|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43183 "use" of the same class in difference scripts results in a fatal error
Submitted: 2007-11-03 17:57 UTC Modified: 2007-11-14 03:42 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-03 (CVS) OS: n/a (linux 2.6, mac os x 10.4)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2007-11-03 17:57 UTC]
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:

namespace Test;

class Helper {}

include dirname(__FILE__) . '/ns_import2.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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-12 15:52 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2007-11-14 03:42 UTC]
Works great now - thanks Dmitry.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Mar 04 19:01:24 2021 UTC