@param $type
@param $expressions

@return mixed

@throws UnknowCompositeTypeException
3062
private function buildComposite($type, $expressions)
    {
        switch ($type) {
            case Lexer::T_AND:
                return $this->expressionBuilder->andX($expressions);
            case Lexer::T_NOT_AND:
                return $this->expressionBuilder->nandX($expressions);
            case Lexer::T_OR:
                return $this->expressionBuilder->orX($expressions);
            case Lexer::T_NOT_OR:
                return $this->expressionBuilder->norX($expressions);
            case Lexer::T_XOR:
                return $this->expressionBuilder->xorX($expressions);
            default:
                throw new UnknowCompositeTypeException($type);
        }
    }
673579
public function find($expression)
    {
        $tokens = $this->parseTokens($expression);

        $collectionData = [$this->data];

        foreach ($tokens as $token) {
            $filter = $token->buildFilter($this->options);

            $filteredData = [];

            foreach ($collectionData as $value) {
                if (AccessHelper::isCollectionType($value)) {
                    $filteredValue = $filter->filter($value);
                    $filteredData = array_merge($filteredData, $filteredValue);
                }
            }

            $collectionData = $filteredData;
        }


        return new static($collectionData, $this->options);
    }
1088574
public static function getInstance(LdapObjectSchema $schema = null, $values, $type)
    {
        $instance = AttributeValueResolver::class;
        
        if ($values instanceof BatchCollection) {
            $instance = BatchValueResolver::class;
        } elseif ($values instanceof OperatorCollection) {
            $instance = OperatorValueResolver::class;
        }
        
        return new $instance($schema, $values, $type);
    }
35917
public static function compile($expression, $type = self::TYPE_CSS)
    {
        if (!is_string($expression)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($expression)));
        }

        if (!is_string($type)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 2 to be string, %s given', __METHOD__, gettype($type)));
        }

        if (strcasecmp($type, self::TYPE_XPATH) !== 0 && strcasecmp($type, self::TYPE_CSS) !== 0) {
            throw new RuntimeException(sprintf('Unknown expression type "%s"', $type));
        }

        $expression = trim($expression);

        if ($expression === '') {
            throw new InvalidSelectorException('The expression must not be empty');
        }

        if (strcasecmp($type, self::TYPE_XPATH) === 0) {
            return $expression;
        }

        if (!array_key_exists($expression, static::$compiled)) {
            static::$compiled[$expression] = static::cssToXpath($expression);
        }

        return static::$compiled[$expression];
    }
796610
protected function resolveCompositeBinding($vars)
    {
        $keys = array_keys($vars);

        foreach ($this->compositeBindings as $binding) {
            if ($keys === $binding[0]) {
                $binder = $binding[1];
                $errorHandler = $binding[2];

                $callable = $this->getBindingCallable($binder, null);
                $r = $this->callBindingCallable($callable, $vars, $errorHandler, true);

                if (!is_array($r) || count($r) !== count($vars)) {
                    throw new Exception("Route-Model-Binding (composite-bind) : Return value should be an array and should be of the same count as the wildcards!");
                }

                // Combine the binding results with the keys
                return array_combine($keys, array_values($r));
            }
        }
    }
1012853
public function count($expression, $type = Query::TYPE_CSS)
    {
        $expression = Query::compile($expression, $type);
        $expression = sprintf('count(%s)', $expression);

        return (int) $this->createXpath()->evaluate($expression);
    }
861981
public function orX(array $expressions)
    {
        $expr = $this->createExpr();
        foreach ($expressions as $expression) {
            $expr->addOr($expression);
        }

        return $expr;
    }
1071377
public static function typeAncestryForType(ResolvedFormTypeInterface $formType = null, array &$types)
    {
        if (!($formType instanceof ResolvedFormTypeInterface)) {
            return;
        }

        $types[] = $formType->getBlockPrefix();

        self::typeAncestryForType($formType->getParent(), $types);
    }
308580
private function getHandler($type)
    {
        if (!isset(self::$typeHandlers[$type])) {
            throw new Exception("Unsupported PDO param type - " . $type);
        }

        return self::$typeHandlers[$type];
    }
1286102
public function compile($expression, CompilationContext $compilationContext)
    {
        /*
         * Resolves the symbol that expects the value
         */
        if ($this->expecting) {
            if ($this->expectingVariable) {
                $symbolVariable = $this->expectingVariable;
                if ('variable' != $symbolVariable->getType()) {
                    throw new CompilerException('Cannot use variable type: '.$symbolVariable->getType().' to store a reference', $expression);
                }
            } else {
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
            }
        } else {
            $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
        }

        $leftExpr = new Expression($expression['left']);
        $leftExpr->setReadOnly($this->readOnly);
        $left = $leftExpr->compile($compilationContext);

        switch ($left->getType()) {
            case 'variable':
            case 'string':
            case 'object':
            case 'array':
            case 'callable':
                break;
            default:
                throw new CompilerException('Cannot obtain a reference from type: '.$left->getType(), $expression);
        }

        $leftVariable = $compilationContext->symbolTable->getVariableForRead($left->getCode(), $compilationContext, $expression);
        switch ($leftVariable->getType()) {
            case 'variable':
            case 'string':
            case 'object':
            case 'array':
            case 'callable':
                break;
            default:
                throw new CompilerException('Cannot obtain reference from variable type: '.$leftVariable->getType(), $expression);
        }

        $symbolVariable->setMustInitNull(true);
        $compilationContext->symbolTable->mustGrownStack(true);

        $symbolVariable->increaseVariantIfNull();
        $compilationContext->codePrinter->output('ZEPHIR_MAKE_REFERENCE('.$symbolVariable->getName().', '.$leftVariable->getName().');');

        return new CompiledExpression('reference', $symbolVariable->getRealName(), $expression);
    }
41208
public function count($expression, $type = Query::TYPE_CSS)
    {
        return $this->toDocument()->count($expression, $type);
    }
561834
public function groupBy( $expressions /* expressions ... */ )  {
		$expressions = is_array( $expressions ) ? $expressions : func_get_args();

		$this->modifierBuilder->groupBy( $expressions );
		return $this;
	}
803122
private function convertToPg($data, TypeInterface $type)
    {
        if ($data === null) {
            return new Value('null');
        }

        if ($type instanceof ArrayType) {
            return $this->convertArrayToPg($data, $type);
        }

        if (isset($this->mappings[(string) $type])) {
            return $this->convertCompositeToPg($data, $type);
        }

        return $this->convertScalarToPg($data, $type);
    }
1096895
private function createMatches(array $expression, CompilationContext $context)
    {
        if (isset($expression['parameters'][2])) {
            $type = $expression['parameters'][2]['parameter']['type'];

            if ('variable' !== $type) {
                throw new CompilerException('Only variables can be passed by reference', $expression);
            }

            $name = $expression['parameters'][2]['parameter']['value'];

            if (!$variable = $context->symbolTable->getVariable($name)) {
                throw new CompilerException(
                    sprintf("Cannot mutate variable '%s' because it wasn't defined", $name),
                    $expression
                );
            }

            if (!\in_array($variable->getType(), ['variable', 'array'], true)) {
                throw new CompilerException(
                    sprintf(
                        "The '%s' variable must be either a variable or an array, got %s",
                        $name,
                        $variable->getType()
                    ),
                    $expression
                );
            }

            if (false == $variable->isInitialized()) {
                $variable->initVariant($context);
                $variable->setIsInitialized(true, $context);
            }
        } else {
            $variable = $context->symbolTable->addTemp('variable', $context);
            $variable->initVariant($context);
        }

        $variable->setDynamicTypes('array');

        return $variable;
    }
1023276
public function nandX(array $expressions)
    {
        $self = $this;
        return function ($object) use ($self, $expressions) {
            $andX = $self->andX($expressions);
            return !$andX($object);
        };
    }
1297854
public function orWhere(Expression $expression) : self
    {
        if ($this->expression === null) {
            return $this->where($expression);
        }

        $this->expression = new CompositeExpression(
            CompositeExpression::TYPE_OR,
            [$this->expression, $expression]
        );

        return $this;
    }
880424
public function findFirstInSubTree($type)
    {
        foreach ($this->getSubTree() as $expression) {
            if ($expression->getType() === $type) {
                return $expression;
            }
        }

        return null;
    }