Re: [RFC] Asymmetric Visibility, with readonly
| From: | Larry Garfield | Date: | Wed, 30 Nov 2022 01:27:41 +0000 |
| Subject: | Re: [RFC] Asymmetric Visibility, with readonly | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119054@lists.php.net to get a copy of this message | ||
On Tue, Nov 29, 2022, at 5:46 PM, Claude Pache wrote:
> In the RFC, section Permitted visibility
> (https://wiki.php.net/rfc/asymmetric-visibility#permitted_visibility
>
> <https://wiki.php.net/rfc/asymmetric-visibility#permitted_visibility>):
>> The set visibility, if it differs from the main (get) visibility, MUST be strictly lesser
>> than the main visibility. That is, the set visibility may only be protected or private. If the main
>> visibility is protected, set visibility may only be private. Any violation of this rule will result
>> in a compile time error.
>>
> The first sentence does not forbid
public public(set), or
> `protected
> protected(set), etc. (the set` visibility does not differ from
> the
> main visibility), but the rest of the paragraph does not allow it. That
> should be clarified.
Er. That's exactly what it says: "strictly lesser" than the main visibility. The
lines after are just restating it. "public public(set)" is not allowed.
(We may relax that in the future to make it compatible with readonly, but that's for later.)
>
> (Because forbidding public public(set), etc., makes it slightly
> more
> cumbersome to explain the rules, I am slightly in favour not to forbid
> it.)
>
>> There is one exception, that of a private readonly property. That would technically expand
>> to private private(set) readonly, which is allowed.
>
> That sentence should be deleted, as readonly is now forbidden.
Good catch, fixed. Thanks.
--Larry Garfield