Fix hasOffsetValueType for arrays#4277
Merged
ondrejmirtes merged 3 commits intophpstan:2.1.xfrom Sep 2, 2025
Merged
Conversation
VincentLanglet
commented
Sep 2, 2025
| ], | ||
| [ | ||
| '*ERROR*', | ||
| 'mixed', |
| 28, | ||
| ], | ||
| [ | ||
| 'Offset int|object might not exist on array|string.', |
Contributor
Author
There was a problem hiding this comment.
This error was added by #4272
It make sens to not have it since
- int is a valid offset and produce no error
- object is not a valid offset (and produce a php crash) and is already reported by the InvalidArrayOffsetRule.
| 12, | ||
| ], | ||
| [ | ||
| 'Offset object does not exist on array<string, int>.', |
Contributor
Author
There was a problem hiding this comment.
Same, already reported by InvalidArrayOffsetRule and this was added by #4272
c66a340 to
8ff0adb
Compare
Contributor
Author
|
The 7.4 failure already exists on 2.1.x https://github.com/phpstan/phpstan-src/actions/runs/17398668843/job/49386473327 |
Collaborator
|
This pull request has been marked as ready for review. |
ondrejmirtes
requested changes
Sep 2, 2025
| "ignorable": true | ||
| }, | ||
| { | ||
| "message": "Offset stdClass does not exist on array{baz: 21}|array{foo: 17, bar: 19}.", |
Member
There was a problem hiding this comment.
We're losing these useful errors. What are they replaced with?
Contributor
Author
There was a problem hiding this comment.
There is already (above)
Invalid array key type stdClass.
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I feel like we should only check for AllowedArrayKeysTypes since others types are checked by InvalidArrayKey rule.