Skip to content

Commit

Permalink
Reserve @use for generic traits instead of @uses (which already has m…
Browse files Browse the repository at this point in the history
…eaning in PHP projects)
  • Loading branch information
ondrejmirtes committed Dec 5, 2019
1 parent 51a9bf6 commit 0331e88
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Ast/PhpDoc/PhpDocNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getImplementsTagValues(string $tagName = '@implements'): array
/**
* @return UsesTagValueNode[]
*/
public function getUsesTagValues(string $tagName = '@uses'): array
public function getUsesTagValues(string $tagName = '@use'): array
{
return array_column(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
Expand Down
8 changes: 4 additions & 4 deletions src/Parser/PhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
$tagValue = $this->parseExtendsTagValue('@implements', $tokens);
break;

case '@uses':
case '@phpstan-uses':
case '@use':
case '@phpstan-use':
case '@template-use':
$tagValue = $this->parseExtendsTagValue('@uses', $tokens);
$tagValue = $this->parseExtendsTagValue('@use', $tokens);
break;

default:
Expand Down Expand Up @@ -346,7 +346,7 @@ private function parseExtendsTagValue(string $tagName, TokenIterator $tokens): A
return new Ast\PhpDoc\ExtendsTagValueNode($type, $description);
case '@implements':
return new Ast\PhpDoc\ImplementsTagValueNode($type, $description);
case '@uses':
case '@use':
return new Ast\PhpDoc\UsesTagValueNode($type, $description);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2480,11 +2480,11 @@ public function provideExtendsTagsData(): \Iterator
];

yield [
'OK @uses',
'/** @uses Foo<A,B> */',
'OK @use',
'/** @use Foo<A,B> */',
new PhpDocNode([
new PhpDocTagNode(
'@uses',
'@use',
new UsesTagValueNode(
new GenericTypeNode(
new IdentifierTypeNode('Foo'),
Expand Down

0 comments on commit 0331e88

Please sign in to comment.