Closed Erikvv closed 8 years ago
How are you producing that error, exactly?
I ask, because all of the various writers are tested, and the tests do not raise any errors. PHP itself resolves based on the imported classes first; if an import matches, it uses that, instead of attempting to resolve to a class in the same namespace. If you do not believe me, please try out my example.
If you can reliably reproduce the issue, please provide me with a unit test or instructions on how to reproduce it.
Are you, by any chance, using EdpSuperluminal in your application? If so, please disable it and let me know if that resolves the issue for you.
Thanks for putting in your effort.
Your test does not represent my scenario: I am actually instantiating the legacy xxxPluginManager class beforehand.
I am using PHP 7.0.9 (I am not using EdpSuperluminal).
This test.php demonstrates the scenario and produces the same error: https://github.com/Erikvv/php-namespace-conflict (N.B. demo gives the same result in PHP5 and 7)
Ofcourse you could say the solution is to simply instantiate the right (non-deprecated) class but is a BC break nonetheless.
@Erikvv your example has one mistake - in Test\Namespaced\Class2
you should have:
use Test\Class1;
but even with that it is not gonna work. The problem is with load class order, as you suggest it in your comment. If namespaced class was used before (is already loaded) then import class with the same name to the namespace class will be failed. I've prepared also my example with travis build here: https://github.com/webimpress/php-namespace-conflict and two examples - working and broken.
Please notice the problem does not occur on hhvm!
Fixes the following error:
Cannot use Zend\Log\FilterPluginManager as FilterPluginManager because the name is already in use in ./vendor/zendframework/zend-log/src/Writer/AbstractWriter.php on line 15