Re: RFC: Namespace-Scoped Visibility for Methods and Properties
| From: | Tim Düsterhus | Date: | Sun, 09 Nov 2025 19:55:31 +0000 |
| Subject: | Re: RFC: Namespace-Scoped Visibility for Methods and Properties | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129178@lists.php.net to get a copy of this message | ||
Hi
On 11/9/25 20:41, Rob Landers wrote:
class P {This is unsound. As we have established, neitherprivate(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.
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