Force type-hint and handle null value in ordering

This commit is contained in:
Julien Fastré 2023-07-28 00:25:32 +02:00
parent dd21694544
commit ae04172929
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -73,18 +73,16 @@ final class ResultRepository implements ObjectRepository
}
/**
* @param mixed|null $orderBy
* @param mixed|null $limit
* @param mixed|null $offset
*
* @return Result[]
* @return array<Result>
*/
public function findByGoal(Goal $goal, $orderBy = null, $limit = null, $offset = null): array
public function findByGoal(Goal $goal, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
{
$qb = $this->buildQueryByGoal($goal);
foreach ($orderBy as $sort => $order) {
$qb->addOrderBy('r.' . $sort, $order);
if (null !== $orderBy) {
foreach ($orderBy as $sort => $order) {
$qb->addOrderBy('r.' . $sort, $order);
}
}
return $qb