Re: Re: RFC: Nested Classes

From: Date: Wed, 07 May 2025 17:21:08 +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 07/05/2025 14:10, Tim Düsterhus wrote:
And rewrite all references inside of Foo to Foo$Bar (using Java's name mangling). This is effectively what Ilija's proposal for file-private classes did: https://externals.io/message/126331#126337. I think this would also be nicer on the autoloading impact. Since a private class is not usable outside of its container class, it doesn't make sense to attempt to autoload it individually, since to reference it, the container class must already be loaded (which means the private class is also already loaded).
I agree that this would be possible; I disagree that it is essential, or that it has anything to do with consistency with the rest of the language. I'm not even sure if it would be a good idea - it would mean having what appears to be a fully-qualified name actually "shadowed" by a completely unrelated definition within a particular scope. For example "\Foo\Bar" would still refer to "namespace Foo, class Bar" in most of the program, but "class Foo, nested class Bar" in the context of class Foo. If the visibility was changed to "public", the shadowing would instantly become a conflict anyway; and I can't picture how "protected" would work. -- Rowan Tommins [IMSoP]

Thread (102 messages)

« previous php.internals (#127304) next »