Re: [RFC][Vote announcement] Property hooks
| From: | Nicolas Grekas | Date: | Wed, 10 Apr 2024 14:56:56 +0000 |
| Subject: | Re: [RFC][Vote announcement] Property hooks | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123091@lists.php.net to get a copy of this message | ||
Hi Ilija, Larry,
Heads-up: Larry and I would like to start the vote of the property
> hooks RFC tomorrow:
> https://wiki.php.net/rfc/property-hooks
>
I would make 3 changes to the RFC if I were in charge :
- I'd make $this->propName inside a hook access the parent property via
its hooks if any. I'd do this because that'd provide
encapsulation-by-default for inheritance. Aka a parent class could
reasonably expect its child classes to get through its hooks. (I'd be fine
with only allowing the "=" operator on this.)
- I'd keep the special $field value to access the backing value. It's a
clear way to signify that accessing the raw value is possible only in
hooks, never in other methods.
- And I'd consider forbidding any method calls in hooks except static
methods. This would allow factorising functional logic without opening for
side-effects on the object outside of hooks themselves.
I'm sharing this in case it rings a bell somewhere, but I can work with the
peculiarities of the current RFC and I must admit I didn't spend as much
time as you on the topic so my proposals might fall short, while yours to
actually work. Thanks for that :)
I'm in favor of the RFC.
Cheers,
Nicolas