diff --git a/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php b/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php index f5f823e8ff2..5d09f00f313 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayMapRector.php @@ -72,15 +72,15 @@ public function refactor(Node $node): ?Node return null; } - $funcReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); + $args = $node->getArgs(); - if (! $funcReflection instanceof NativeFunctionReflection) { + if (! isset($args[0]) || ! $args[0]->value instanceof Closure) { return null; } - $args = $node->getArgs(); + $funcReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); - if (! isset($args[0]) || ! $args[0]->value instanceof Closure) { + if (! $funcReflection instanceof NativeFunctionReflection) { return null; } diff --git a/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php b/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php index 24971671843..19c0129afe0 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php @@ -76,15 +76,15 @@ public function refactor(Node $node): ?Node return null; } - $funcReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); + $args = $node->getArgs(); - if (! $funcReflection instanceof NativeFunctionReflection) { + if (! isset($args[1]) || ! $args[1]->value instanceof Closure) { return null; } - $args = $node->getArgs(); + $funcReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); - if (! isset($args[1]) || ! $args[1]->value instanceof Closure) { + if (! $funcReflection instanceof NativeFunctionReflection) { return null; }