-
-
Notifications
You must be signed in to change notification settings - Fork 934
Open
phpstan/phpstan-src
#4149Labels
Description
Bug report
array_filter
can create array with gaps so getting the first element using $arr[0]
might not work. But guarding the array access by count($array) === 1
will make PHPStan happy:
https://phpstan.org/r/d924c125-9c42-41a3-a90d-04381950227b
Actually, array_filter
is not even necessary:
Code snippet that reproduces the problem
https://phpstan.org/r/1e55cca6-5846-4d63-8c25-7539e069aba4
Expected output
PHPStan should print the following error (like if count
is removed):
Offset 0 might not exist on array{0?: string, 1?: int}.
Did PHPStan help you today? Did it make you happy in any way?
Hoping PHPStan could eventually detect j0k3r/php-readability#96, though we are not up to level four yet.