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

From: Date: Thu, 20 Feb 2020 08:58:02 +0000
Subject: Re: [RFC] [DISCUSSION] Immutable/final/readonly properties
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-108693@lists.php.net to get a copy of this message
> > I would expect that operating on one of these properties before it's > initialized will throw an error: > Actually, the RFC only says that the "immutability" of properties is guaranteed after initialization. We could of course change this premise, but that would make some important use-cases (like what Marco's ProxyManager has) impossible to do. Furthermore, unsetting properties could be completely disabled by another RFC, given there is a migration path for the legitimiate use-cases. As far as I remember, the "Locked Classes" ( https://wiki.php.net/rfc/locked-classes) and lately the "Rigid Properties" (https://github.com/php/php-src/pull/5170) RFCs try to have their shots at it. > Does that work currently or no? If so, this is pretty sweet. If not, it > seems to be of limited use. > No, it doesn't work, and it seems to be an unrelated feature for me. As far as I understand your example, it's the topic of the "Constant expressions" RFC. I believe the behaviour proposed by my RFC would be still useful in many cases where one wants to be sure that no unexpected modifications can happen with a property. My use-cases would mainly include objects storing different kind of data: events, value objects, data transfer objects. Máté Kocsis

« previous php.internals (#108693) next »