PHPStorm refactor shortcut to give an alias in use statement
You can use PHPStorm refactoring feature (cursor on SomeOtherClass, Shift+F6), it allows to rename alias and its usages.
click here to see the screenshot
If you have already used SomeClass in your script without an alias, first you should set an alias with the same name:
use MyNamespace\SomeClass as SomeClass;
and then refactor this alias, as decribed above.
Another one solution:
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
https://laracasts.com/discuss/channels/general-discussion/phpstorm-importing-namespaces-with-aliases/replies/99388
With PhpStorm 2018.3 you can use "Replace with Alias" feature: https://blog.jetbrains.com/phpstorm/2018/12/new-refactorings-in-phpstorm-2018-3/