-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Description
Feature Request
What
https://github.com/doctrine/orm/blob/3.5.x/src/EntityRepository.php#L138
EntityRepository#count() calls EntityPersister#count(), which defines itself as public function count(array|Criteria $criteria = []): int. This methos has two implementations, AbstractEntityPersister#count() and BasicEntityPersister#count(), both of which have the same method signature.
However, EntityRepository#count() is defined as public function count(array $criteria = []): int, completely discarding the Criteria option.
Please add Criteria to 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:
$newUsersThisMonth = $em->getRepository(User::class)->count(
Criteria::expr()->gte('createdAt', new DateTime('midnight first day of this month'))
);How
-public function count(array $criteria = []): int
+public function count(array|Criteria $criteria = []): intMetadata
Metadata
Assignees
Labels
No labels