Bug report
In PHPStan 2.0.2 (and also 1.x.x) i encountered the following:
PHPStan is incorrectly reporting a false-positive error for array offset access. Specifically, it claims that offsets 1|2|3|4|5 might not exist in $counterArray, even though the code explicitly initializes them with an isset check.
Output:
Offset 1|2|3|4|5 might not exist on array<1|2|3|4|5, array{string_index_1: int<0, max>, string_index_2: int<0, max>}>. 🪪 offsetAccess.notFound
Weird thing: The playground does not detect the problem, but my actual environment does.
(Or maybe i'm doing something wrong?)
Code snippet that reproduces the problem
https://phpstan.org/r/cc479aa3-3c2e-4be9-b264-9f62a25e06bd
Expected output
I expect no problem detected.
Did PHPStan help you today? Did it make you happy in any way?
Yes! Love it <3