diff --git a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php index fa53d580fe5..e4ac0190472 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToNewRector.php @@ -72,16 +72,16 @@ public function refactor(Node $node): ?Node return null; } + $class = $this->getName($node->class); + if ($class === null) { + return null; + } + foreach ($this->staticCallsToNewsByMethod[strtolower($methodName)] ?? [] as $staticCallToNew) { if (! $this->isName($node->class, $staticCallToNew->getClass())) { continue; } - $class = $this->getName($node->class); - if ($class === null) { - continue; - } - return new New_(new FullyQualified($class), $node->args); } diff --git a/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php b/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php index 0b463ada4e6..e71b8facb79 100644 --- a/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php +++ b/rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php @@ -95,6 +95,12 @@ public function refactor(Node $node): ?Node $dimFetchVariableNames = $this->resolveDimFetchVariableNames($closureExpr); + // the items type does not change per closure param, resolve it once + $type = $this->getType($closureItems); + if ($type instanceof ArrayType && $type->getItemType()->isObject()->yes()) { + continue; + } + foreach ($closureExpr->getParams() as $closureParam) { if ($closureParam->type instanceof Node) { // param is known already @@ -110,11 +116,6 @@ public function refactor(Node $node): ?Node continue; } - $type = $this->getType($closureItems); - if ($type instanceof ArrayType && $type->getItemType()->isObject()->yes()) { - continue; - } - $hasChanged = true; $closureParam->type = new Identifier('array'); }