ArithmeticExpression() public method

ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"
public ArithmeticExpression ( ) : Doctrine\ORM\Query\AST\ArithmeticExpression
return Doctrine\ORM\Query\AST\ArithmeticExpression
Example #1
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // Add the concat separator to the values array.
     $this->values[] = $parser->ArithmeticExpression();
     // Add the rest of the strings to the values array. CONCAT_WS must
     // be used with at least 2 strings not including the separator.
     $lexer = $parser->getLexer();
     while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) {
         $parser->match(Lexer::T_COMMA);
         $peek = $lexer->glimpse();
         $this->values[] = $peek['value'] == '(' ? $parser->FunctionDeclaration() : $parser->ArithmeticExpression();
     }
     while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
         switch (strtolower($lexer->lookahead['value'])) {
             case 'notempty':
                 $parser->match(Lexer::T_IDENTIFIER);
                 $this->notEmpty = true;
                 break;
             default:
                 // Identifier not recognized (causes exception).
                 $parser->match(Lexer::T_CLOSE_PARENTHESIS);
                 break;
         }
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 /**
  * @param \Doctrine\ORM\Query\Parser $parser
  * @return void
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->date = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->format = $this->convertFormat($parser->ArithmeticExpression());
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #3
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expr1 = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->expr2 = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 public function parse(Parser $parser)
 {
     $parser->Match(Lexer::T_IDENTIFIER);
     $parser->Match(Lexer::T_OPEN_PARENTHESIS);
     $this->dateExpression = $parser->ArithmeticExpression();
     $parser->Match(Lexer::T_COMMA);
     $this->formatChar = $parser->ArithmeticExpression();
     $parser->Match(Lexer::T_CLOSE_PARENTHESIS);
 }
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->latitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->center = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->distance = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #6
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->condition = $parser->ConditionalExpression();
     $parser->match(Lexer::T_COMMA);
     $this->isTrueStatement = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->isFalseStatement = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #7
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->firstValue = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->secondValue = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->thirdValue = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #8
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expressions[] = $parser->ConditionalExpression();
     $parser->match(Lexer::T_COMMA);
     $this->expressions[] = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->expressions[] = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->values[] = $parser->ArithmeticExpression();
     $lexer = $parser->getLexer();
     while (count($this->values) < 2 || $lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
         $parser->match(Lexer::T_COMMA);
         $this->values[] = $parser->ArithmeticExpression();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #10
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match(\Doctrine\ORM\Query\Lexer::T_IDENTIFIER);
     $parser->match(\Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS);
     $this->firstExpression = $parser->ArithmeticExpression();
     if (\Doctrine\ORM\Query\Lexer::T_COMMA === $lexer->lookahead['type']) {
         $parser->match(\Doctrine\ORM\Query\Lexer::T_COMMA);
         $this->secondExpression = $parser->ArithmeticExpression();
     }
     $parser->match(\Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS);
 }
Example #11
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->latOrigin = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->lngOrigin = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->latDestination = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->lngDestination = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #12
0
 public function parse(Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->fromLatitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->fromLongitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->toLatitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->toLongitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->latOrigin = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->lonOrigin = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->latPoint = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->lonPoint = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->distance = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #14
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     // (2)
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     // (3)
     $this->nb = $parser->ArithmeticExpression();
     // (4)
     $parser->match(Lexer::T_COMMA);
     // (3)
     $this->format = $parser->ArithmeticExpression();
     // (4)
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
     // (3)
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->parameters[self::PARAMETER_KEY] = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_AS);
     $parser->match(Lexer::T_IDENTIFIER);
     $lexer = $parser->getLexer();
     $type = $lexer->token['value'];
     if ($lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
         $parser->match(Lexer::T_OPEN_PARENTHESIS);
         /** @var Literal $parameter */
         $parameter = $parser->Literal();
         $parameters = array($parameter->value);
         if ($lexer->isNextToken(Lexer::T_COMMA)) {
             while ($lexer->isNextToken(Lexer::T_COMMA)) {
                 $parser->match(Lexer::T_COMMA);
                 $parameter = $parser->Literal();
                 $parameters[] = $parameter->value;
             }
         }
         $parser->match(Lexer::T_CLOSE_PARENTHESIS);
         $type .= '(' . implode(', ', $parameters) . ')';
     }
     if (!$this->checkType($type)) {
         $parser->syntaxError(sprintf('Type unsupported. Supported types are: "%s"', implode(', ', $this->supportedTypes)), $lexer->token);
     }
     $this->parameters[self::TYPE_KEY] = $type;
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->longitude = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->center = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->distance = $parser->ArithmeticExpression();
     if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) {
         $parser->match(Lexer::T_COMMA);
         $this->latitude = $this->center;
         $this->center = $this->distance;
         $this->distance = $parser->ArithmeticExpression();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 /**
  * parse - allows DQL to breakdown the DQL string into a processable structure.
  *
  * @param \Doctrine\ORM\Query\Parser $parser
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->dateExpression = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->formatChar = $parser->StringPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #18
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->field = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_AS);
     $this->type = $parser->getLexer()->lookahead['value'];
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->dateExpression = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->fromTz = $parser->StringPrimary();
     $parser->match(Lexer::T_COMMA);
     $this->toTz = $parser->StringPrimary();
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #20
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expr[] = $parser->ConditionalExpression();
     for ($i = 0; $i < 2; $i++) {
         $parser->match(Lexer::T_COMMA);
         $this->expr[] = $parser->ArithmeticExpression();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #21
0
 /**
  * parse
  *
  * @param \Doctrine\ORM\Query\Parser $parser
  * @access public
  * @return void
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->roundPrecission = $parser->ArithmeticExpression();
     if ($this->roundPrecission == null) {
         $this->roundPrecission = 0;
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
 /**
  * {@inheritDoc}
  */
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $lexer = $parser->getLexer();
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->date = $parser->ArithmeticExpression();
     // parse second format parameter if available
     if (Lexer::T_COMMA === $lexer->lookahead['type']) {
         $parser->match(Lexer::T_COMMA);
         $this->fmt = $parser->ArithmeticPrimary();
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #23
0
 public function parse(\Doctrine\ORM\Query\Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->expr1 = $parser->ArithmeticExpression();
     $parser->match(Lexer::T_COMMA);
     $this->expr2 = $parser->ArithmeticExpression();
     $lexer = $parser->getLexer();
     while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
         switch (strtolower($lexer->lookahead['value'])) {
             case 'inverse':
                 $parser->match(Lexer::T_IDENTIFIER);
                 $this->inverse = true;
                 break;
             default:
                 // Identifier not recognized (causes exception).
                 $parser->match(Lexer::T_CLOSE_PARENTHESIS);
                 break;
         }
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }
Example #24
0
 public function parse(Parser $parser)
 {
     $parser->match(Lexer::T_IDENTIFIER);
     $parser->match(Lexer::T_OPEN_PARENTHESIS);
     $this->values[] = $parser->ArithmeticExpression();
     $lexer = $parser->getLexer();
     while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) {
         $parser->match(Lexer::T_COMMA);
         $peek = $lexer->glimpse();
         $this->values[] = $peek['value'] == '(' ? $parser->FunctionDeclaration() : $parser->ArithmeticExpression();
     }
     while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
         switch (strtolower($lexer->lookahead['value'])) {
             case 'notempty':
                 $parser->match(Lexer::T_IDENTIFIER);
                 $this->notEmpty = true;
                 break;
             default:
                 $parser->match(Lexer::T_CLOSE_PARENTHESIS);
                 break;
         }
     }
     $parser->match(Lexer::T_CLOSE_PARENTHESIS);
 }