Skip to content

Commit

Permalink
[CodeQuality] More handling on Function/Static/Instantition callable …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
samsonasik authored Dec 11, 2024
1 parent cce5097 commit 7f9dae6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\Fixture;

final class SkipFirstClassCallableInCallFunction
{
public function getSubscribedEvents()
{
return textElement(...)->execute(...);
}

public function textElement()
{
}
}
12 changes: 7 additions & 5 deletions src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
};

Expand Down

0 comments on commit 7f9dae6

Please sign in to comment.