Re: Namespaces and __autoload()

From: Date: Mon, 27 Aug 2007 22:31:11 +0000
Subject: Re: Namespaces and __autoload()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-31947@lists.php.net to get a copy of this message
Jochem Maas wrote: > Dmitry Stogov wrote: >> This is an implementation of Stas idea. >> >> 1) Look for existent class in current namespace >> 2) Look for existent internal class >> 3) Try to autoload class from current namespace >> > > both ways have a wtf factor in that class with names > matching 'internal' class names behave differently. > > afaict you would not be able to autoload class Exception > from within namespace Foo in the example below. > > currently one cannot create classes named the same as > 'internal' classes ... obviously. > > I would consider making internal class names illegal > in namespaces. this would be consistent simple and clear. If this happens, namespaces will be useless, and we'll be forced to use _ in all classnames again to avoid potential conflicts with internal classes. > > also I don't see what would be gained from being allowed > to do: > > <?php > > namespace Foo; > class Exception extends Exception {}; That looks awful :). This should be: class Exception extends ::Exception {} Anything else does not strike me as good coding practice. Greg

« previous php.internals (#31947) next »