Skip to content

Commit

Permalink
Fix throwpoint in elseif condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 16, 2021
1 parent 2911f68 commit fb62e5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ private function processStmtNode(
$nodeCallback($elseif, $scope);
$elseIfConditionType = $condScope->getType($elseif->cond)->toBoolean();
$condResult = $this->processExprNode($elseif->cond, $condScope, $nodeCallback, ExpressionContext::createDeep());
$throwPoints = array_merge($throwPoints, $condResult->getThrowPoints());
$condScope = $condResult->getScope();
$branchScopeStatementResult = $this->processStmtNodes($elseif, $elseif->stmts, $condResult->getTruthyScope(), $nodeCallback);

Expand Down
13 changes: 13 additions & 0 deletions tests/PHPStan/Rules/Exceptions/data/unthrown-exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ public function doAmet2()
}
}

public function doConsecteur()
{
try {
if (false) {

} elseif ($this->doAmet()) {

}
} catch (\InvalidArgumentException $e) {

}
}

}

0 comments on commit fb62e5e

Please sign in to comment.