Re: [RFC] Asymmetric Visibility, with readonly
| From: | Ilija Tovilo | Date: | Mon, 14 Nov 2022 12:00:23 +0000 |
| Subject: | Re: [RFC] Asymmetric Visibility, with readonly | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119004@lists.php.net to get a copy of this message | ||
Hi Derick
> > As I understand it, you’re suggesting that a property declared as
> >
public protected(set) would never trigger __set().
>
> I would think that that would be against our current practice, which is
> easy enough to explain as "if the property isn't visible set,
> then use __set()". I would argue that "protected(set)" marks a property
> as invisible from a non-inherited class/method, and hence __set should
> be called.
What you're describing does not match the readonly behavior.
https://3v4l.org/X76pV
Readonly properties only call __set once they are explicitly unset.
The same applies to __unset. I changed this in the asymmetric
visibility implementation recently to match this behavior but the RFC
has not been adjusted to reflect this yet.
AFAIK this behavior is there to allow calls to __set for certain edge
cases. While not very intuitive it makes sense to stay consistent. If
this behavior is undesirable we should change it in both places.
Ilija