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 count() regression #3889

Merged
merged 3 commits into from
Mar 20, 2025
Merged

Fix count() regression #3889

merged 3 commits into from
Mar 20, 2025

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Mar 20, 2025

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.

Awesome, thanks!

if (
!$isNormalCount->yes()
|| (!$isConstantArray->yes() && !$isList->yes())
|| $type->isIterableAtLeastOnce()->no() // array{} cannot be used for further narrowing
|| !$positiveInt->isSuperTypeOf($sizeType)->yes()
Copy link
Member

Choose a reason for hiding this comment

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

What would change if we also included zero here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems to also work

@staabm staabm marked this pull request as ready for review March 20, 2025 10:46
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@herndlm
Copy link
Contributor

herndlm commented Mar 20, 2025

Nice, thx!

@ondrejmirtes ondrejmirtes merged commit c6e0450 into phpstan:2.1.x Mar 20, 2025
415 of 417 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the reg branch March 20, 2025 12:55
@ondrejmirtes
Copy link
Member

We have another one 🙁 https://phpstan.org/r/c97add7b-a241-45c9-88f1-b8e7c76daa09

@staabm staabm mentioned this pull request Mar 22, 2025
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.

4 participants