If you use switch in catch block phpstan you get error that variable might not be defined.
<?php declare(strict_types = 1);
function test(): int
{
try {
$var = 1;
} catch (\Throwable $e) {
switch ($e->getCode()) {
case 1:
return 0;
default:
return -1;
}
}
return $var;
}