From 37d1a73e831f8cf8034bf9f56f319033e4034af8 Mon Sep 17 00:00:00 2001 From: Alex Wells Date: Sun, 26 Jun 2022 14:58:55 +0300 Subject: [PATCH] Support @template-contravariant tags --- src/Parser/PhpDocParser.php | 3 +++ tests/PHPStan/Parser/PhpDocParserTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) 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