/**
  * Create platform function node.
  *
  * @param string $platformName
  * @param string $functionName
  * @param array $parameters
  * @throws \Doctrine\ORM\Query\QueryException
  * @return PlatformFunctionNode
  */
 public static function create($platformName, $functionName, array $parameters)
 {
     $className = __NAMESPACE__ . '\\Platform\\Functions\\' . Inflector::classify(strtolower($platformName)) . '\\' . Inflector::classify(strtolower($functionName));
     if (!class_exists($className)) {
         throw QueryException::syntaxError(sprintf('Function "%s" does not supported for platform "%s"', $functionName, $platformName));
     }
     return new $className($parameters);
 }
 /**
  * Generates a new syntax error.
  *
  * @param string      $expected Expected string.
  * @param array|null  $token    Got token.
  *
  * @return void
  *
  * @throws \Doctrine\ORM\Query\QueryException
  */
 public function syntaxError($expected = '', $token = null)
 {
     if ($token === null) {
         $token = $this->lexer->lookahead;
     }
     $tokenPos = isset($token['position']) ? $token['position'] : '-1';
     $message = "line 0, col {$tokenPos}: Error: ";
     $message .= $expected !== '' ? "Expected {$expected}, got " : 'Unexpected ';
     $message .= $this->lexer->lookahead === null ? 'end of string.' : "'{$token['value']}'";
     throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL()));
 }
示例#3
0
 /**
  * Generates a new syntax error.
  *
  * @param string $expected Expected string.
  * @param array $token Got token.
  *
  * @throws \Doctrine\ORM\Query\QueryException
  */
 public function syntaxError($expected = '', $token = null)
 {
     if ($token === null) {
         $token = $this->_lexer->lookahead;
     }
     $tokenPos = isset($token['position']) ? $token['position'] : '-1';
     $message = "line 0, col {$tokenPos}: Error: ";
     if ($expected !== '') {
         $message .= "Expected {$expected}, got ";
     } else {
         $message .= 'Unexpected ';
     }
     if ($this->_lexer->lookahead === null) {
         $message .= 'end of string.';
     } else {
         $message .= "'{$token['value']}'";
     }
     throw QueryException::syntaxError($message);
 }