Re: [RFC] Asymmetric Visibility, with readonly
| From: | Deleu | Date: | Sun, 13 Nov 2022 22:08:25 +0000 |
| Subject: | Re: [RFC] Asymmetric Visibility, with readonly | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118998@lists.php.net to get a copy of this message | ||
>
>
> This is untrue. You can declare a private property identically in a
> parent and child class, even readonly. I'm doing this now in a project.
> It works, but would be unnecessary if the parent's property were
> protected(set).
>
> --Larry Garfield
>
I do understand the slight complexity here (perhaps stronger in terms of
implementation), but my assumption was that if a property is private and
"the set visibility must be tighter", PHP would never assume `private
protected(set) readonly
. In other words, if private readonly` then
private private(set) readonly, therefore nothing changes. You can keep
the use of disjointed variables in inheritance provided they're all
private. The only concern is when a property is declared protected, which
then evaluates to what I mentioned on the previous email.
I'm also under the stated assumption that public public(set) readonly is
not something needed to be supported.
--
Marco Deleu