This package is abandoned and no longer maintained. The author suggests using the jaspr/expression package instead.

Rich expression builder allows create complex closure expression tree to filter array of objects

2.0.0 2022-06-14 20:56 UTC

This package is auto-updated.

Last update: 2022-11-18 16:56:30 UTC


Is a tool for creating expression tree to filter collection of objects. The main task is to be able filter object in array by their properties. Additionally, I will add SQLResolver to create WHERE filter for your query.


$obj1        = new \stdClass();
$obj1->field = 1;
$obj2        = new \stdClass();
$obj2->field = 2;
$arr         = [$obj1, $obj2];
$expression  = Ex::and(
    Ex::eq(Ex::field('field'), Ex::literal(1)),
    Ex::gt(Ex::field('field'), Ex::literal(0))
$resolver    = new ClosureResolver();
$filter      = $resolver->dispatch($expression);
$result      = array_filter($arr, $filter);


array(1) {
  [0] =>
  class stdClass#410 (1) {
    public $field =>