• 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).

reio Thank you for the test case.

Implemented and ready for the next update.

2 months later

I'm re-opening the issue because we need to revert this change in the upcoming update.

We can't track false value currently due to performance reasons; but we will re-implement it in the future.

    Write a Reply...