@@ -891,14 +891,6 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
891891 }
892892 $ phpDocParameterTypes [$ paramName ] = $ paramTag ->getType ();
893893 }
894- foreach ($ phpDocParameterTypes as $ paramName => $ paramType ) {
895- $ phpDocParameterTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
896- $ paramType ,
897- $ phpDocBlockClassReflection ->getActiveTemplateTypeMap (),
898- $ phpDocBlockClassReflection ->getCallSiteVarianceMap (),
899- TemplateTypeVariance::createContravariant (),
900- );
901- }
902894 foreach ($ resolvedPhpDoc ->getParamOutTags () as $ paramName => $ paramOutTag ) {
903895 $ phpDocParameterOutTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
904896 $ paramOutTag ->getType (),
@@ -914,22 +906,6 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
914906 $ isInternal = $ resolvedPhpDoc ->isInternal ();
915907 $ isFinal = $ resolvedPhpDoc ->isFinal ();
916908 $ isPure ??= $ resolvedPhpDoc ->isPure ();
917- if ($ isPure === null ) {
918- $ classResolvedPhpDoc = $ phpDocBlockClassReflection ->getResolvedPhpDoc ();
919- if ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsPure ()) {
920- if (
921- strtolower ($ methodReflection ->getName ()) === '__construct '
922- || (
923- ($ phpDocReturnType === null || !$ phpDocReturnType ->isVoid ()->yes ())
924- && !$ nativeReturnType ->isVoid ()->yes ()
925- )
926- ) {
927- $ isPure = true ;
928- }
929- } elseif ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsImpure ()) {
930- $ isPure = false ;
931- }
932- }
933909 $ asserts = Assertions::createFromResolvedPhpDocBlock ($ resolvedPhpDoc );
934910 $ acceptsNamedArguments = $ resolvedPhpDoc ->acceptsNamedArguments ();
935911 $ selfOutType = $ resolvedPhpDoc ->getSelfOutTag () !== null ? $ resolvedPhpDoc ->getSelfOutTag ()->getType () : null ;
@@ -938,6 +914,32 @@ public function createUserlandMethodReflection(ClassReflection $fileDeclaringCla
938914 }
939915 }
940916
917+ if ($ isPure === null ) {
918+ $ classResolvedPhpDoc = $ phpDocBlockClassReflection ->getResolvedPhpDoc ();
919+ if ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsPure ()) {
920+ if (
921+ strtolower ($ methodReflection ->getName ()) === '__construct '
922+ || (
923+ ($ phpDocReturnType === null || !$ phpDocReturnType ->isVoid ()->yes ())
924+ && !$ nativeReturnType ->isVoid ()->yes ()
925+ )
926+ ) {
927+ $ isPure = true ;
928+ }
929+ } elseif ($ classResolvedPhpDoc !== null && $ classResolvedPhpDoc ->areAllMethodsImpure ()) {
930+ $ isPure = false ;
931+ }
932+ }
933+
934+ foreach ($ phpDocParameterTypes as $ paramName => $ paramType ) {
935+ $ phpDocParameterTypes [$ paramName ] = TemplateTypeHelper::resolveTemplateTypes (
936+ $ paramType ,
937+ $ phpDocBlockClassReflection ->getActiveTemplateTypeMap (),
938+ $ phpDocBlockClassReflection ->getCallSiteVarianceMap (),
939+ TemplateTypeVariance::createContravariant (),
940+ );
941+ }
942+
941943 return $ this ->methodReflectionFactory ->create (
942944 $ actualDeclaringClass ,
943945 $ declaringTrait ,
0 commit comments