Skip to content
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

Fix Array_ expr type resolving with unpacked array items #1586

Merged
merged 3 commits into from Aug 5, 2022

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Aug 3, 2022

Closes phpstan/phpstan#7724

The problem was the missing $optional arg for the ConstantArrayTypeBuilder::setOffsetValueType for the first conditional handling string keys. Unpacked array item values are always optional in that context as long as the array is not iterable at least once.

UPDATE: One more thing was looking weird to me which I fixed in the second commit. I removed the check of $valueType->getIterableValueType()->isIterableAtLeastOnce() which goes too far if I'm not mistaken. As the iterableValueType does not influence the outer array non-emptyness basically. See the affected test files for bug-5287

@herndlm herndlm marked this pull request as ready for review August 3, 2022 07:35
@herndlm herndlm marked this pull request as draft August 3, 2022 08:00
@herndlm herndlm marked this pull request as ready for review August 3, 2022 08:20
@ondrejmirtes ondrejmirtes merged commit cb46f97 into phpstan:1.8.x Aug 5, 2022
@ondrejmirtes
Copy link
Member

Thank you!

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