src/Parser/Doctrine/OrderPartialParser.php
final public static function parse(
        array $queryBuilderFieldsToProperties,
        array $sortColumns = null,
        array $embeddableFieldsToProperties,
        array $embeddableInsideEmbeddableFieldsToProperties
    ): string {
        foreach ($queryBuilderFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = StringManipulator::replaceAllDotsExceptLast(SelectPartialParser::OBJECT_WORD.'.'.$property);
        }
        foreach ($embeddableFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = SelectPartialParser::OBJECT_WORD.StringManipulator::replaceAllDotsExceptLastTwo('.'.$property);
        }
        foreach ($embeddableInsideEmbeddableFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = SelectPartialParser::OBJECT_WORD.StringManipulator::replaceAllDotsExceptLastThree('.'.$property);
        }

        if (null === $sortColumns || 0 === count($sortColumns)) {
            return '';
        }

        $orderString = ' ORDER BY ';
        foreach ($sortColumns as $field => $order) {
            $orderString .= sprintf(' %s %s, ',
                static::queryBuilderFieldToOrderAlias($field),
                static::queryBuilderOrderDirectionToSafeValue($order)
            );
        }

        return rtrim($orderString, ', ').' ';
    }
final public static function parse(
        array $queryBuilderFieldsToProperties,
        array $sortColumns = null,
        array $embeddableFieldsToProperties,
        array $embeddableInsideEmbeddableFieldsToProperties
    ): string {
        foreach ($queryBuilderFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = StringManipulator::replaceAllDotsExceptLast(SelectPartialParser::OBJECT_WORD.'.'.$property);
        }
        foreach ($embeddableFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = SelectPartialParser::OBJECT_WORD.StringManipulator::replaceAllDotsExceptLastTwo('.'.$property);
        }
        foreach ($embeddableInsideEmbeddableFieldsToProperties as $field => $property) {
            static::$queryBuilderFieldsToOrderAlias[$field] = SelectPartialParser::OBJECT_WORD.StringManipulator::replaceAllDotsExceptLastThree('.'.$property);
        }

        if (null === $sortColumns || 0 === count($sortColumns)) {
            return '';
        }

        $orderString = ' ORDER BY ';
        foreach ($sortColumns as $field => $order) {
            $orderString .= sprintf(' %s %s, ',
                static::queryBuilderFieldToOrderAlias($field),
                static::queryBuilderOrderDirectionToSafeValue($order)
            );
        }

        return rtrim($orderString, ', ').' ';
    }
@param array      $queryBuilderFieldsToProperties
@param array|null $sortColumns
@param array      $embeddableFieldsToProperties
@param array      $embeddableInsideEmbeddableFieldsToProperties

@return string