Skip to content

Commit

Permalink
Support @template-contravariant tags
Browse files Browse the repository at this point in the history
  • Loading branch information
autaut03 authored and ondrejmirtes committed Jun 26, 2022
1 parent 25ddf93 commit 135607f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Parser/PhpDocParser.php
Expand Up @@ -178,6 +178,9 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
case '@template-covariant':
case '@phpstan-template-covariant':
case '@psalm-template-covariant':
case '@template-contravariant':
case '@phpstan-template-contravariant':
case '@psalm-template-contravariant':
$tagValue = $this->parseTemplateTagValue($tokens);
break;

Expand Down
15 changes: 15 additions & 0 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Expand Up @@ -3323,6 +3323,21 @@ public function provideTemplateTagsData(): Iterator
),
]),
];

yield [
'OK with contravariance',
'/** @template-contravariant T */',
new PhpDocNode([
new PhpDocTagNode(
'@template-contravariant',
new TemplateTagValueNode(
'T',
null,
''
)
),
]),
];
}

public function provideExtendsTagsData(): Iterator
Expand Down

0 comments on commit 135607f

Please sign in to comment.