-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#818Labels
Milestone
Description
Bug report
Code snippet that reproduces the problem
/**
* @param list<mixed> $arr
* @return list<mixed>|null
*/
function nullArray(array $arr): ?array {
$copy = [...$arr];
if (count($copy) === 0) {
return null;
}
return $copy;
}https://phpstan.org/r/83a4e3c7-d7b1-44c3-bf5d-7222a175ff1e
(The code doesn't make any sense. It's just there to prove there's a false positive.)
Expected output
No errors. If the input $arr is an empty list, the resulting $copy will be empty as well.
Actual output
Strict comparison using === between int<1, max> and 0 will always evaluate to false.