Re: [RFC] [DISCUSSION] Immutable/final/readonly properties

From: Date: Thu, 20 Feb 2020 00:26:25 +0000
Subject: Re: [RFC] [DISCUSSION] Immutable/final/readonly properties
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108692@lists.php.net to get a copy of this message
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 <kocsismate90@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 >

« previous php.internals (#108692) next »