Re: [PHP-DEV] [VOTE] Readonly properties

This is only part of a thread. view whole thread
July 5, 2021 10:03 (Patrick ALLAERT)
Le jeu. 1 juil. 2021 à 12:23, Nikita Popov> a écrit :

> Hi internals, > > I have opened voting on > The vote closes 2021-07-15. > > See for the discussion thread on this > proposal. I think a decent tl;dr is that readonly properties as proposed do > not play well with clone-based withers, so some people believe we should > either improve cloning first, or introduce asymmetric property visibility > instead, which does not suffer from this issue. > > Regards, > Nikita >
Hi Nikita, As much as I wish I could access publicly a property, but being denied changing it: var_dump($object->property); // allowed $object->property = $newObject; //disallowed I feel that the "readonly" feature will be used instead of asymmetric visibility as suggested in "property accessors" RFC in cases where the latter would be more appropriate. I wish "Property accessors" RFC would have been open to vote for 8.1 as you probably initially intended to for the following reasons: - It doesn't suffer from the clone-based withers issue. - It provides a way to declare properties in interfaces. Maybe there are other drawbacks with that one that I don't see? Probably the much higher complexity of it? Although they are different concepts, I'm not sure we would benefit much from "readonly" if we already had property accessors. Just wanted to express my preferences. Thanks for all the work! Regards, Patrick