1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add support for if replacement

This commit is contained in:
Brown 2019-11-14 11:03:16 -05:00
parent 8154a9ef16
commit a5c3304853

View File

@ -1053,6 +1053,28 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
if ($search_result[0] && $search_result[1]) {
return $search_result;
}
} elseif ($stmt instanceof PhpParser\Node\Stmt\If_) {
$search_result = $this->findAssignStmt($stmt->stmts, $var_id, $original_location);
if ($search_result[0] && $search_result[1]) {
return $search_result;
}
foreach ($stmt->elseifs as $elseif_stmt) {
$search_result = $this->findAssignStmt($elseif_stmt->stmts, $var_id, $original_location);
if ($search_result[0] && $search_result[1]) {
return $search_result;
}
}
if ($stmt->else) {
$search_result = $this->findAssignStmt($stmt->else->stmts, $var_id, $original_location);
if ($search_result[0] && $search_result[1]) {
return $search_result;
}
}
}
$i++;