diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index 23022323..ee7848c1 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -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; diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index 28b0a8e1..ccf71651 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -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