From 7f9dae6ddcce4331acb1058a47d9947ee1b87c17 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 12 Dec 2024 01:51:18 +0700 Subject: [PATCH] [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 --- ...irst_class_callable_in_call_function.php.inc | 17 +++++++++++++++++ .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 12 +++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 rules-tests/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_first_class_callable_in_call_function.php.inc diff --git a/rules-tests/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_first_class_callable_in_call_function.php.inc b/rules-tests/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_first_class_callable_in_call_function.php.inc new file mode 100644 index 0000000000..134b84cec1 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Fixture/skip_first_class_callable_in_call_function.php.inc @@ -0,0 +1,17 @@ +execute(...); + } + + public function textElement() + { + } +} diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 031e64708f..7eacc4b9dd 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -87,8 +87,11 @@ use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\NodeScopeResolver; use PHPStan\Analyser\ScopeContext; +use PHPStan\Node\FunctionCallableNode; +use PHPStan\Node\InstantiationCallableNode; use PHPStan\Node\MethodCallableNode; use PHPStan\Node\Printer\Printer; +use PHPStan\Node\StaticMethodCallableNode; use PHPStan\Node\UnreachableStatementNode; use PHPStan\Node\VirtualNode; use PHPStan\Parser\ParserErrorsException; @@ -386,13 +389,12 @@ public function processNodes( return; } - if ($node instanceof MethodCallableNode) { + if ($node instanceof MethodCallableNode || $node instanceof FunctionCallableNode || $node instanceof StaticMethodCallableNode || $node instanceof InstantiationCallableNode) { $node->getOriginalNode() ->setAttribute(AttributeKey::SCOPE, $mutatingScope); - $node->getOriginalNode() - ->var->setAttribute(AttributeKey::SCOPE, $mutatingScope); - $node->getOriginalNode() - ->name->setAttribute(AttributeKey::SCOPE, $mutatingScope); + $this->processCallike($node->getOriginalNode(), $mutatingScope); + + return; } };