|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-05 02:16 UTC] cellog@php.net
[2007-10-05 06:56 UTC] dmitry@php.net
[2007-10-05 14:26 UTC] cellog@php.net
[2007-10-17 09:59 UTC] dmitry@php.net
[2007-10-17 10:01 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 11:00:01 2025 UTC |
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