您可以使用PHPStorm重构功能(游标在SomeOtherClass,Shift F6上),它允许重命名别名及其用法.
如果您已经在脚本中使用了SomeClass而没有别名,那么首先应该设置一个具有相同名称的别名:
use MyNamespace\SomeClass as SomeClass;
然后重构这个别名,如上所述.
另一个解决方案:
If you import a conflicting name, like Foo\MyClass and you already have use Bar\MyClass; in your document, you should be faced with the following prompt
+--------------------------------------------+
| Import class |
+--------------------------------------------+
| Alias name: |
| [________________________________________] |
| |
| [X] Always create alias while class import |
| |
| [ OK ] [ Cancel ] |
+--------------------------------------------+
The trick is to check the “Always create alias” checkbox to always be
faced with the prompt while importing.
Forgot to mention that you should also uncheck the settings
Settings > Editor > General > Auto Import > [ ] Enable auto-import in
file scope
Settings > Editor > General > Auto Import > [ ] Enable auto-import in
namespace scope