On Sun, Apr 20, 2025 at 7:46 AM Rob Landers <rob@bottled.codes> wrote: > > On Mon, Mar 31, 2025, at 21:45, Rob Landers wrote: > > Hello internals, > > I have significantly revamped the RFC (again). Key changes to the RFC: > > 1. More (realistic) examples, > 2. Since enums are basically specialized classes, they are allowed to be > nested as well (hat tip to Reddit), > 3. Using backslash as the class separator, > 4. Proper scoping (and shadowing), > 5. Nesting is allowed in interfaces and enums as well as classes; but not > traits, > 6. (Hopefully) Clearer wording, > 7. Nesting in traits, or nested traits, are future scope, > 8. Nested interfaces are future scope too. > > Some benefits of using \ as a separator: > > - a simple name can refer to nested classes: > > Scope resolution was expanded to treat inner classes within the same class as > “in scope.” This provides a more natural usage: > > class Outer { > class Inner {} > public function foo(Inner $inner) {} > } > > - Standard “use” statements can alias them: > > use Outer\Inner as Inner; > > But it also has some draw backs: > > - The engine doesn’t know that Outer\Inner is a nested class and autoloaders > will have to account for that. It will only ask for Outer\Inner. > > - You cannot simply refer to parent:>Inner, you have to explicitly ask for > the parent by name: SomeParentClass\Inner. > > A draft implementation (which is more of a proof-of-concept) is available on > GitHub. > > > Hello internals, > > As it seems that discussion has mostly died down, I'd like to put this > towards a vote starting on May 1, 2025. > > — Rob
I intend to vote no. Fundamentally, this proposal adds a form of "packaging" which only affects classes. There's no packaging for constants or functions, unless you put them onto a class to make them class constants and static methods. This is weird to me. I would prefer that we work out something more general. I am also worried that naming collisions are possible. Something like this: ```php namespace A { class B {} } namespace { class A { class B {} } } ``` Where `A\B` refers to two possible things. I don't like this, and to my knowledge, this type of confusion has not been possible in the past. Of course, feel free to point it out if so. Note that methods and properties of the same name are disambiguated by syntax, where here the syntax is the same.