Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@ondrejmirtes
Copy link
Member

I feel like the error could always be reported on level 7+.

The difference is that the reportPossiblyUndefined... option is for offsets like string, but in this case this is about a union and one of the union parts never exists on the constant array so it'd be a good fit for L7+ without any extra option.

@VincentLanglet VincentLanglet changed the title Add non regression test Detect more possibly-impossible offset Jul 26, 2025
@VincentLanglet VincentLanglet marked this pull request as draft July 26, 2025 15:47
@VincentLanglet VincentLanglet force-pushed the test/1061 branch 10 times, most recently from c290ea1 to 2417411 Compare August 1, 2025 11:28
@VincentLanglet VincentLanglet marked this pull request as ready for review August 1, 2025 11:43
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not so sure about this, the impact seems high...

{
"message": "Possibly invalid array key type int|object.",
"line": 35,
"ignorable": true
},
{
"message": "Offset int|object might not exist on array{baz: 21}|array{foo: 17, bar: 19}.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong for array{foo: 17, bar: 19}|array{baz: 21}. int|object never exists on these arrays.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I think this is because of #4272 which need to be fix/merged first then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to detect possibly-impossible constant offset
3 participants