src/POData/UriProcessor/QueryProcessor/OrderByParser/OrderByParser.php
/**
     * This function perform the following tasks with the help of internal helper
     * functions
     * (1) Read the orderby clause and perform basic syntax errors
     * (2) Build 'Order By Tree', creates anonymous sorter function for each leaf 
     *     node and check for error
     * (3) Build 'OrderInfo' structure, holds information about the navigation 
     *     properties used in the orderby clause (if any) and orderby path if 
     *     IDSQP implementor want to perform sorting
     * (4) Build top level anonymous sorter function
     * (4) Release resources hold by the 'Order By Tree'
     * (5) Create 'InternalOrderInfo' structure, which wraps 'OrderInfo' and top 
     *     level sorter function 
     * 
     * @param ResourceSetWrapper           $resourceSetWrapper ResourceSetWrapper for the resource targeted by resource path.
     * @param ResourceType                 $resourceType       ResourceType for the resource targeted by resource path.
     * @param string                       $orderBy            The orderby clause.
     * @param ProvidersWrapper $providerWrapper    Reference to the wrapper for IDSQP and IDSMP impl.
     * 
     * @return InternalOrderByInfo
     * 
     * @throws ODataException If any error occur while parsing orderby clause
     */


@param ResourceSetWrapper           $resourceSetWrapper ResourceSetWrapper for the resource targeted by resource path.
@param ResourceType                 $resourceType       ResourceType for the resource targeted by resource path.
@param string                       $orderBy            The orderby clause.
@param ProvidersWrapper $providerWrapper    Reference to the wrapper for IDSQP and IDSMP impl.



@throws ODataException If any error occur while parsing orderby clause
@param ResourceSetWrapper $resourceSetWrapper ResourceSetWrapper for the resource targeted by resource path . @param ResourceType $resourceType ResourceType for the resource targeted by resource path . @param string $orderBy The orderby clause . @param ProvidersWrapper $providerWrapper Reference to the wrapper for IDSQP and IDSMP impl . @throws ODataException If any error occur while parsing orderby clause
public static function parseOrderByClause(
	    ResourceSetWrapper $resourceSetWrapper,
        ResourceType $resourceType,
        $orderBy,
        ProvidersWrapper $providerWrapper
    ) {
        $orderByParser = new OrderByParser($providerWrapper);
        try {
            $orderByParser->_dummyObject = $resourceType->getInstanceType()->newInstance();
        } catch (\ReflectionException $reflectionException) {
            throw ODataException::createInternalServerError(Messages::orderByParserFailedToCreateDummyObject());
        }
        $orderByParser->_rootOrderByNode = new OrderByRootNode($resourceSetWrapper, $resourceType);
        $orderByPathSegments = $orderByParser->_readOrderBy($orderBy);
        $orderByParser->_buildOrderByTree($orderByPathSegments);
        $orderByParser->_createOrderInfo($orderByPathSegments);
        $orderByParser->_generateTopLevelComparisonFunction();
        $orderByParser->_rootOrderByNode->free();
        $internalOrderInfo = new InternalOrderByInfo(
            $orderByParser->_orderByInfo, 
            $orderByParser->_comparisonFunctions, 
            $orderByParser->_topLevelComparisonFunction, 
            $orderByParser->_dummyObject
        );
        unset($orderByParser->_orderByInfo);
        unset($orderByParser->_topLevelComparisonFunction);
        return $internalOrderInfo;        
    }
public static function parseOrderByClause ( ResourceSetWrapper $ resourceSetWrapper , ResourceType $ resourceType , $ orderBy , ProvidersWrapper $ providerWrapper ) { $ orderByParser = new OrderByParser ( $ providerWrapper ) ; try { $ orderByParser -> _dummyObject = $ resourceType -> getInstanceType ( ) -> newInstance ( ) ; } catch ( \ ReflectionException $ reflectionException ) { throw ODataException :: createInternalServerError ( Messages :: orderByParserFailedToCreateDummyObject ( ) ) ; } $ orderByParser -> _rootOrderByNode = new OrderByRootNode ( $ resourceSetWrapper , $ resourceType ) ; $ orderByPathSegments = $ orderByParser -> _readOrderBy ( $ orderBy ) ; $ orderByParser -> _buildOrderByTree ( $ orderByPathSegments ) ; $ orderByParser -> _createOrderInfo ( $ orderByPathSegments ) ; $ orderByParser -> _generateTopLevelComparisonFunction ( ) ; $ orderByParser -> _rootOrderByNode -> free ( ) ; $ internalOrderInfo = new InternalOrderByInfo ( $ orderByParser -> _orderByInfo , $ orderByParser -> _comparisonFunctions , $ orderByParser -> _topLevelComparisonFunction , $ orderByParser -> _dummyObject ) ; unset ( $ orderByParser -> _orderByInfo ) ; unset ( $ orderByParser -> _topLevelComparisonFunction ) ; return $ internalOrderInfo ; }
This function perform the following tasks with the help of internal helper
 functions
 (1) Read the orderby clause and perform basic syntax errors
 (2) Build 'Order By Tree', creates anonymous sorter function for each leaf
     node and check for error
 (3) Build 'OrderInfo' structure, holds information about the navigation
     properties used in the orderby clause (if any) and orderby path if
     IDSQP implementor want to perform sorting
 (4) Build top level anonymous sorter function
 (4) Release resources hold by the 'Order By Tree'
 (5) Create 'InternalOrderInfo' structure, which wraps 'OrderInfo' and top
     level sorter function
This function perform the following tasks with the help of internal helper functions ( 1 ) Read the orderby clause and perform basic syntax errors ( 2 ) Build ' Order By Tree ' creates anonymous sorter function for each leaf node and check for error ( 3 ) Build ' OrderInfo ' structure holds information about the navigation properties used in the orderby clause ( if any ) and orderby path if IDSQP implementor want to perform sorting ( 4 ) Build top level anonymous sorter function ( 4 ) Release resources hold by the ' Order By Tree ' ( 5 ) Create ' InternalOrderInfo ' structure which wraps ' OrderInfo ' and top level sorter function
//Recursively release the resources //creates internal order info wrapper 