Re: [RFC] Asymmetric visibility

From: Date: Mon, 08 Aug 2022 13:39:25 +0000
Subject: Re: [RFC] Asymmetric visibility
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-118391@lists.php.net to get a copy of this message
On Sun, Aug 7, 2022 at 10:38 PM Rowan Tommins <rowan.collins@gmail.com> wrote: > On 07/08/2022 11:54, Lynn wrote: > > Reading "public private", "public protected", or "protected > > private" > > reads really weird public private(set) static self $propertyZnç¡:«ëä³< > > ÔÖ. > > > Interesting, it seems that you've unconsciously broken it up as "public > private" followed by "(set)", rather than "public" followed by > "private(set)". Perhaps it's because of the position of the parentheses, > which do feel awkward to me at first glance. Would it read more > naturally to you with different punctuation? > > public (private set) static self $property; > > Or: > > (public; private set) static self $property; > > Or: > > public private-set static self $property; > The more I think about it, the more I agree with Marco's point of view on this. I don't think there's a way to add this functionality without it looking confusing one way or another. Once I get to use php8+, I'll probably end up using readonly for most code. I think the feature itself is nice for the scenario where you want to have private or protected mutability, but even this is a scenario I would avoid myself. I'm afraid that based on the future possibilities package(set) will make it even more confusing when allowing external modifications by specific classes, which would make it even more complicated to find out who or what may or may not modify a property from a reader perspective (like code reviews).

« previous php.internals (#118391) next »