Skip to content

Commit

Permalink
fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 18, 2024
1 parent 3b28c3e commit 3c7afad
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/PHPStan/NodeVisitor/ReIndexNodeAttributeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use PhpParser\Node;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\MatchArm;
use PhpParser\Node\Stmt\ClassMethod;
Expand All @@ -15,12 +20,17 @@
use PhpParser\Node\Stmt\Switch_;
use PhpParser\Node\Stmt\TryCatch;
use PhpParser\NodeVisitorAbstract;
use Webmozart\Assert\Assert;

final class ReIndexNodeAttributeVisitor extends NodeVisitorAbstract
{
public function enterNode(Node $node): ?Node
{
if ($node instanceof CallLike) {
/** @var FuncCall|MethodCall|New_|NullsafeMethodCall|StaticCall $node */
$node->args = array_values($node->args);
return $node;
}

if ($node instanceof FunctionLike) {
/** @var ClassMethod|Function_|Closure $node */
$node->params = array_values($node->params);
Expand All @@ -32,12 +42,6 @@ public function enterNode(Node $node): ?Node
return $node;
}

if ($node instanceof CallLike) {
Assert::propertyExists($node, 'args');
$node->args = array_values($node->args);
return $node;
}

if ($node instanceof If_) {
$node->elseifs = array_values($node->elseifs);
return null;
Expand Down

0 comments on commit 3c7afad

Please sign in to comment.