private static function myParsePath(?UrlInterface $baseUrl = null, string $pathString, ?UrlPathInterface &$path = null, ?string &$queryString = null, ?string &$fragment = null, ?string &$error = null): bool
    {
        // Fragment.
        $parts = explode('#', $pathString, 2);
        $pathString = $parts[0];
        $fragment = count($parts) > 1 ? $parts[1] : null;

        if (!self::myValidateFragment($fragment, $error)) {
            return false;
        }

        // Query string.
        $parts = explode('?', $pathString, 2);
        $pathString = $parts[0];
        $queryString = count($parts) > 1 ? $parts[1] : null;

        if (!self::myValidateQueryString($queryString, $error)) {
            return false;
        }

        // Try parse url path.
        if (!self::myParseUrlPath($baseUrl, $pathString, $path, $error)) {
            return false;
        }

        // If path is empty and there is a base url, handle query string and fragment.
        if ($pathString === '' && $baseUrl !== null && $queryString === null) {
            $queryString = $baseUrl->getQueryString();
            $fragment = $fragment ?: $baseUrl->getFragment();
        }

        return true;
    }