Skip to content

Commit

Permalink
Fix handling of throw statements when nikic/php-parser ^4.18 is used
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 21, 2023
1 parent 9bdd4a6 commit 0282217
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/StaticAnalysis/ExecutableLinesFindingVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ public function enterNode(Node $node): void
return;
}

/**
* nikic/php-parser ^4.18 represents <code>throw</code> statements
* as <code>Stmt\Throw_</code> objects
*/
if ($node instanceof Node\Stmt\Throw_) {
$this->setLineBranch($node->expr->getEndLine(), $node->expr->getEndLine(), ++$this->nextBranch);

return;
}

/**
* nikic/php-parser ^5 represents <code>throw</code> statements
* as <code>Stmt\Expression</code> objects that contain an
* <code>Expr\Throw_</code> object
*/
if ($node instanceof Node\Stmt\Expression && $node->expr instanceof Node\Expr\Throw_) {
$this->setLineBranch($node->expr->expr->getEndLine(), $node->expr->expr->getEndLine(), ++$this->nextBranch);

Expand Down

0 comments on commit 0282217

Please sign in to comment.