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 <[email protected]> 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

Reply via email to