private function  parseOrderByField()
    {
        $retVal = null;

        $fieldName = $this->tokenizer->getTokenValue();

        $this->tokenizer->expect(TokenType::EXPRESSION);

        if($this->tokenizer->is(TokenType::LEFT_PAREN))
        {
            $retVal = new AST\OrderByFunction($this->parseFunctionExpression($fieldName, Functions\SoqlFunctionInterface::CONTEXT_ORDER_BY));
        }
        else
        {
            $retVal = new AST\OrderByField($fieldName);
        }

        // ASC/DESC
        if($this->tokenizer->isKeyword('asc'))
        {
            $retVal->setDirection(AST\OrderByField::DIRECTION_ASC);

            $this->tokenizer->readNextToken();
        }
        elseif($this->tokenizer->isKeyword('desc'))
        {
            $retVal->setDirection(AST\OrderByField::DIRECTION_DESC);

            $this->tokenizer->readNextToken();
        }

        if($this->tokenizer->isKeyword('NULLS'))
        {
            $this->tokenizer->readNextToken();

            if($this->tokenizer->isKeyword('last'))
            {
                $retVal->setNulls(AST\OrderByField::NULLS_LAST);
            }
            elseif($this->tokenizer->isKeyword('first'))
            {
                $retVal->setNulls(AST\OrderByField::NULLS_FIRST);
            }
            else
            {
                throw new ParseException(sprintf('Unexpected "%s"', $this->tokenizer->getTokenValue()), $this->tokenizer->getLine(), $this->tokenizer->getLinePos(), $this->tokenizer->getInput());
            }
            $this->tokenizer->expect(TokenType::KEYWORD);
        }

        return $retVal;
    }
private function  parseOrderByField()
    {
        $retVal = null;

        $fieldName = $this->tokenizer->getTokenValue();

        $this->tokenizer->expect(TokenType::EXPRESSION);

        if($this->tokenizer->is(TokenType::LEFT_PAREN))
        {
            $retVal = new AST\OrderByFunction($this->parseFunctionExpression($fieldName, Functions\SoqlFunctionInterface::CONTEXT_ORDER_BY));
        }
        else
        {
            $retVal = new AST\OrderByField($fieldName);
        }

        // ASC/DESC
        if($this->tokenizer->isKeyword('asc'))
        {
            $retVal->setDirection(AST\OrderByField::DIRECTION_ASC);

            $this->tokenizer->readNextToken();
        }
        elseif($this->tokenizer->isKeyword('desc'))
        {
            $retVal->setDirection(AST\OrderByField::DIRECTION_DESC);

            $this->tokenizer->readNextToken();
        }

        if($this->tokenizer->isKeyword('NULLS'))
        {
            $this->tokenizer->readNextToken();

            if($this->tokenizer->isKeyword('last'))
            {
                $retVal->setNulls(AST\OrderByField::NULLS_LAST);
            }
            elseif($this->tokenizer->isKeyword('first'))
            {
                $retVal->setNulls(AST\OrderByField::NULLS_FIRST);
            }
            else
            {
                throw new ParseException(sprintf('Unexpected "%s"', $this->tokenizer->getTokenValue()), $this->tokenizer->getLine(), $this->tokenizer->getLinePos(), $this->tokenizer->getInput());
            }
            $this->tokenizer->expect(TokenType::KEYWORD);
        }

        return $retVal;
    }
private function parseOrderByField ( ) { $ retVal = null ; $ fieldName = $ this -> tokenizer -> getTokenValue ( ) ; $ this -> tokenizer -> expect ( TokenType :: EXPRESSION ) ; if ( $ this -> tokenizer -> is ( TokenType :: LEFT_PAREN ) ) { $ retVal = new AST \ OrderByFunction ( $ this -> parseFunctionExpression ( $ fieldName , Functions \ SoqlFunctionInterface :: CONTEXT_ORDER_BY ) ) ; } else { $ retVal = new AST \ OrderByField ( $ fieldName ) ; } // ASC/DESC if ( $ this -> tokenizer -> isKeyword ( 'asc' ) ) { $ retVal -> setDirection ( AST \ OrderByField :: DIRECTION_ASC ) ; $ this -> tokenizer -> readNextToken ( ) ; } elseif ( $ this -> tokenizer -> isKeyword ( 'desc' ) ) { $ retVal -> setDirection ( AST \ OrderByField :: DIRECTION_DESC ) ; $ this -> tokenizer -> readNextToken ( ) ; } if ( $ this -> tokenizer -> isKeyword ( 'NULLS' ) ) { $ this -> tokenizer -> readNextToken ( ) ; if ( $ this -> tokenizer -> isKeyword ( 'last' ) ) { $ retVal -> setNulls ( AST \ OrderByField :: NULLS_LAST ) ; } elseif ( $ this -> tokenizer -> isKeyword ( 'first' ) ) { $ retVal -> setNulls ( AST \ OrderByField :: NULLS_FIRST ) ; } else { throw new ParseException ( sprintf ( 'Unexpected "%s"' , $ this -> tokenizer -> getTokenValue ( ) ) , $ this -> tokenizer -> getLine ( ) , $ this -> tokenizer -> getLinePos ( ) , $ this -> tokenizer -> getInput ( ) ) ; } $ this -> tokenizer -> expect ( TokenType :: KEYWORD ) ; } return $ retVal ; }
ORDER BY fieldExpression ASC | DESC ? NULLS FIRST | LAST ?

@throws ParseException
@return SortableInterface
ORDER BY fieldExpression ASC | DESC ? NULLS FIRST | LAST ?