Bug report
Only happens in lvl 9. The issue lies basically in this snippet:
if (isset($array['mightExist']) && !is_string($array['mightExist'])) {
throw new Exception('Has to be string if set');
}
PHPStan still assumes that $array['mightExist'] is mixed, even though it can only be unset or string after that point. Interestingly, it does not complain if the key is used without null coalesce, even though it can still be unset
Code snippet that reproduces the problem
https://phpstan.org/r/4d0bc609-96f0-4eec-a029-5926d67f9370
Expected output
No error reported
Bug report
Only happens in lvl 9. The issue lies basically in this snippet:
PHPStan still assumes that
$array['mightExist']ismixed, even though it can only be unset or string after that point. Interestingly, it does not complain if the key is used without null coalesce, even though it can still be unsetCode snippet that reproduces the problem
https://phpstan.org/r/4d0bc609-96f0-4eec-a029-5926d67f9370
Expected output
No error reported