diff --git a/rules/CodeQuality/Rector/Attribute/ExplicitAttributeNamedArgsRector.php b/rules/CodeQuality/Rector/Attribute/ExplicitAttributeNamedArgsRector.php index f3e5e4201d5..c0f95436769 100644 --- a/rules/CodeQuality/Rector/Attribute/ExplicitAttributeNamedArgsRector.php +++ b/rules/CodeQuality/Rector/Attribute/ExplicitAttributeNamedArgsRector.php @@ -65,6 +65,11 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + // no arguments to name + if ($node->args === []) { + return null; + } + $methodReflection = $this->reflectionResolver->resolveConstructorReflectionFromAttribute($node); if (! $methodReflection instanceof MethodReflection) { return null; diff --git a/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php b/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php index 15e77d6c1d3..f5a31d3634b 100644 --- a/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php +++ b/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php @@ -102,31 +102,31 @@ public function refactor(Node $node): StaticCall|MethodCall|null return null; } - $scope = ScopeFetcher::fetch($node); - - $arrayCallable = $this->arrayCallableMethodMatcher->match($node, $scope); - if (! $arrayCallable instanceof ArrayCallable) { + if ($node->getAttribute(AttributeKey::IS_CLASS_CONST_VALUE)) { return null; } - $callerExpr = $arrayCallable->getCallerExpr(); - if (! $callerExpr instanceof Variable && ! $callerExpr instanceof PropertyFetch && ! $callerExpr instanceof ClassConstFetch) { + if ($node->getAttribute(AttributeKey::IS_DEFAULT_PROPERTY_VALUE)) { return null; } - if ($node->getAttribute(AttributeKey::IS_CLASS_CONST_VALUE)) { + if ($node->getAttribute(AttributeKey::IS_PARAM_DEFAULT)) { return null; } - if ($node->getAttribute(AttributeKey::IS_DEFAULT_PROPERTY_VALUE)) { + if ($node->getAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE)) { return null; } - if ($node->getAttribute(AttributeKey::IS_PARAM_DEFAULT)) { + $scope = ScopeFetcher::fetch($node); + + $arrayCallable = $this->arrayCallableMethodMatcher->match($node, $scope); + if (! $arrayCallable instanceof ArrayCallable) { return null; } - if ($node->getAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE)) { + $callerExpr = $arrayCallable->getCallerExpr(); + if (! $callerExpr instanceof Variable && ! $callerExpr instanceof PropertyFetch && ! $callerExpr instanceof ClassConstFetch) { return null; }