Re: RFC: Namespace-Scoped Visibility for Methods and Properties
| From: | Alexandru Pătrănescu | Date: | Sun, 09 Nov 2025 06:09:27 +0000 |
| Subject: | Re: RFC: Namespace-Scoped Visibility for Methods and Properties | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129159@lists.php.net to get a copy of this message | ||
Hi Rob
On Sat, Nov 8, 2025, 14:46 Rob Landers <rob@bottled.codes> wrote:
> Hello Internals,
>
> I’d like to introduce an RFC for discussion:
> https://wiki.php.net/rfc/namespace_visibility which proposes a
> new
> visibility modifier: private(namespace).
>
> This idea has appeared several times in previous threads but never
> progressed to a formal proposal (from what I could find). My hope is that
> with defined semantics, examples, and implementation details, we can
> evaluate it properly and see whether there’s support for moving forward.
> Feedback is very welcome.
>
>
Nice work on this.
I have one issue:
> *Visibility hierarchy: *public < protected < private(namespace) < private
I think is not a correct view of the real problem space, as the protected
and private namespace scopes are separate sets that might have things in
common but can also be distinct.
I think the correct way to model it, is to have two hierarchies:
public < protected < private
public < private(namespace) < private
Otherwise you can have things like
protected private(namespace)(set)
that is unclear how it should be handled.
Can you clarify what is the right-now expected get and set allowance for
these cases:
- child classes in the same namespace
- child classes in another namespace
- non-child classes in the same namespace
My suggestion is to not allow mixing protected and private namespace for
aviz.
--
Alex