Combine many maps to a single tree one

@param string $op        A boolean operator
@param callable $map1, ...
@return callable
198402
public function combine($op, $map1/**, $transf2,... */)
    {
        $transformations = func_get_args();
        array_shift($transformations);

        return function(Expression $expr, $compiler) use ($op, $transformations)
        {
            $tree = new SpanExpression(strtoupper($op));

            foreach ($transformations as $transformation) {
                $tree->addExpression($transformation($expr, $compiler));
            }

            return $tree;
        };
    }
635311
static function fuse(&$opt1, $opt2) {
        return isset($opt1) ? $opt1 : (isset($opt2) ? $opt2 : null); 
    }
1005296
public function createMapper()
    {
        if ($this->mapperElement !== null) {
            throw new BuildException(
                "Cannot define more than one mapper",
                $this->getLocation()
            );
        }
        $this->mapperElement = new Mapper($this->getProject());

        return $this->mapperElement;
    }
155389
private function mapOperator($operator)
    {
        if (array_key_exists($operator, $this->shortOperators)) {
            $operator = $this->shortOperators[$operator];
        }

        if (!in_array($operator, $this->allowedOperators)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid operator `%s` given. Valid operators are %s.',
                $operator,
                implode(', ', $this->allowedOperators)
            ));
        }

        return $operator;
    }
426085
public function whereIn($field, $param, string $op = ''): self
    {
        $ops = ['?'];
        if (is_array($param)) {
            $ops = array_fill(0, count($param), '?');
        }

        return $this->where($this->prepareField($field) .' IN ('. join(', ', $ops) .')', $param, $op);
    }
1240689
function (op, other) {
        return new(tree.Dimension)
                  (tree.operate(op, this.value, other.value),
                  this.unit || other.unit);
    }
562811
public function createCollection($operator = Query::OP_AND)
    {
        $statement = new CollectionQuery();
        $statement->setOperator($operator);

        $this->add($statement);

        return $statement;
    }
814663
protected function doOperation( Operator $op ) {
		if ( count( $this->operands ) < 2 ) {
			$op->error( 'missing operand' );
		}
		$right = array_pop( $this->operands );
		$left = array_pop( $this->operands );
		$result = $op->operate( $left, $right );
		$this->operands[] = $result;
	}
817170
public function add($operation)
    {
        if (is_array($operation)) {
            $this->collection[] = new Operation($operation);
        } elseif (is_object($operation) && $operation instanceof Operation) {
            $this->collection[] = $operation;
        }

        return $this;
    }
655301
protected function setOperation($query, string $operation)
	{
		if(($query instanceof Subquery) === false)
		{
			$query = new Subquery($query);
		}

		$this->setOperations[] =
		[
			'query'     => $query,
			'operation' => $operation,
		];

		return $this;
	}
388035
public static ModelNode createOperation(final String operation) {
        final ModelNode op = new ModelNode();
        op.get(OP).set(operation);
        op.get(OP_ADDR).setEmptyList();
        return op;
    }
376846
private function beginBracket($op) {
        $this->currentWhere[] = [$op => []];
        $this->whereStack[] = &$this->currentWhere;
        end($this->currentWhere);
        $this->currentWhere = &$this->currentWhere[key($this->currentWhere)][$op];

        return $this;
    }
877812
protected function _createCombineExpression( $operator, array $list )
	{
		$results = array();
		$operators = $this->getOperators();

		foreach( $list as $entry )
		{
			$entry = (array) $entry;

			if( ( list( $op, $value ) = each( $entry ) ) === false ) {
				throw new MW_Common_Exception( sprintf( 'Invalid combine condition array "%1$s"', json_encode( $entry ) ) );
			}

			if( in_array( $op, $operators['combine'] ) ) {
				$results[] = $this->_createCombineExpression( $op, (array) $entry[$op] );
			}
			else if( in_array( $op, $operators['compare'] ) ) {
				$results[] = $this->_createCompareExpression( $op, (array) $entry[$op] );
			}
			else {
				throw new MW_Common_Exception( sprintf( 'Invalid operator "%1$s"', $op ) );
			}
		}

		return $this->combine( $operator, $results );
	}
1313765
void appendOp(int length, int op)
  {

    int totalLen = m_ops.getOp(OpMap.MAPINDEX_LENGTH);

    m_ops.setOp(totalLen, op);
    m_ops.setOp(totalLen + OpMap.MAPINDEX_LENGTH, length);
    m_ops.setOp(OpMap.MAPINDEX_LENGTH, totalLen + length);
  }
68972
protected function _createCompareExpression( $op, array $pair )
	{
		if( ( list( $name, $value ) = each( $pair ) ) === false ) {
			throw new MW_Common_Exception( sprintf( 'Invalid compare condition array "%1$s"', json_encode( $pair ) ) );
		}

		return $this->compare( $op, $name, $value );
	}
621867
public function aggregate(array $pipeline, array $op = [])
    {
        if (! TypeConverter::isNumericArray($pipeline)) {
            $operators = func_get_args();
            $pipeline = [];
            $options = [];

            $i = 0;
            foreach ($operators as $operator) {
                $i++;
                if (! is_array($operator)) {
                    trigger_error("Argument $i is not an array", E_USER_WARNING);
                    return;
                }

                $pipeline[] = $operator;
            }
        } else {
            $options = $op;
        }

        if (isset($options['cursor'])) {
            $options['useCursor'] = true;

            if (isset($options['cursor']['batchSize'])) {
                $options['batchSize'] = $options['cursor']['batchSize'];
            }

            unset($options['cursor']);
        } else {
            $options['useCursor'] = false;
        }

        try {
            $cursor = $this->collection->aggregate(TypeConverter::fromLegacy($pipeline), $options);

            return [
                'ok' => 1.0,
                'result' => TypeConverter::toLegacy($cursor),
                'waitedMS' => 0,
            ];
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
        }
    }
33080
public function on($c1, $op, $c2)
	{
		$this->_last_join->on($c1, $op, $c2);

		return $this;
	}