Code snippet that reproduces the problem
https://phpstan.org/r/169b87d5-eec8-4c75-abbc-94878970833f
Expected output
The count(MyRecord::find()) type is incorrectly narrowed to 1. It should be non-negative-int again
Impact
In upgrading to phpstan 2, this is hitting a lot of faulty impossibleType in our unit tests, where we have a similar pattern for (mock) records, and count assertions are common. Note it still happens when using $this->assertCount(1, Something::find()); (new Something)->insert(); $this->assertCount(2, Something::find()); in PHPUnit.
Did PHPStan help you today? Did it make you happy in any way?
It makes me want to code in weekends!
Code snippet that reproduces the problem
https://phpstan.org/r/169b87d5-eec8-4c75-abbc-94878970833f
Expected output
The
count(MyRecord::find())type is incorrectly narrowed to 1. It should benon-negative-intagainImpact
In upgrading to phpstan 2, this is hitting a lot of faulty
impossibleTypein our unit tests, where we have a similar pattern for (mock) records, and count assertions are common. Note it still happens when using$this->assertCount(1, Something::find()); (new Something)->insert(); $this->assertCount(2, Something::find());in PHPUnit.Did PHPStan help you today? Did it make you happy in any way?
It makes me want to code in weekends!