You need to declare the second argument and use Lexeras follows:
namespace HQF\Bundle\PizzasBundle\DQL;
use \Doctrine\ORM\Query\AST\Functions\FunctionNode;
use \Doctrine\ORM\Query\Lexer;
class MysqlRound extends FunctionNode
{
private $firstExpression = null;
private $secondExpression = null;
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->firstExpression = $parser->ArithmeticPrimary();
if(Lexer::T_COMMA === $lexer->lookahead['type']){
$parser->match(Lexer::T_COMMA);
$this->secondExpression = $parser->ArithmeticPrimary();
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
if (null !== $this->secondExpression){
return 'ROUND('
. $this->firstExpression->dispatch($sqlWalker)
. ', '
. $this->secondExpression->dispatch($sqlWalker)
. ')';
}
return 'ROUND(' . $this->firstExpression->dispatch($sqlWalker) . ')';
}
}
Edit
Doctrine2 . @beberlei . (IFELSE, IFNULL, NULLIF, COS, ACOS ..), (ROUND, GREATEST LEAST , , .)