Re: Allow hooks in `readonly` promoted properties

From: Date: Thu, 05 Jun 2025 17:06:35 +0000
Subject: Re: Allow hooks in `readonly` promoted properties
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-127613@lists.php.net to get a copy of this message
On Thu, Jun 5, 2025, at 1:12 AM, Nick wrote:
> Hey internals,
>
>> On 4. Jun 2025, at 20:19, Nick <php@nicksdot.dev> wrote:
>>> I believe at the moment that RFC text is all there is. :-)  I don't know that
>>> it's worth opening a discussion without at least a mostly-done implementation.  Also, Ilija is
>>> rather busy on other tasks at the moment, as am I.  (Unless someone else wants to jump in to
>>> implement it, which would be fine.)
>> 
>> People often say “you can just do things”. So I did, and tried to contribute the code
>> for your existing RFC text:
>> 
>> https://github.com/php/php-src/pull/18757
>
> Would this be expected to work? Can interface properties be declared readonly?
> interface Cleaned
> {
>     public readonly string $clean { get; } // has readonly
> }

Interface properties cannot be declared readonly today:

https://3v4l.org/cXgR0

Which I think is correct behavior.

Make sure to include a test based on the "lazy product" example from the RFC text. 
That's the main sort of use case I'd expect we'd want to enable. :-)

--Larry Garfield


Thread (14 messages)

« previous php.internals (#127613) next »