Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Description
Right now YAML component dumps an empty array like this:$dump = array('test' => array()); astest: { }. In some applications that use the YAML it needs to betest: [ ] a list instead of a hash.
In the symfony codebase on this line (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Yaml/Inline.php#L160) I found:
$keys = array_keys($value); if ((1 == count($keys) && '0' == $keys[0]) || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) ) {It looks to me if I pass$dump = array('test' => array('0' => '')) It should work? However this code outputs:test: - ''. Its successfully using the list format but its passing the blank value. I think another conditional is missing to be able to create:test: [ ]. I checked the unit tests and I can't find anywhere that explains what(1 == count($keys) && '0' == $keys[0]) was intended for other than this purpose.
EDIT: It doesn't look to be hitting that section of code at all since my indent level is really high. However I am still tring to figure out how to get it to output a[ ] instead of hash{ } since it is invalid yaml for what I am using it for and a blank array defaults to the hash.