ID: 42859 Updated by: [EMAIL PROTECTED] Reported By: greg at chiaraquartet dot net Status: Open Bug Type: Scripting Engine problem Operating System: linux PHP Version: 5CVS-2007-10-05 (CVS) New Comment:
accidentally didn't log in as cellog to submit this. Previous Comments: ------------------------------------------------------------------------ [2007-10-05 02:03:44] greg at chiaraquartet dot net Description: ------------ zend_do_import incorrectly compares an import name to global class names. It should compare EG(current_namespace) . '::' . importname to check for conflicting names. This is because when inside a namespace, to the user, import should behave in the same manner as a class declaration. This code: <?php namespace Foo; class Exception {} ?> creates Foo::Exception. This code: <?php namespace Foo; import Blah::Exception as Exception; ?> Should essentially work as if the user had typed: <?php namespace Foo; import Blah::Exception as Foo::Exception; ?> In other words, it should resolve future uses of "Exception" to "Blah::Exception" and "::Exception" to "Exception" and not complain about "Exception" conflicting with "::Exception" Patch for PHP 5: http://pear.php.net/~greg/fix_import.patch.txt Patch for PHP 6: http://pear.php.net/~greg/fix_import.php6.patch.txt Reproduce code: --------------- testme.php: <?php namespace Blah; class Exception extends ::Exception {} ?> test.php: <?php namespace Foo; include 'testme.php'; import Blah::Exception; $a = new Exception; throw $a; ?> Expected result: ---------------- Fatal error: Uncaught exception 'Blah::Exception' in /home/cellog/workspace/php5/test.php:5 Stack trace: #0 {main} thrown in /home/cellog/workspace/php5/test.php on line 5 Actual result: -------------- Fatal error: Import name 'Exception' conflicts with defined class in /home/cellog/workspace/php5/test.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42859&edit=1