Re: RFC: Namespace-Scoped Visibility for Methods and Properties
| From: | Volodymyr Volynets | Date: | Sun, 09 Nov 2025 20:25:25 +0000 |
| Subject: | Re: RFC: Namespace-Scoped Visibility for Methods and Properties | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129180@lists.php.net to get a copy of this message | ||
Hi,
Did we take into account prefixed namespaces.
private(namespace \Users\Auth\*) function test() {}
And then Auth folder has other classes and folders with child namespaces.
Sent from my iPhone
> On Nov 9, 2025, at 2:56 PM, Tim Düsterhus <tim@bastelstu.be> wrote:
>
> Hi
>
>> On 11/9/25 20:41, Rob Landers wrote:
>> class P {
>> private(namespace) function x() {}
>> }
>> class C extends P {
>> protected function x() {}
>> }
>> This behaves the same as overriding a private method with a protected/public one today: the
>> parent’s method is private to its declaring class, so the second example is allowed.
>
> This is unsound. As we have established, neither
>
private(namespace) nor protected is
> a subset of each other.
>
> Specifically allowing this breaks the following (everything is declared in the same namespace):
>
> class P {
> private(namespace) function x() { }
> }
> class C extends P {
> protected function x() { }
> }
>
> function f(P $p) {
> $p->x(); // legal, because f is in the same namespace as P.
> }
>
> f(new C()); // breaks, because C::x() is protected and thus not legal to access from f / the
> global scope.
>
> Best regards
> Tim Düsterhus