Skip to content

Erroneous Offset might not exist #12574

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

Open
momala454 opened this issue Feb 11, 2025 · 5 comments
Open

Erroneous Offset might not exist #12574

momala454 opened this issue Feb 11, 2025 · 5 comments
Labels
Milestone

Comments

@momala454
Copy link

momala454 commented Feb 11, 2025

Bug report

phpstan does not know the relation between a variable and another, in certain cases.
In the code snippet, the relation works in hello2 but not in hello

Code snippet that reproduces the problem

https://phpstan.org/r/ff3ed970-82b1-43cb-a427-3851372ded26

Another example where with a relation between $i and $param is not known https://phpstan.org/r/c6bf0d70-3b34-4653-bcb9-726053f24276

Expected output

No error

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

Yes as always

@momala454
Copy link
Author

Another example. not sure if I have to create another issue https://phpstan.org/r/c53254dd-ab2c-4323-9be1-184d28881049

@momala454
Copy link
Author

Another example. array_search return only existing keys https://phpstan.org/r/702a9f43-f9ad-4915-bba2-252cd8db1540

it looks like reportPossiblyNonexistentGeneralArrayOffset requires a lot of "hacks"

@staabm
Copy link
Contributor

staabm commented Feb 11, 2025

some of these cases will be fixed by phpstan/phpstan-src#3766

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 11, 2025
@momala454
Copy link
Author

@staabm your PR did not seem to have any impact on those

@staabm
Copy link
Contributor

staabm commented Mar 11, 2025

I had another look, but most examples you posted are pretty static analysis unfriendly.

atm I have no idea how these can be improved.

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

3 participants