-
Notifications
You must be signed in to change notification settings - Fork 457
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
Make array access on possible false tolerant with isset #1791
Conversation
5b21e40
to
6fd272b
Compare
Make array access tolerant with isset Fixes bug phpstan/phpstan#8068
6fd272b
to
29de899
Compare
Thank you! |
[ | ||
'Cannot access offset \'a\' on array{a: 1, b: 1}|(Closure(): void).', | ||
258, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling closure or object (without ArrayAccess) causes a fatal error, so this case shouldn't be ignored.
https://3v4l.org/lFcCq
I think it might be better to have another condition to the type, whether isOffestAccessible->no throws an fatal error or not.
This might lead to improvements in issues like phpstan/phpstan#8388
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to open a new issue about this, comments on old merged PRs will get lost :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Done phpstan/phpstan#8393
Closes phpstan/phpstan#8068.
Hey Ondrej,
As discussed in the bug. PHP is tolerant with
isset
.The removed line
Cannot access offset \'a\' on array{a: 1, b: 1}|(Closure(): void).
from the other test is reasonable because closure key access in isset would always be reported.appreciate your help on getting the fix for this one.