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
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixture;

final class SkipNormalArrayWithVariadic
{
private function foo(mixed ...$args): void {}

public function test(): void
{
$this->foo('first', ['key' => 'value'], c: 'test');
}
}
14 changes: 8 additions & 6 deletions src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Error;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
Expand Down Expand Up @@ -277,11 +276,6 @@ public function processNodes(
return;
}

if ($node instanceof Arg) {
$node->value->setAttribute(AttributeKey::SCOPE, $mutatingScope);
return;
}

if ($node instanceof Foreach_) {
// decorate value as well
$node->valueVar->setAttribute(AttributeKey::SCOPE, $mutatingScope);
Expand Down Expand Up @@ -492,6 +486,14 @@ private function processCallLike(CallLike $callLike, MutatingScope $mutatingScop
} elseif ($callLike instanceof New_ && ! $callLike->class instanceof Class_) {
$callLike->class->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}

if ($callLike->isFirstClassCallable()) {
return;
}

foreach ($callLike->getArgs() as $arg) {
$arg->value->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}
}

private function processAssign(Assign|AssignOp|AssignRef $assign, MutatingScope $mutatingScope): void
Expand Down
Loading