Re: Re: [RFC][Discussion] Harmonise "untyped" and "typed" properties
| From: | Robert Landers | Date: | Thu, 23 Nov 2023 08:09:15 +0000 |
| Subject: | Re: Re: [RFC][Discussion] Harmonise "untyped" and "typed" properties | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121771@lists.php.net to get a copy of this message | ||
On Thu, Nov 23, 2023 at 8:56 AM Rowan Tommins <rowan.collins@gmail.com> wrote:
>
> On 23 November 2023 01:37:06 GMT, Claude Pache <claude.pache@gmail.com> wrote:
> >What you describe in the last sentence is what was initially designed and implemented by
> >the RFC: https://wiki.php.net/rfc/typed_properties_v2 (section
> >Overloaded Properties).
> >
> >However, it was later changed to the current semantics (unset() needed in order to trigger
> >__get()) in https://github.com/php/php-src/pull/4974
>
>
> Good find. So not only is it not specified this way in the RFC, it actually made it into a live
> release, then someone complained and we rushed out a more complicated version "to avoid
> WTF". That's really unfortunate.
>
> I'm not at all convinced by the argument in the linked bug report - whether you get an
> error or an unexpected call to __get, the solution is to assign a valid value to the property. And
> making the behaviour different after unset() just hides the user's problem, which is that they
> didn't expect to *ever* have a call to __get for that property.
>
> But I guess I'm 4 years too late to make that case.
>
> Regards,
>
> --
> Rowan Tommins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
Heh
> But I guess I'm 4 years too late to make that case.
4 years ago, I was using this behavior to write proxies that actually
called things over the network instead of the properties. I didn't
file that bug, but I probably would have filed something similar.
Nowadays, those proxies are dead as we long since generated code based
on interfaces (so they'll pass PHP type checks). I venture once we
have property hooks (assuming that is still a thing coming along),
this behavior can be removed completely as you can just use property
hooks instead of unset to call __get. I'm actually quite excited about
property hooks and hope they pass.
Personally, I haven't used this behavior since 7.4-ish, and I'd be
surprised to see it relied on in modern PHP: code generation is too
easy these days.
Robert Landers
Software Engineer
Utrecht NL