psalm
psalm copied to clipboard
Variable set inside catch is not propagated
https://psalm.dev/r/1368e04405
I found these snippets:
https://psalm.dev/r/1368e04405
<?php
$retry = false;
try {
try {
} catch (Throwable $e) {
$retry = true;
throw $e;
}
} finally {
/** @psalm-trace $retry */;
if (!$retry) {
}
}
Psalm output (using commit 028ac7f):
INFO: Trace - 10:28 - $retry: false
ERROR: RedundantCondition - 11:6 - Operand of type true is always truthy
ERROR: RedundantCondition - 11:7 - Type false for $retry is always falsy
INFO: UnusedVariable - 6:3 - $retry is never referenced or the value is not used