Re: Re: RFC: Nested Classes

From: Date: Tue, 06 May 2025 19:33:32 +0000
Subject: Re: Re: RFC: Nested Classes
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


On 4 May 2025 14:52:23 BST, "Tim Düsterhus" <[email protected]> wrote:

>> It's also not a new problem: PHP doesn't enforce a file and directory layout, and
>> libraries can and do define things "inside" each other's namespaces. When declaring a
>> class, you have to be aware of whether a class with the same fully-qualified name has been, or will
>> be, declared in another file.
>
>This is correct, but all these other classes that could conflict are part of the *public API* of
>a library. But now with private nested classes I would also be aware of the private part of a
>library to avoid conflicts.

The classes that you'll need to be aware of will exist whether this feature is added or not,
and you'll already need to avoid conflicting with them - usually by simply avoiding the main
namespace prefix of the library.

Probably they will be currently marked "@internal" or highlighted in documentation in some
way, to indicate that they are not intended as part of the public API; the only difference will be
that now you'll get an error if you ignore that documentation.

Rowan Tommins
[IMSoP]


Thread (102 messages)