Bug report
The following code is detected in the latest PHPStan as “Unreachable statement - code above always terminates.”
Maybe MutatingScope::resolveType() needs to recursively inspect the parent element.
Code snippet that reproduces the problem
<?php declare(strict_types = 1);
/**
* @param array{a?:array{b:bool}} $options
*/
function f(array $options): bool
{
if (isset($options['a']['b'])) {
return true;
}
return false;
}
var_dump(f([])); // returns false
https://phpstan.org/r/c877f393-c5d5-4b81-9655-709ba6b6a85b
Expected output
The last statement is reachable at run time, so no message should be printed.
https://3v4l.org/fjfml