Re: [RFC] Asymmetric Visibility, with readonly
| From: | Derick Rethans | Date: | Tue, 15 Nov 2022 10:34:09 +0000 |
| Subject: | Re: [RFC] Asymmetric Visibility, with readonly | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119012@lists.php.net to get a copy of this message | ||
On Mon, 14 Nov 2022, Ilija Tovilo wrote:
> 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.
Now I have re-read the Assymetric Visibility RFC's "Interaction with
__set"
(https://wiki.php.net/rfc/asymmetric-visibility#interaction_with_set),
I'm slightly more confused. Could you update that section, as what it
currently states seems reasonable.
cheers,
Derick