dump function ignore inline parameter when using TaggedValue

Viewed 70

I have an issue with Yaml::Dump() function. when I use TaggedValue, dump function is ignoring parameter $inline

If I'm not using TaggedValues, it's working as expected.

This is example code used

 use Symfony\Component\Yaml\Yaml;
 use Symfony\Component\Yaml\Tag\TaggedValue;

$Admins = array(
        array(
            'samaccountname' => ['user1'],
            'cn' => ['Louisa Nicolas'],
            'mail' => ['mail@domain.com'],
        ),
        array(
            'samaccountname' => ['user2'],
            'cn' => ['Telper Max'],
            'mail' => ['mail@domain.com'],
        )
    );

    $rootYaml = array();
    foreach ($Admins as $Admin) {
        $adm = array(
            'id' => $Admin['samaccountname'][0],
            'annotations' => array(
                'name' => $Admin['cn'][0],
                'email' => $Admin['mail'][0]
        ));
        $rootYaml[] = $adm;
        $rootYamlTagged[] = new TaggedValue('user', $adm);
    }
    echo "##### Works without tags\n";
    print Yaml::dump($rootYaml, 3);
    echo "##### not working with tags\n";
    print Yaml::dump($rootYamlTagged, 3);

Result :

##### Works without tags
-
    id: user1
    annotations:
        name: 'Louisa Nicolas'
        email: mail@domain.com
-
    id: user2
    annotations:
        name: 'Telper Max'
        email: mail@domain.com
##### not working with tags
- !user { id: user1, annotations: { name: 'Louisa Nicolas', email: mail@domain.com } }
- !user { id: user2, annotations: { name: 'Telper Max', email: mail@domain.com } }

I would expect to have for tagged

- !user 
  id: user1, 
  annotations: 
    name: 'Louisa Nicolas'
    email: mail@domain.com
- !user
  id: user2
  annotations: 
    name: 'Telper Max'
    email: mail@domain.com 

I opened a bug for that on support team, and bug was confirmed.

Yaml dump : ignore inline parameter when TaggedValue used

1 Answers
Related