Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reportPossiblyNonexistentGeneralArrayOffset false positive #11020

Open
RdeV-Visy opened this issue May 14, 2024 · 0 comments
Open

reportPossiblyNonexistentGeneralArrayOffset false positive #11020

RdeV-Visy opened this issue May 14, 2024 · 0 comments
Labels
Milestone

Comments

@RdeV-Visy
Copy link

Bug report

reportPossiblyNonexistentGeneralArrayOffset fails after using php function to get the last key in a non empty array.

Offset (int|string) might not exist on non-empty-array<string>.                       
offsetAccess.notFound  

Code snippet that reproduces the problem

https://phpstan.org/r/b29ae8a5-c605-4130-9417-8e46c2d64312

Expected output

I would not expect reportPossiblyNonexistentGeneralArrayOffset to fail on the example provided but it does. Same for a count -1 type setup.

(the playgroud doesn't fail but I can't seem to turn on reportPossiblyNonexistentGeneralArrayOffset)

Did PHPStan help you today? Did it make you happy in any way?

PHPStan makes me happy every workday and has saved me an approximate infinity reviewing things static analysis could have told me. Thanks!

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants