@@ -175,6 +175,12 @@ public static function extractTemplates(PhpDocNode $node): array
175175 }
176176 }
177177
178+ foreach ($ node ->getTags () as $ tagNode ) {
179+ if ($ tagNode ->value instanceof TemplateTagValueNode && ! isset ($ templates [$ tagNode ->value ->name ])) {
180+ $ templates [$ tagNode ->value ->name ] = $ tagNode ->value ;
181+ }
182+ }
183+
178184 return $ templates ;
179185 }
180186
@@ -212,6 +218,19 @@ public static function extractTemplateVariances(PhpDocNode $node): array
212218 }
213219 }
214220
221+ foreach ($ node ->getTags () as $ tagNode ) {
222+ if ($ tagNode ->value instanceof TemplateTagValueNode && ! isset ($ variances [$ tagNode ->value ->name ])) {
223+ $ lowerTag = strtolower ($ tagNode ->name );
224+ if (str_contains ($ lowerTag , 'covariant ' )) {
225+ $ variances [$ tagNode ->value ->name ] = 'covariant ' ;
226+ } elseif (str_contains ($ lowerTag , 'contravariant ' )) {
227+ $ variances [$ tagNode ->value ->name ] = 'contravariant ' ;
228+ } else {
229+ $ variances [$ tagNode ->value ->name ] = 'invariant ' ;
230+ }
231+ }
232+ }
233+
215234 return $ variances ;
216235 }
217236
@@ -223,29 +242,14 @@ public static function extractTemplateVariances(PhpDocNode $node): array
223242 public static function getInheritedTags (PhpDocNode $ node ): array
224243 {
225244 $ tags = [];
226- $ tagNames = [
227- '@extends ' ,
228- '@template-extends ' ,
229- '@phpstan-extends ' ,
230- '@psalm-extends ' ,
231- '@implements ' ,
232- '@template-implements ' ,
233- '@phpstan-implements ' ,
234- '@psalm-implements ' ,
235- '@use ' ,
236- '@template-use ' ,
237- '@phpstan-use ' ,
238- ];
239245
240- foreach ($ tagNames as $ name ) {
241- foreach ($ node ->getTagsByName ($ name ) as $ tagNode ) {
242- if (
243- $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \ExtendsTagValueNode ||
244- $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \ImplementsTagValueNode ||
245- $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \UsesTagValueNode
246- ) {
247- $ tags [] = $ tagNode ->value ;
248- }
246+ foreach ($ node ->getTags () as $ tagNode ) {
247+ if (
248+ $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \ExtendsTagValueNode ||
249+ $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \ImplementsTagValueNode ||
250+ $ tagNode ->value instanceof \PHPStan \PhpDocParser \Ast \PhpDoc \UsesTagValueNode
251+ ) {
252+ $ tags [] = $ tagNode ->value ;
249253 }
250254 }
251255
@@ -424,4 +428,4 @@ public static function extractMagicMethodContract(string $doc, string $methodNam
424428
425429 return null ;
426430 }
427- }
431+ }
0 commit comments