Skip to content

Fix count() regression - #3889

Merged
ondrejmirtes merged 3 commits into
phpstan:2.1.xfrom
staabm:reg
Mar 20, 2025
Merged

ondrejmirtes merged 3 commits into
phpstan:2.1.xfrom
staabm:reg

Conversation

@staabm

@staabm staabm commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

@ondrejmirtes ondrejmirtes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, thanks!

Comment thread src/Analyser/TypeSpecifier.php Outdated
!$isNormalCount->yes()
|| (!$isConstantArray->yes() && !$isList->yes())
|| $type->isIterableAtLeastOnce()->no() // array{} cannot be used for further narrowing
|| !$positiveInt->isSuperTypeOf($sizeType)->yes()

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@herndlm

herndlm commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

Nice, thx!

@ondrejmirtes
ondrejmirtes merged commit c6e0450 into phpstan:2.1.x Mar 20, 2025
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you.

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

Copy link
Copy Markdown
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