Re: [RFC[ Property accessor hooks, take 2
| From: | Benjamin Außenhofer | Date: | Tue, 27 Feb 2024 20:51:36 +0000 |
| Subject: | Re: [RFC[ Property accessor hooks, take 2 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122525@lists.php.net to get a copy of this message | ||
Hey,
On Wed, Feb 21, 2024 at 7:58 PM Larry Garfield <larry@garfieldtech.com>
wrote:
> Hello again, fine Internalians.
>
> After much on-again/off-again work, Ilija and I are back with a more
> polished property access hooks/interface properties RFC. It’s 99%
> unchanged from last summer; the PR is now essentially complete and more
> robust, and we were able to squish the last remaining edge cases.
>
> Baring any major changes, we plan to bring this to a vote in mid-March.
>
> https://wiki.php.net/rfc/property-hooks
>
> It’s long, but that’s because we’re handling every edge case we could
> think of. Properties involve dealing with both references and inheritance,
> both of which have complex implications. We believe we’ve identified the
> most logical handling for all cases, though.
>
> Note the FAQ question at the end, which explains some design choices.
>
> There’s one outstanding question, which is slightly painful to ask:
> Originally, this RFC was called “property accessors,” which is the
> terminology used by most languages. During early development, when we had
> 4 accessors like Swift, we changed the name to “hooks” to better indicate
> that one was “hooking into” the property lifecycle. However, later
> refinement brought it back down to 2 operations, get and set. That makes
> the “hooks” name less applicable, and inconsistent with what other
> languages call it.
>
> However, changing it back at this point would be a non-small amount of
> grunt work. There would be no functional changes from doing so, but it’s
> lots of renaming things both in the PR and the RFC. We are willing to do so
> if the consensus is that it would be beneficial, but want to ask before
> putting in the effort.
thank you for this proposal. there are some points i'd like to make into
this discussion:
* Thank you for the removal of $field, it was non-idomatic from a PHP POV.
* I would prefer that the short syntax $foo => null; be voted upon
separately. Personally I think it could be confusing and is too close to a
regular assignment for default value and I prefer not to have it and keep
the rest of the RFC.
* The magic of detecting if a property is virtual or backed is - like Rowan
said - subtle. I would also prefer this to be managed via an explicit
mechanism, by for example keywording the property as "virtual", instead of
the implicit way with the parsing based detection.
* As Doctrine project maintainer, we have had some troubles supporting read
only properties for proxies. I would have hoped that with hooks I can
overwrite a readonly property and "hook" into it instead by defining a
getter, but "no setter". From my read of the RFC this would not be allowed
and throws a compile time error. Could you maybe clarify why at least this
special case is not possible? I didn't immediately get it from the RFC
section on readonly as it only speaks about the problems in abstract.
greetings
Benjamin
>
> --
> Larry Garfield
> larry@garfieldtech.com
>