@@ -88,27 +88,27 @@ public function getNodeTypes() : array
8888 */
8989 public function refactor (Node $ node )
9090 {
91- $ scope = ScopeFetcher::fetch ($ node );
9291 if ($ node instanceof ClassMethod || $ node instanceof Function_) {
93- return $ this ->refactorClassMethodOrFunction ($ node, $ scope );
92+ return $ this ->refactorClassMethodOrFunction ($ node );
9493 }
9594 if ($ node instanceof New_) {
96- return $ this ->refactorNew ($ node, $ scope );
95+ return $ this ->refactorNew ($ node );
9796 }
98- return $ this ->refactorMethodCallOrFuncCall ($ node, $ scope );
97+ return $ this ->refactorMethodCallOrFuncCall ($ node );
9998 }
10099 /**
101100 * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node
102101 * @return \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|null
103102 */
104- private function refactorClassMethodOrFunction ($ node, Scope $ scope )
103+ private function refactorClassMethodOrFunction ($ node )
105104 {
106105 if ($ node ->params === []) {
107106 return null ;
108107 }
109108 if ($ node ->getAttribute (self ::HAS_SWAPPED_PARAMS , \false) === \true) {
110109 return null ;
111110 }
111+ $ scope = ScopeFetcher::fetch ($ node );
112112 if ($ node instanceof ClassMethod) {
113113 $ reflection = $ this ->reflectionResolver ->resolveMethodReflectionFromClassMethod ($ node , $ scope );
114114 } else {
@@ -125,7 +125,7 @@ private function refactorClassMethodOrFunction($node, Scope $scope)
125125 $ node ->setAttribute (self ::HAS_SWAPPED_PARAMS , \true);
126126 return $ node ;
127127 }
128- private function refactorNew (New_ $ new, Scope $ scope ) : ?New_
128+ private function refactorNew (New_ $ new ) : ?New_
129129 {
130130 if ($ new ->args === []) {
131131 return null ;
@@ -137,6 +137,7 @@ private function refactorNew(New_ $new, Scope $scope) : ?New_
137137 if (!$ methodReflection instanceof MethodReflection) {
138138 return null ;
139139 }
140+ $ scope = ScopeFetcher::fetch ($ new );
140141 $ expectedArgOrParamOrder = $ this ->resolveExpectedArgParamOrderIfDifferent ($ methodReflection , $ new , $ scope );
141142 if ($ expectedArgOrParamOrder === null ) {
142143 return null ;
@@ -148,7 +149,7 @@ private function refactorNew(New_ $new, Scope $scope) : ?New_
148149 * @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $node
149150 * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall|null
150151 */
151- private function refactorMethodCallOrFuncCall ($ node, Scope $ scope )
152+ private function refactorMethodCallOrFuncCall ($ node )
152153 {
153154 if ($ node ->isFirstClassCallable ()) {
154155 return null ;
@@ -157,6 +158,7 @@ private function refactorMethodCallOrFuncCall($node, Scope $scope)
157158 if (!$ reflection instanceof MethodReflection && !$ reflection instanceof FunctionReflection) {
158159 return null ;
159160 }
161+ $ scope = ScopeFetcher::fetch ($ node );
160162 $ expectedArgOrParamOrder = $ this ->resolveExpectedArgParamOrderIfDifferent ($ reflection , $ node , $ scope );
161163 if ($ expectedArgOrParamOrder === null ) {
162164 return null ;
@@ -184,6 +186,7 @@ private function resolveExpectedArgParamOrderIfDifferent($reflection, $node, Sco
184186 if ($ reflection instanceof FunctionReflection && $ this ->vendorLocationDetector ->detectFunctionReflection ($ reflection )) {
185187 return null ;
186188 }
189+ $ scope = ScopeFetcher::fetch ($ node );
187190 $ parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select ($ reflection , $ node , $ scope );
188191 $ expectedParameterReflections = $ this ->requireOptionalParamResolver ->resolveFromParametersAcceptor ($ parametersAcceptor );
189192 if ($ expectedParameterReflections === $ parametersAcceptor ->getParameters ()) {
0 commit comments