@@ -893,14 +893,6 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
893893 }
894894 $ phpDocParameterTypes [$ paramName ] = $ paramTag ->getType ();
895895 }
896- foreach ($ phpDocParameterTypes as $ paramName => $ paramType ) {
897- $ phpDocParameterTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
898- $ paramType ,
899- $ phpDocBlockClassReflection ->getActiveTemplateTypeMap (),
900- $ phpDocBlockClassReflection ->getCallSiteVarianceMap (),
901- TemplateTypeVariance::createContravariant (),
902- );
903- }
904896 foreach ($ resolvedPhpDoc ->getParamOutTags () as $ paramName => $ paramOutTag ) {
905897 $ phpDocParameterOutTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
906898 $ paramOutTag ->getType (),
@@ -916,22 +908,6 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
916908 $ isInternal = $ resolvedPhpDoc ->isInternal ();
917909 $ isFinal = $ resolvedPhpDoc ->isFinal ();
918910 $ isPure ??= $ resolvedPhpDoc ->isPure ();
919- if ($ isPure === null ) {
920- $ classResolvedPhpDoc = $ phpDocBlockClassReflection ->getResolvedPhpDoc ();
921- if ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsPure ()) {
922- if (
923- strtolower ($ methodReflection ->getName ()) === '__construct '
924- || (
925- ($ phpDocReturnType === null || !$ phpDocReturnType ->isVoid ()->yes ())
926- && !$ nativeReturnType ->isVoid ()->yes ()
927- )
928- ) {
929- $ isPure = true ;
930- }
931- } elseif ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsImpure ()) {
932- $ isPure = false ;
933- }
934- }
935911 $ asserts = Assertions::createFromResolvedPhpDocBlock ($ resolvedPhpDoc );
936912 $ acceptsNamedArguments = $ resolvedPhpDoc ->acceptsNamedArguments ();
937913 $ selfOutType = $ resolvedPhpDoc ->getSelfOutTag () !== null ? $ resolvedPhpDoc ->getSelfOutTag ()->getType () : null ;
@@ -940,6 +916,32 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
940916 }
941917 }
942918
919+ if ($ isPure === null ) {
920+ $ classResolvedPhpDoc = $ phpDocBlockClassReflection ->getResolvedPhpDoc ();
921+ if ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsPure ()) {
922+ if (
923+ strtolower ($ methodReflection ->getName ()) === '__construct '
924+ || (
925+ ($ phpDocReturnType === null || !$ phpDocReturnType ->isVoid ()->yes ())
926+ && !$ nativeReturnType ->isVoid ()->yes ()
927+ )
928+ ) {
929+ $ isPure = true ;
930+ }
931+ } elseif ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsImpure ()) {
932+ $ isPure = false ;
933+ }
934+ }
935+
936+ foreach ($ phpDocParameterTypes as $ paramName => $ paramType ) {
937+ $ phpDocParameterTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
938+ $ paramType ,
939+ $ phpDocBlockClassReflection ->getActiveTemplateTypeMap (),
940+ $ phpDocBlockClassReflection ->getCallSiteVarianceMap (),
941+ TemplateTypeVariance::createContravariant (),
942+ );
943+ }
944+
943945 return $ this ->methodReflectionFactory ->create (
944946 $ actualDeclaringClass ,
945947 $ declaringTrait ,
0 commit comments