$used 已用名列表(引用传入,调用方维护) */ public static function make(string $name, int $id, array &$used): string { $base = str_replace(['[', ']', ':', '*', '?', '/', '\\'], '', $name); $base = mb_substr($base === '' ? '未命名' : $base, 0, 28); $title = $base; if (in_array($title, $used, true)) { $title = mb_substr($base, 0, 25) . '#' . $id; } $used[] = $title; return $title; } }