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 setting offset to a List #3382

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

VincentLanglet
Copy link
Contributor

Extracted from #3381

assertType('true', array_is_list($array));

$array[$key] = false;
assertType('true', array_is_list($array));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prior to this PR, it was considered as false.

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.

Hey, I specifically asked for ConstantArrayTypeBuilderTest reproduction so please add that.

@VincentLanglet
Copy link
Contributor Author

Hey, I specifically asked for ConstantArrayTypeBuilderTest reproduction so please add that.

Sorry for the misunderstanding, it should be better now (?)

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.

Otherwise I couldn't find any problem with this edit 👍

$builder->setOffsetValueType(new ConstantIntegerType(2), new NullType());
$this->assertTrue($builder->isList());

$oneOrZero = TypeCombinator::union(
Copy link
Member

Choose a reason for hiding this comment

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

Please also write some counter-example test as well. Like when we're setting a union offset that does not exist yet, that will make the array be no longer a list. Thanks.

@ondrejmirtes ondrejmirtes merged commit 09749db into phpstan:1.12.x Sep 2, 2024
488 of 499 checks passed
@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
Development

Successfully merging this pull request may close these issues.

2 participants