-
-
Notifications
You must be signed in to change notification settings - Fork 934
Open
phpstan/phpstan-src
#4012Labels
Description
Bug report
Context
Today, I experienced quite a bad bug in a closed source project, where (pseudo-code) unset($someArray[array_search($key, $someArray)]) was used.
What is the problem?
Following code "runs" in PHP's wonky-ass runtime model, but makes no sense from a logical perspective:
<?php
/** @var array<int, int> $data */
unset($data[false]);It would be a good idea to get an error from this, rather than a silent execution from Psalm
Code snippet that reproduces the problem
https://phpstan.org/r/757a1ea2-b1b9-4ef7-a441-69e25f5142ba
Expected output
Would expect an output like:
5 Offset false does not exist on array<int, int>. offsetAccess.notFound
Did PHPStan help you today? Did it make you happy in any way?
PHPStan keeps being a lighthouse of quality in a sea of shite :D