Re: Order of class resolution with namespaces and autoload

From: Date: Sat, 20 Oct 2007 23:42:17 +0000
Subject: Re: Order of class resolution with namespaces and autoload
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-32897@lists.php.net to get a copy of this message
Quoting Stanislav Malyshev <stas@zend.com>:
But you shouldn't even look for Exception then. I'm saying that if you want the global Exception class you should import it.
That would be double bad - that means you have to go over all your code and add :: to all instances of global classes, even though you never ever intended to override any of them. I don't think it's a good idea.
No, you just have to import them into your namespace, right next to the namespace declaration. Which solves both problems - ease of using global classes and the extra autoload. Honestly I don't know if having a PHP:: namespace with an alias to the builtin classes is feasible, but if it is, then the simple, "put global classes into my namespace" ("register_globals" ;) option is: namespace Test; import PHP; -chuck

« previous php.internals (#32897) next »