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

Count after calling SplObjectStorage::removeAll #10884

Open
hultberg opened this issue Apr 16, 2024 · 0 comments
Open

Count after calling SplObjectStorage::removeAll #10884

hultberg opened this issue Apr 16, 2024 · 0 comments
Labels
Milestone

Comments

@hultberg
Copy link

Bug report

If you call count on a SplObjectStorage before calling SplObjectStorage::removeAll then on subsequent if (count() === 0) calls PHPStan report an error that this check will always be false. Calling removeAll might change the contents. Same problem with removeAllExcept calls.

Strict comparison using === between int<1, max> and 0 will always evaluate to false.

Code snippet that reproduces the problem

https://phpstan.org/r/69cf4869-d279-4876-977c-468f3f5d94a9

Expected output

No errors

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me alot and makes me happy. :-)

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants