Doctrine\ORM\Query\Parser::SimpleArithmeticExpression PHP Méthode

SimpleArithmeticExpression() public méthode

SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*
public SimpleArithmeticExpression ( ) : Doctrine\ORM\Query\AST\SimpleArithmeticExpression
Résultat Doctrine\ORM\Query\AST\SimpleArithmeticExpression
    public function SimpleArithmeticExpression()
    {
        $terms = array();
        $terms[] = $this->ArithmeticTerm();

        while (($isPlus = $this->_lexer->isNextToken(Lexer::T_PLUS)) || $this->_lexer->isNextToken(Lexer::T_MINUS)) {
            $this->match(($isPlus) ? Lexer::T_PLUS : Lexer::T_MINUS);

            $terms[] = $this->_lexer->token['value'];
            $terms[] = $this->ArithmeticTerm();
        }

        // Phase 1 AST optimization: Prevent AST\SimpleArithmeticExpression
        // if only one AST\ArithmeticTerm is defined
        if (count($terms) == 1) {
            return $terms[0];
        }

        return new AST\SimpleArithmeticExpression($terms);
    }

Usage Example

 /**
  * @override
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
All Usage Examples Of Doctrine\ORM\Query\Parser::SimpleArithmeticExpression
Parser