Re: [RFC] Change Directory class to behave like an opaque object

From: Date: Tue, 01 Oct 2024 20:56:49 +0000
Subject: Re: [RFC] Change Directory class to behave like an opaque object
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-125717@lists.php.net to get a copy of this message
On Tue, Oct 1, 2024, at 22:21, Nick Lockheart wrote: > On Tue, 2024-10-01 at 16:36 +0000, Gina P. Banyard wrote: > > On Wednesday, 25 September 2024 at 10:12, Nick Lockheart > > <lists@ageofdream.com> wrote: > > > > > On Sat, 2024-09-14 at 15:33 +0000, Gina P. Banyard wrote: > > > I don't suppose we could call the Directory class something else, > > > like > > > "SPLDirectory"? > > > > > > You can't make a Directory with new (or at least > > > you aren't > > > supposed > > > to be able to), so any existing code would already get a Directory > > > object with dir() not new > > > Directory(). There would be no BC > > > break > > > with a rename. > > > > This is factually incorrect. > > This would be a large BC break, moreover PHP "owns" the global > > namespace. > > > > Is every single word really a reserved word in the global namespace? > > > > Otherwise, if you are in the global namespace and try to create a > > class which is called Directory this would result in an Error being > > thrown. > > > > Actually, it will not throw an error because classes are auto loaded. > > The auto loader will not run because Directory is already registered. > It will instantiate a built-in Directory object. > > An error would only be thrown if the file with the other Directory > class is manually included, which most people do not do anymore for > class definitions. > Hey Nick, Is this actually an issue though? \Directory would be a weird thing to autoload. Most people tend to autoload specific namespaces. I think it would be weird to autoload into the global namespace. Maybe I am wrong, and that is why I ask. — Rob

« previous php.internals (#125717) next »