I'm new to PHPStorm and want to ask how can I get fully-classified class name (absolute path to the class) using Code Completion (Command+Space)?
For example, I have a function in my code:
<?php
namespace A;
use C\D\Class;
/**
* @return Class (what PHPStorm suggests)
* @return \C\D\Class (what I need)
*/
function foo() {
return new Class();
}
?>
This function returns an instance of \C\D\Class When generating docblock for this function, I use Command+Space to place class name after @return keyword. PHPStorm suggests Class in the expanded list but when I select necessary class it places only "Class" instead of "\C\D\Class".
How can I fix it?
Thanks in advance.
Press Ctrl + Alt + Shift + C (Edit | Copy Reference) on "Editor" in the code and you'll have the fully-qualified name in your clipboard.
I have tried the following according to this thread (Intellij IDEA CE 12 Android XML Code Completion not working): Go to File->Power Save Mode and disable it - it is off. Go to Preferences->Editor->Code Completion and check Autopopup code completion - this has been checked. Go to File->Invalidate Caches and restart.
I had the same issue too. Actually it is very simple, but I also did not find the option. It is well hidden.
Open the settings and go to:
IDE Settings -> Editor -> Auto Import
There you'll find the checkbox "Enable auto-import in namespace scope". Uncheck it, and namespaces will not be shorten anymore using the"use" keyword.
But now PhpStorm will tell you that it is unnecessary to use the complete namespace. To avoid that just disable the inspection "Unnecessary fully qualified name".
You are still able to tell PhpStorm to import the current class' namespace. For me it is just marking the class with the cursor and pressing ALT+ENTER. Then this dialog appears:
When I confirm with ENTER the namespace of this class becomes imported and shorten:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With