1

Hello I was just wondering about the hints syntax. PhpStorm automatically resolves parameters with:

@param ConfigFactoryInterface $config

But every ressources I find are using the full path:

@param \Drupal\Core\Config\ConfigFactoryInterface $config

How come?

Thanks you, Mathias

1

Preface: annotations are something different, what you're talking about are called DocBlocks.

PhpStorm automatically resolves parameters

Not in my experience; if you're using the namespace at the top of that file

use Drupal\Core\Config\ConfigFactoryInterface;

then yes, just like in the rest of your PHP code in the same file, you don't need to use the fully qualified namespace when referring to that class.

Without that use statement at the top of the file, PhpStorm won't be able to resolve the class (without the differentiator of namespace, how would it distinguish between two identically named classes?). At that point you'll probably see a squiggly line under the class in the docblock, informing you that it couldn't be found.

0

According to drupal coding standard, you should write class full path in your phpdoc.

In phpstorm : File >> settings >> Editor >> Code style >> PHP >> PHPDoc tab, check "use fully-qualified class names" :

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.