I don't see anything in the coding standards that says that aliases in e.g. /** @var ContentEntityInterface */ are illegal. In this case, there would be a use \Drupal\Core\Entity\ContentEntityInterface; at the top.
However, Coder doesn't like this, and it triggers what I've tracked down to \Drupal_Sniffs_Classes_UnusedUseStatementSniff.
Unfortunately, this also contains fix instructions, and it will break my IDE's (PhpStorm's) type-hinting-based auto-completion if I actually auto-fix these. There are a lot of these warnings, so it's basically blocking me from completing code review on my module.
Comments
Comment #2
wizonesolutionsComment #3
lars toomre commentedThese inline docblocks type hinting for phpstorm also are causing a false positive sniff report of "Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead" in sniff Drupal.Commenting.InlineComment.DocBlock.
Comment #4
lars toomre commentedCreated related Coder issue #2624934: False sniff for Drupal.Classes.UnusedUseStatement.UnusedUse.
Comment #5
wizonesolutionsIt's possible that
@vardeclarations MUST use FQNs. If that is the case, then https://youtrack.jetbrains.com/issue/WI-26688 is the problem. I voted for that.In the interim, though, it would be better if Coder either implemented a separate sniff for this violation (if it's a violation), e.g. "Inline @var declaration should use fully-qualified name." It could also implement a fix for this by checking the defined aliases and figuring out which class was being referenced. Or just not auto-fix it such that I could run
phpbcfwithout concern that a bunch of myusestatements would be automatically removed.Comment #6
klausiDuplicate of #2587807: Drupal.Classes.UnusedUseStatement needs to scan comments.