Re: [RFC] Readonly property hooks
| From: | Larry Garfield | Date: | Fri, 18 Jul 2025 15:51:25 +0000 |
| Subject: | Re: [RFC] Readonly property hooks | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128116@lists.php.net to get a copy of this message | ||
On Fri, Jul 18, 2025, at 9:50 AM, Marco Pivetta wrote:
> On Fri, 18 Jul 2025 at 16:43, Tim Düsterhus <tim@bastelstu.be> wrote:
>> 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.
>
> Just a heads up: I also plan to vote "no" on this RFC because the
> expectation with readonly is that there is no kind of
> interference or
> lazy initialization anyway.
>
> Now that lazy proxies have landed into core, there is also no need for
> __get hacks anymore.
Even on set hooks, which do not violate any of the interpretations of what readonly
"means" floating about? As the RFC notes, that's now a necessary validation step
with the improved clone() on its way.
--Larry Garfield