Skip to content

Commit

Permalink
fix: doctrine/collections deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Apr 2, 2024
1 parent b0b4468 commit 5b39b54
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Operation/Matching.php
Expand Up @@ -7,6 +7,7 @@
use Closure;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
use Doctrine\Common\Collections\Order;
use Generator;
use loophp\collection\Contract\Operation\Sortable;

Expand Down Expand Up @@ -37,13 +38,13 @@ static function (Criteria $criteria): Closure {
$pipes[] = (new Filter())()($filterCallback);
}

$orderings = $criteria->getOrderings();
$orderings = $criteria->orderings();

if ([] !== $orderings) {
$next = null;

foreach (array_reverse($orderings) as $field => $ordering) {
$next = ClosureExpressionVisitor::sortByField($field, Criteria::DESC === $ordering ? -1 : 1, $next);
$next = ClosureExpressionVisitor::sortByField($field, Order::Descending === $ordering ? -1 : 1, $next);
}

$pipes[] = (new Sort())()(Sortable::BY_VALUES)($next);
Expand Down

0 comments on commit 5b39b54

Please sign in to comment.