Doctrine\ORM\Query\Parser::ScalarExpression PHP Method

ScalarExpression() public method

ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression | BooleanPrimary | CaseExpression | EntityTypeExpression
public ScalarExpression ( ) : mixed
return mixed One of the possible expressions or subexpressions.
    public function ScalarExpression()
    {
        $lookahead = $this->_lexer->lookahead['type'];
        if ($lookahead === Lexer::T_IDENTIFIER) {
            $this->_lexer->peek(); // lookahead => '.'
            $this->_lexer->peek(); // lookahead => token after '.'
            $peek = $this->_lexer->peek(); // lookahead => token after the token after the '.'
            $this->_lexer->resetPeek();

            if ($this->_isMathOperator($peek)) {
                return $this->SimpleArithmeticExpression();
            }

            return $this->StateFieldPathExpression();
        } else if ($lookahead == Lexer::T_INTEGER || $lookahead == Lexer::T_FLOAT) {
            return $this->SimpleArithmeticExpression();
        } else if ($this->_isFunction()) {
            // We may be in an ArithmeticExpression (find the matching ")" and inspect for Math operator)
            $this->_lexer->peek(); // "("
            $peek = $this->_peekBeyondClosingParenthesis();

            if ($this->_isMathOperator($peek)) {
                return $this->SimpleArithmeticExpression();
            }
            
            return $this->FunctionDeclaration();
        } else if ($lookahead == Lexer::T_STRING) {
            return $this->StringPrimary();
        } else if ($lookahead == Lexer::T_INPUT_PARAMETER) {
            return $this->InputParameter();
        } else if ($lookahead == Lexer::T_TRUE || $lookahead == Lexer::T_FALSE) {
            $this->match($lookahead);
            return new AST\Literal(AST\Literal::BOOLEAN, $this->_lexer->token['value']);
        } else if ($lookahead == Lexer::T_CASE || $lookahead == Lexer::T_COALESCE || $lookahead == Lexer::T_NULLIF) {
            return $this->CaseExpression();
        } else {
            $this->syntaxError();
        }
    }

Usage Example

コード例 #1
0
ファイル: RepeatFunction.php プロジェクト: b4nan/doctrine
 /**
  * @param Parser $parser
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->char = $parser->ScalarExpression();
     $parser->match(Lexer::T_COMMA);
     $this->times = $parser->ScalarExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
All Usage Examples Of Doctrine\ORM\Query\Parser::ScalarExpression
Parser