public static function bytesToSizeString($bytes, int $decimals = null, string $decimalSeparator = null, string $thousandsSeparator = null): string
    {
        if (!is_int($bytes) && !is_float($bytes)) {
            if (is_numeric($bytes)) {
                $bytes = (float)$bytes;
            } else {
                $bytes = 0;
            }
        }

        // FIXME: The defaults should again be in the function declaration and nulls not allowed. This is a breaking change though.
        if ($decimals === null) {
            $decimals = 0;
        }
        if ($decimalSeparator === null) {
            $decimalSeparator = '.';
        }
        if ($thousandsSeparator === null) {
            $thousandsSeparator = ',';
        }

        $bytes = max($bytes, 0);
        $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
        $pow = min($pow, count(self::$sizeUnits) - 1);
        $bytes /= pow(2, (10 * $pow));

        return sprintf(
            '%s %s',
            number_format(round($bytes, 4 * $decimals), $decimals, $decimalSeparator, $thousandsSeparator),
            self::$sizeUnits[$pow]
        );
    }