Closed
Description
I executed like below.
$array = ['foo' => ['bar' => [1 => 2, 'baz' => 3]]];
echo Yaml::dump($array);
I expected
foo:
bar: { 1: 2, baz: 3 }
but result is
foo:
bar: [2, 3]
I edited Yaml/Inline.php like below, I got wanted result.
@@ -159,9 +159,7 @@
{
// array
$keys = array_keys($value);
- if ((1 == count($keys) && '0' == $keys[0])
- || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
- ) {
+ if ($keys === range(0, count($keys)-1)) {
$output = array();
foreach ($value as $val) {
$output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);