Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/Expr/ClosureExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public static function getObjectFieldValue(object|array $object, string $field):

/**
* Helper for sorting arrays of objects based on multiple fields + orientations.
*
* @return Closure(mixed, mixed): int
*/
public static function sortByField(string $name, int $orientation = 1, Closure|null $next = null): Closure
{
Expand Down Expand Up @@ -171,7 +173,11 @@ public function walkCompositeExpression(CompositeExpression $expr): Closure
};
}

/** @param callable[] $expressions */
/**
* @param array<callable(object): bool> $expressions
*
* @return Closure(object): bool
*/
private function andExpressions(array $expressions): Closure
{
return static fn (object $object): bool => array_all(
Expand All @@ -180,7 +186,11 @@ private function andExpressions(array $expressions): Closure
);
}

/** @param callable[] $expressions */
/**
* @param array<callable(object): bool> $expressions
*
* @return Closure(object): bool
*/
private function orExpressions(array $expressions): Closure
{
return static fn (object $object): bool => array_any(
Expand All @@ -189,7 +199,11 @@ private function orExpressions(array $expressions): Closure
);
}

/** @param callable[] $expressions */
/**
* @param array<callable(object): bool> $expressions
*
* @return Closure(object): bool
*/
private function notExpression(array $expressions): Closure
{
return static fn (object $object) => ! $expressions[0]($object);
Expand Down