fix(clashmeta): handle associative arrays in block yaml export

This commit is contained in:
yinjianm
2026-04-18 01:50:45 +08:00
parent 4a5091825c
commit 994819e8a0
+19
View File
@@ -250,6 +250,25 @@ class ClashMeta extends AbstractProtocol
foreach ($value as $item) { foreach ($value as $item) {
$prefix = str_repeat(' ', $indent) . '-'; $prefix = str_repeat(' ', $indent) . '-';
if (is_array($item)) { if (is_array($item)) {
if (self::isAssocArray($item)) {
$isFirst = true;
foreach ($item as $key => $child) {
$keyPrefix = ($isFirst ? $prefix . ' ' : str_repeat(' ', $indent + 2)) . $key . ':';
if (is_array($child)) {
if ($child === []) {
$lines[] = $keyPrefix . ' []';
} else {
$lines[] = $keyPrefix;
$lines[] = rtrim(self::dumpYamlNode($child, $indent + 4), "\n");
}
} else {
$lines[] = $keyPrefix . ' ' . self::dumpYamlScalar($child);
}
$isFirst = false;
}
continue;
}
if ($item === []) { if ($item === []) {
$lines[] = $prefix . ' []'; $lines[] = $prefix . ' []';
continue; continue;