Skip to content

Commit 7f9dae6

Browse files
authored
[CodeQuality] More handling on Function/Static/Instantition callable node on OptionalParametersAfterRequiredRector (#6558)
* [CodeQuality] More handling on Function/Static/Instantition callable node on OptionalParametersAfterRequiredRector * [CodeQuality] More handling on Function/Static/Instantition callable node on OptionalParametersAfterRequiredRector * set * cs fix
1 parent cce5097 commit 7f9dae6

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\Fixture;
6+
7+
final class SkipFirstClassCallableInCallFunction
8+
{
9+
public function getSubscribedEvents()
10+
{
11+
return textElement(...)->execute(...);
12+
}
13+
14+
public function textElement()
15+
{
16+
}
17+
}

src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@
8787
use PHPStan\Analyser\MutatingScope;
8888
use PHPStan\Analyser\NodeScopeResolver;
8989
use PHPStan\Analyser\ScopeContext;
90+
use PHPStan\Node\FunctionCallableNode;
91+
use PHPStan\Node\InstantiationCallableNode;
9092
use PHPStan\Node\MethodCallableNode;
9193
use PHPStan\Node\Printer\Printer;
94+
use PHPStan\Node\StaticMethodCallableNode;
9295
use PHPStan\Node\UnreachableStatementNode;
9396
use PHPStan\Node\VirtualNode;
9497
use PHPStan\Parser\ParserErrorsException;
@@ -386,13 +389,12 @@ public function processNodes(
386389
return;
387390
}
388391

389-
if ($node instanceof MethodCallableNode) {
392+
if ($node instanceof MethodCallableNode || $node instanceof FunctionCallableNode || $node instanceof StaticMethodCallableNode || $node instanceof InstantiationCallableNode) {
390393
$node->getOriginalNode()
391394
->setAttribute(AttributeKey::SCOPE, $mutatingScope);
392-
$node->getOriginalNode()
393-
->var->setAttribute(AttributeKey::SCOPE, $mutatingScope);
394-
$node->getOriginalNode()
395-
->name->setAttribute(AttributeKey::SCOPE, $mutatingScope);
395+
$this->processCallike($node->getOriginalNode(), $mutatingScope);
396+
397+
return;
396398
}
397399
};
398400

0 commit comments

Comments
 (0)