Dmitry Stogov wrote: > In your example : > > <?php > namespace Foo; > import Blah::Exception; > $a = new Exception; > ?> > > "new Exception" refer to "Blah::Exception" and will fail if such class > doesn't exists. > > "import Blah::Exception" creates an alias with short name "Exception" only > for current file (it doesn't creates "Foo::Exception") > > May be I didn't understood the question. :)
Yes, you do misunderstand I think :) testme.php: <?php namespace Blah; class Exception extends ::Exception {} ?> test.php: <?php namespace Foo; include 'testme.php'; import Blah::Exception; $a = new Exception; ?> result: [EMAIL PROTECTED]:~/workspace/php5$ sapi/cli/php -n test.php Fatal error: Import name 'Exception' conflicts with defined class in /home/cellog/workspace/php5/test.php on line 4 This is because of this check: if (zend_hash_exists(CG(class_table), lcname, Z_STRLEN_P(name)+1)) { zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined class", Z_STRVAL_P(name)); } we are comparing "Exception" to "Exception" in the class table, and so we get a fatal error. We should instead transparently import Blah::Exception not as "Exception" but as "Foo::Exception" *only* for the above comparison check. In other words, import needs to honor namespace when checking for class naming conflicts. If you can create class "Exception" inside namespace Foo and refer to it as "Exception" then import Blah::Exception should also allow referring to "Exception" *if* "Foo::Exception" doesn't already exist. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php