-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Bug report
With a setup like this:
/**
* @param array{'foo': string, 'bar'?: string} $array
*/
private function myfunction(array $array): int
{
$string = $array['bar'] ?? $array['foo'];
return strlen($string);
}I'm getting:
Parameter #1 $string of function strlen expects string, mixed given.
But from my understanding, $string will always be a string, cause both array keys (foo and bar) are string (if present at all).
This only happens when checkImplicitMixed is enabled; therefore I can't reproduce it in the playground.
Code snippet that reproduces the problem
No response
Expected output
No error message.
Did PHPStan help you today? Did it make you happy in any way?
Sure! :-)
Reactions are currently unavailable