mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
EntityRepository#count() should support Criteria as parameter #7573
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jurchiks on GitHub (Nov 8, 2025).
Feature Request
What
https://github.com/doctrine/orm/blob/3.5.x/src/EntityRepository.php#L138
EntityRepository#count()callsEntityPersister#count(), which defines itself aspublic function count(array|Criteria $criteria = []): int. This methos has two implementations,AbstractEntityPersister#count()andBasicEntityPersister#count(), both of which have the same method signature.However,
EntityRepository#count()is defined aspublic function count(array $criteria = []): int, completely discarding theCriteriaoption.Please add
Criteriato this parameter to make it match the interface and improve UX.Why
Because it makes sense.
Instead of having to write a custom EntityRepository method, users could write something like this:
How