|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-12 15:52 UTC] dmitry@php.net
[2007-11-14 03:42 UTC] chagenbu@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
Description: ------------ As per discussion on the PHP internals list, the proper way to ensure that when using a short name, the class loaded is always from the current namespace (even if it needs to be autoloaded and has not yet been loaded) is to import that class in every file where it is used. However, doing so in two separate scripts, OR just importing a class that has already been defined in the namespace, can result in a fatal error claiming an import clash. Because of the nature of namespaces and this bug it requires 2 small scripts to reproduce, not one. Reproduce code: --------------- ns_import1.php: --------------- <?php namespace Test; class Helper {} include dirname(__FILE__) . '/ns_import2.php'; ns_import2.php: --------------- <?php namespace Test; import Test::Helper; class Other {} Expected result: ---------------- No error, should be no output. Actual result: -------------- $ php ns_import1.php Fatal error: Import name 'Helper' conflicts with defined class in /tmp/ns_import2.php on line 5