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

From: Date: Fri, 14 Feb 2020 13:42:44 +0000
Subject: Re: [RFC] [PROPOSAL] Immutable/final/readonly properties
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-108575@lists.php.net to get a copy of this message
> > If somebody really wants a mixed property to be immutable, they > could > write `private immutable null|bool|int|float|string|array|object > $property;`. > Yeah, one of my ideas was to first add support for mixed (for which there have been a proposal/PR since quite some time), so that all non-typed properties could be implicitly upgraded to the mixed type. But I don't think it's the way to go... Maybe only if our long-term goal would be to deprecate/remove non-typed properties and implicit initialization altogether in favour of mixed type and implicit uninitialization... > That would make implementation straightforward, since you'd expect > immutable to be before a type declaration (can be done in the > parser, > right?). > Yeah, the implementation didn't seem very tricky yet (but people with more experience with the internals of PHP should tell). However, Nikita also warned me not to support references. So this is another question to decide...

« previous php.internals (#108575) next »