From 23aad291c9d87bd5ae39a41efe1f2d7e2a7edc0f Mon Sep 17 00:00:00 2001 From: devman1917 <92359289+devman1917@users.noreply.github.com> Date: Tue, 6 Jan 2026 12:42:06 +0330 Subject: [PATCH] Update Dumper.php --- Dumper.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Dumper.php b/Dumper.php index cd5a1f6c..5752efdd 100644 --- a/Dumper.php +++ b/Dumper.php @@ -129,15 +129,24 @@ private function doDump(mixed $input, int $inline = 0, int $indent = 0, int $fla if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { $dumpObjectAsInlineMap = !(array) $value; } - - $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || !$value; + $isSequenceItem = !$dumpAsMap; + $willBeInlined = + $inline - 1 <= 0 + || (!\is_array($value) && $dumpObjectAsInlineMap) + || !$value + || ( + $isSequenceItem + && \is_array($value) + && Inline::isHash($value) + && $this->isSimpleInlineMap($value) + ); $output .= \sprintf('%s%s%s%s', - $prefix, - $dumpAsMap ? Inline::dump($key, $flags).':' : '-', - $willBeInlined || ($compactNestedMapping && \is_array($value) && Inline::isHash($value)) ? ' ' : "\n", - $compactNestedMapping && \is_array($value) && Inline::isHash($value) ? substr($this->doDump($value, $inline - 1, $indent + 2, $flags, $nestingLevel + 1), $indent + 2) : $this->doDump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags, $nestingLevel + 1) - ).($willBeInlined ? "\n" : ''); + $prefix, + $dumpAsMap ? Inline::dump($key, $flags).':' : '-', + $willBeInlined || ($compactNestedMapping && \is_array($value) && Inline::isHash($value)) ? ' ' : "\n", + $compactNestedMapping && \is_array($value) && Inline::isHash($value) ? substr($this->doDump($value, $inline - 1, $indent + 2, $flags, $nestingLevel + 1), $indent + 2) : $this->doDump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags, $nestingLevel + 1) + ).($willBeInlined ? "\n" : ''); } } @@ -181,4 +190,16 @@ private function getBlockIndentationIndicator(string $value): string return ''; } + + private function isSimpleInlineMap(array $value): bool + { + foreach ($value as $v) { + if (\is_array($v) || $v instanceof TaggedValue) { + return false; + } + } + + return true; + } + }