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

TypeCombinator: Don't combine array-shapes of lists with non-lists #3201

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 1, 2024

idea is to not combine lists with non-lists array-shapes. keeping them separate yields a more precise union which later on can lead to better analysis results

motivated by the issue described in phpstan/phpstan#11256 (reply in thread)

@staabm
Copy link
Contributor Author

staabm commented Jul 1, 2024

I think this change makes sense as is in isolation.

maybe it does not yet address all the problems I need to solve for the case at hand and needs another fix after I can combine it with the open preg_match efforts.

@staabm staabm marked this pull request as ready for review July 1, 2024 10:41
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm staabm marked this pull request as draft July 1, 2024 10:43
@@ -1532,6 +1532,10 @@ public function isKeysSupersetOf(self $otherArray): bool
return $keyTypesCount === 0;
}

if (!$this->isList->equals($otherArray->isList)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have this line of code say:

if ($this->isList->yes() !== $otherArray->isList->yes()) {

But I can't explain why, feel better to me. I'm going to let you come up with test cases that will have different results because of this change :)

@staabm staabm closed this Jul 1, 2024
@staabm staabm deleted the no-combine-list-non-list branch July 1, 2024 15:06
@staabm
Copy link
Contributor Author

staabm commented Jul 1, 2024

The initial motivation of this PR was fixed differently

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.

3 participants