Someone recently requested something similar for a PHP static analysis tool
I wrote (https://psalm.dev/r/f75997a263), though that version only allows
lazy initialisation inside the class in which a given property is declared.

Personally I don't like either approach – I think per-property getters and
setters would be a more appropriate venue for this functionality, something
like:

property int $s {
    public get;
    private set;
}

This pattern could also be extended to support per-property getter and
setter methods.

On Wed, 19 Feb 2020 at 12:06, Máté Kocsis <kocsismat...@gmail.com> wrote:

> Hi Internals,
>
> I'd like to move my RFC forward to the discussion phase:
> https://wiki.php.net/rfc/write_once_properties
>
> In short, I propose to add support for a new property modifier that would
> allow properties to be initialized, but not modified afterwards.
>
> Cheers,
> Máté Kocsis
>

Reply via email to