@@ -988,8 +988,26 @@ private function processStmtNode(
988988 throw new ShouldNotHappenException ();
989989 }
990990
991- $ classStatementsGatherer = new ClassStatementsGatherer ($ classReflection , $ nodeCallback );
992- $ this ->processAttributeGroups ($ stmt , $ stmt ->attrGroups , $ classScope , $ classStatementsGatherer );
991+ $ classStatementsGatherer = new ClassStatementsGatherer ($ classReflection );
992+ $ classStatementsGathererCallback = new class ($ classStatementsGatherer , $ nodeCallback ) {
993+
994+ /**
995+ * @param callable(Node $node, Scope $scope): void $nodeCallback
996+ */
997+ public function __construct (
998+ private ClassStatementsGatherer $ classStatementsGatherer ,
999+ private $ nodeCallback ,
1000+ )
1001+ {
1002+ }
1003+
1004+ public function __invoke (Node $ node , Scope $ scope ): void
1005+ {
1006+ ($ this ->classStatementsGatherer )($ node , $ scope , $ this ->nodeCallback );
1007+ }
1008+
1009+ };
1010+ $ this ->processAttributeGroups ($ stmt , $ stmt ->attrGroups , $ classScope , $ classStatementsGathererCallback );
9931011
9941012 $ classLikeStatements = $ stmt ->stmts ;
9951013 if ($ this ->narrowMethodScopeFromConstructor ) {
@@ -1010,7 +1028,7 @@ private function processStmtNode(
10101028 });
10111029 }
10121030
1013- $ this ->processStmtNodesInternal ($ stmt , $ classLikeStatements , $ classScope , $ classStatementsGatherer , $ context );
1031+ $ this ->processStmtNodesInternal ($ stmt , $ classLikeStatements , $ classScope , $ classStatementsGathererCallback , $ context );
10141032 $ nodeCallback (new ClassPropertiesNode ($ stmt , $ this ->readWritePropertiesExtensionProvider , $ classStatementsGatherer ->getProperties (), $ classStatementsGatherer ->getPropertyUsages (), $ classStatementsGatherer ->getMethodCalls (), $ classStatementsGatherer ->getReturnStatementsNodes (), $ classStatementsGatherer ->getPropertyAssigns (), $ classReflection ), $ classScope );
10151033 $ nodeCallback (new ClassMethodsNode ($ stmt , $ classStatementsGatherer ->getMethods (), $ classStatementsGatherer ->getMethodCalls (), $ classReflection ), $ classScope );
10161034 $ nodeCallback (new ClassConstantsNode ($ stmt , $ classStatementsGatherer ->getConstants (), $ classStatementsGatherer ->getConstantFetches (), $ classReflection ), $ classScope );
0 commit comments