-
Notifications
You must be signed in to change notification settings - Fork 520
Detect more possibly-impossible offset #4164
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
I feel like the error could always be reported on level 7+. The difference is that the |
35af5a4
to
f4b6dbd
Compare
c290ea1
to
2417411
Compare
This pull request has been marked as ready for review. |
2417411
to
0a8a1e2
Compare
@@ -127,6 +131,10 @@ public function testRule(): void | |||
'Offset int does not exist on array<string, string>.', | |||
312, | |||
], | |||
[ | |||
'Offset int|null might not exist on array<string, string>.', |
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.
Well this is totally wrong, null
gets cast to ''
in an array key and that can exist on array<string, string>.
. Not sure where to do the fix.
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.
You misunderstood the error message.
You can see that phpstan already report on line 312 (the error above)
'Offset int does not exist on array<string, string>.',
So here we're reporting the same message with "might not exist" certainty because
- int does not exists
- null can exist
Closes phpstan/phpstan#1061