File tree Expand file tree Collapse file tree
Transform/Rector/StaticCall
TypeDeclaration/Rector/FuncCall Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,16 +72,16 @@ public function refactor(Node $node): ?Node
7272 return null ;
7373 }
7474
75+ $ class = $ this ->getName ($ node ->class );
76+ if ($ class === null ) {
77+ return null ;
78+ }
79+
7580 foreach ($ this ->staticCallsToNewsByMethod [strtolower ($ methodName )] ?? [] as $ staticCallToNew ) {
7681 if (! $ this ->isName ($ node ->class , $ staticCallToNew ->getClass ())) {
7782 continue ;
7883 }
7984
80- $ class = $ this ->getName ($ node ->class );
81- if ($ class === null ) {
82- continue ;
83- }
84-
8585 return new New_ (new FullyQualified ($ class ), $ node ->args );
8686 }
8787
Original file line number Diff line number Diff line change @@ -95,6 +95,12 @@ public function refactor(Node $node): ?Node
9595
9696 $ dimFetchVariableNames = $ this ->resolveDimFetchVariableNames ($ closureExpr );
9797
98+ // the items type does not change per closure param, resolve it once
99+ $ type = $ this ->getType ($ closureItems );
100+ if ($ type instanceof ArrayType && $ type ->getItemType ()->isObject ()->yes ()) {
101+ continue ;
102+ }
103+
98104 foreach ($ closureExpr ->getParams () as $ closureParam ) {
99105 if ($ closureParam ->type instanceof Node) {
100106 // param is known already
@@ -110,11 +116,6 @@ public function refactor(Node $node): ?Node
110116 continue ;
111117 }
112118
113- $ type = $ this ->getType ($ closureItems );
114- if ($ type instanceof ArrayType && $ type ->getItemType ()->isObject ()->yes ()) {
115- continue ;
116- }
117-
118119 $ hasChanged = true ;
119120 $ closureParam ->type = new Identifier ('array ' );
120121 }
You can’t perform that action at this time.
0 commit comments