-
Notifications
You must be signed in to change notification settings - Fork 548
Ignore negative keys on checking whether a ConstantArray is a list #3870
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
Conversation
|
This pull request has been marked as ready for review. |
ondrejmirtes
left a comment
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.
A similar fix needs to be done in ArrayType::isList() - see https://phpstan.org/r/47372278-5264-4f01-a12c-dce00a50539f
|
Sorry, I'm wrong. |
|
Disregard my review there. |
ondrejmirtes
left a comment
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.
Please only check this review. Thanks.
|
Oh I requested review by mistake, sorry |
|
It's ready for review, thank you! |
|
Thank you. |
|
Probably not a problem with |
|
@zonuexe Array shapes are not currently sealed by default. The most upvoted feature request about it is here on GitHub. |
|
This problem is also related to sealed array, but that alone doesn't prevent input like |
|
I get it, it's complicated 😊 Maybe we could enforce the order of keys along with true sealed-ness of arrays. |
In
ConstantArrayTypeBuilder,setOffsetValueType()usesConstantIntegerTypeofoffsetTypefor checking whether aConstantArrayis a list, but doesn't check whether it is positive. Because of that, aConstantArraythat has negative integer keys is treated as list.This PR resolves phpstan/phpstan#12708.