Use fully qualified class names in PHPDocs only
Answered
Hello,
in our PHP 7 project, our styling guideline requires, that imported classes should be shortened in general, but PHPDoc tags must have the fully-qualified namespace.
use Fully\Qualified\ClassName;
/**
* @param \Fully\Qualified\ClassName $complexType
*
* @return \Fully\Qualified\ClassName
*/
public function setExample(ClassName $complexType): ClassName
{
...
}
Under
Editor->Codestyle->PHP->PHPDoc->Generated PHPDocs tags
there is a option Use fully-qualified class names which should do exactly this in my opinion
But activating this seems to lead to a false behaviour in IntelliJ. When generating getters/setters for Example, the PHP functions argument type also gets the full namespace although they are not part of PHPDoc.
/**
* @param \Fully\Qualified\ClassName $complexType
*
* @return \Fully\Qualified\ClassName
*/
public function setExample(\Fully\Qualified\ClassName $complexType): \Fully\Qualified\ClassName
{
...
}
Deactivating the option gives the following which is expected but not helpful in my case
use Fully\Qualified\ClassName;
/**
* @param ClassName $complexType
*
* @return ClassName
*/
public function setExample(ClassName $complexType): ClassName
{
...
}
How to solve this to get it like the first example?
Best
Please sign in to leave a comment.
This can't be achieved automatically atm. That's because of https://youtrack.jetbrains.com/issue/WI-51342 & https://youtrack.jetbrains.com/issue/WI-46238. You can vote/comment the first report describing your problem to increase its priority & get notified about the updates.