Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading