Re: RFC: Namespace-Scoped Visibility for Methods and Properties
| From: | Rowan Tommins [IMSoP] | Date: | Sat, 08 Nov 2025 16:50:26 +0000 |
| Subject: | Re: RFC: Namespace-Scoped Visibility for Methods and Properties | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129150@lists.php.net to get a copy of this message | ||
On 08/11/2025 12:43, Rob Landers wrote:
I’d like to introduce an RFC for discussion: https://wiki.php.net/rfc/namespace_visibility which proposes a new visibility modifier: private(namespace).Hi Rob, Thanks for putting together the RFC. My main concern with this and similar single-keyword proposals is that its only useful if people lay out their code in a particular way, rather than fitting with the variety of namespace hierarchies seen in the wild. For instance, in your example, you have two classes: - App\Auth\SessionManager - App\Auth\SessionStore But if this was library with a set of interchangeable session stores, it might well lay them out like this: - Acme\AuthLib\Session\Manager - Acme\AuthLib\Session\Store\SessionStoreInterface - Acme\AuthLib\Session\Store\DatabaseSessionStore - Acme\AuthLib\Session\Store\FileSystemSessionStore - etc In that case, "current namespace plus children" would work, and I'd be interested in your reasoning for requiring an exact match instead. But even that might not be enough, if for some reason it looked like this: - Acme\AuthLib\Services\SessionManager - Acme\AuthLib\Implementations\SessionStore\SessionStoreInterface - Acme\AuthLib\Implementations\SessionStore\DatabaseSessionStore - Acme\AuthLib\Implementations\SessionStore\FileSystemSessionStore - etc Here, what we want is visibilty for everything inside "Acme\AuthLib", not only in "Acme\AuthLib\Services". Since, as you say in another reply, we don't have a standard definition of "module", "package", or "assembly", I think we need a keyword or attribute which takes as a parameter either the namespace prefix, or the number of levels to match. -- Rowan Tommins [IMSoP]