Skip to content

Commit fb62e5e

Browse files
committed
Fix throwpoint in elseif condition
1 parent 2911f68 commit fb62e5e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ private function processStmtNode(
712712
$nodeCallback($elseif, $scope);
713713
$elseIfConditionType = $condScope->getType($elseif->cond)->toBoolean();
714714
$condResult = $this->processExprNode($elseif->cond, $condScope, $nodeCallback, ExpressionContext::createDeep());
715+
$throwPoints = array_merge($throwPoints, $condResult->getThrowPoints());
715716
$condScope = $condResult->getScope();
716717
$branchScopeStatementResult = $this->processStmtNodes($elseif, $elseif->stmts, $condResult->getTruthyScope(), $nodeCallback);
717718

tests/PHPStan/Rules/Exceptions/data/unthrown-exception.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,17 @@ public function doAmet2()
121121
}
122122
}
123123

124+
public function doConsecteur()
125+
{
126+
try {
127+
if (false) {
128+
129+
} elseif ($this->doAmet()) {
130+
131+
}
132+
} catch (\InvalidArgumentException $e) {
133+
134+
}
135+
}
136+
124137
}

0 commit comments

Comments
 (0)