- Edited
function test(): bool
{
$var = rand(0, 1) === 0 ? 'string' : false;
if ($var === false) {
throw new \Exception('Var is false.');
}
return $var;
}
$var is reported as being (local variable) bool|string $var
at the return stage. Ideally it should be reported as string $var
and yield Return value of test() is expected to be of type bool, string returned PHP(PHP0408)
.