Re: [RFC] Readonly property hooks
| From: | Tim Düsterhus | Date: | Fri, 18 Jul 2025 14:42:54 +0000 |
| Subject: | Re: [RFC] Readonly property hooks | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128112@lists.php.net to get a copy of this message | ||
Hi
On 7/18/25 16:25, Faizan Akram Dar wrote:
The problem with allowing only set hooks is that readonly class won't be compatible with hooks, I think that is one of the main motivations behind this RFC.Yes. The point is that the semantics users expect from
readonly are fundamentally incompatible with a get hook that could return arbitrarily changing values whenever you read from a property.
Proposing to change this is like proposing an RFC that allows storing a string in a property with type array. It would be a massive break in user expectations for a feature that existed since 4 PHP versions (in case of readonly).
Best regards
Tim Düsterhus