Skip to content

Remove count() narrowing handling of empty array#3896

Merged
ondrejmirtes merged 1 commit into
phpstan:2.1.xfrom
herndlm:count-empty-array-handling
Mar 22, 2025
Merged

Remove count() narrowing handling of empty array#3896
ondrejmirtes merged 1 commit into
phpstan:2.1.xfrom
herndlm:count-empty-array-handling

Conversation

@herndlm
Copy link
Copy Markdown
Contributor

@herndlm herndlm commented Mar 22, 2025

Is already covered by the adaption of #3895

@herndlm herndlm mentioned this pull request Mar 22, 2025
@herndlm
Copy link
Copy Markdown
Contributor Author

herndlm commented Mar 22, 2025

I realized late that this is slightly different though. the fix from @staabm is checking sizeType, while this was checking type. let's see what CI says, if in doubt, maybe it's better to keep? hmm

on the other hand I do prefer a simpler if here though if possible :)

@herndlm
Copy link
Copy Markdown
Contributor Author

herndlm commented Mar 22, 2025

I'll do a quick check for what I added this initially, can't remember

@herndlm
Copy link
Copy Markdown
Contributor Author

herndlm commented Mar 22, 2025

no clue, it doesn't influence anything. independent of @staabm's sizeType check. even if I remove the whole sizeType check line no new tests start failing. while developing things initially, at some point, I'm sure the isIterableAtLeastOnce()->no() was needed to fix failing tests. but most likely I refactored then and it became irrelevant.

if nobody else has another opinion, then I think it's fine to remove it

@staabm
Copy link
Copy Markdown
Contributor

staabm commented Mar 22, 2025

agree we should not have code which does not fail tests when removed (except perf improvements)

@ondrejmirtes ondrejmirtes merged commit 40d7179 into phpstan:2.1.x Mar 22, 2025
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

@herndlm herndlm deleted the count-empty-array-handling branch March 22, 2025 12:59
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