-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Phpstan ignores possibly undefined array offsets #7553
Comments
There's some extra code that makes sure this IS NOT reported: https://github.com/phpstan/phpstan-src/blob/4bfe42193d092be3bf004b03575ebeedbd957da6/src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php#L49-L60 Even in Psalm it's an extra couple of options off by default: https://psalm.dev/docs/running_psalm/configuration/#ensurearraystringoffsetsexist I'd accept a patch that adds an extra option for this behaviour. |
There are also more Info's about this at #7450 (reply in thread) |
@ondrejmirtes may I ask why you chose not to report this? |
@desmax It'd report too many annoying things in existing codebases, like thousands of errors that aren't actually bugs... |
Well, most of things reported by static analysis tools are not actual bugs, but "just" potential bugs. |
It was mentioned that a PR that adds opt-in for this would be accepted. Shouldn't that be enough? |
Hi, how soon can we expect the release of this feature? |
When someone implements it 😊 |
Thanks to phpstan/phpstan-src#3028 in PHPStan 1.11 there will be two new options: parameters:
reportPossiblyNonexistentGeneralArrayOffset: true
reportPossiblyNonexistentConstantArrayOffset: true |
Docs update 074f438 |
thank you very much! |
Bug report
The following code should raise an error, but it passes with level 9 + strict rules.
Code snippet that reproduces the problem
https://phpstan.org/r/5347b67e-f0ad-4505-aeca-cfb074dcb3e7
Expected output
It should raise an error about possibly undefined array offset, same way as psalm does. Quite obvious.
https://psalm.dev/r/e3d927af68
The text was updated successfully, but these errors were encountered: