22
33namespace  PHPStan \Reflection \Annotations ;
44
5+ use  PHPStan \PhpDoc \Tag \TemplateTag ;
56use  PHPStan \Reflection \ClassReflection ;
67use  PHPStan \Reflection \ExtendedMethodReflection ;
78use  PHPStan \Reflection \MethodReflection ;
89use  PHPStan \Reflection \MethodsClassReflectionExtension ;
10+ use  PHPStan \Type \Generic \TemplateTypeFactory ;
911use  PHPStan \Type \Generic \TemplateTypeHelper ;
12+ use  PHPStan \Type \Generic \TemplateTypeMap ;
13+ use  PHPStan \Type \Generic \TemplateTypeScope ;
1014use  PHPStan \Type \Generic \TemplateTypeVariance ;
15+ use  PHPStan \Type \Type ;
16+ 
1117use  function  count ;
1218
1319class  AnnotationsMethodsClassReflectionExtension implements  MethodsClassReflectionExtension
@@ -57,6 +63,13 @@ private function findClassReflectionWithMethod(
5763				);
5864			}
5965
66+ 			$ templateTypeScope  = TemplateTypeScope::createWithClass ($ classReflection ->getName ());
67+ 
68+ 			$ templateTypeMap  = new  TemplateTypeMap (array_map (
69+ 				static  fn  (TemplateTag   $ tag ): Type   => TemplateTypeFactory::fromTemplateTag ($ templateTypeScope , $ tag ),
70+ 				$ methodTags [$ methodName ]->getTemplates ()
71+ 			));
72+ 
6073			$ isStatic  = $ methodTags [$ methodName ]->isStatic ();
6174			$ nativeCallMethodName  = $ isStatic  ? '__callStatic '  : '__call ' ;
6275
@@ -75,6 +88,7 @@ private function findClassReflectionWithMethod(
7588				$ classReflection ->hasNativeMethod ($ nativeCallMethodName )
7689					? $ classReflection ->getNativeMethod ($ nativeCallMethodName )->getThrowType ()
7790					: null ,
91+ 				$ templateTypeMap ,
7892			);
7993		}
8094
0 commit comments