On Wed, Feb 19, 2020, 19:51 Larry Garfield <la...@garfieldtech.com> wrote:
> On Wed, Feb 19, 2020, at 11:05 AM, Máté Kocsis 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 > > As envisoned, does this allow for a property to be set to a dynamic > value? My concern is that while a public locked/writeonce property is > great for access, it doesn't do anything to enable lazy setting on first > access. In fact the only way to do that would be to make it private and > wrap access in a method, which would look exactly like that does now but > with an extra keyword that doesn't actually offer much. > > You could set the value in advance in the constructor, but then it's not > lazy, just locked. > > Is there a way it could support lazy-on-first-use then locked? Máté did run a few teats: operating on a lazy value (before initialisation) seems to work as expected 👍