There is a return type contract violation in stable 2.5.x branch for `count()` method in `BasicEntityPersister` class: string returned instead of integer https://github.com/doctrine/doctrine2/blob/e1b851f2e93a4afd82fb7e7f32c6f114d0ea7b71/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php#L811-L824 causing incorrect behavior in case like: ```php /** @var $coll Doctrine\ORM\LazyCriteriaCollection */ if ($coll->count() === 0) { // unreachable code } ``` it seems to be fixed as a collateral change in `master` and needs to be backported somehow: https://github.com/doctrine/doctrine2/commit/a90035e81af2e9a424c0268a36101c3483e06571#diff-25f5292f65d5536bb733559f15e0d37fR825