Skip to content

Yaml dump : ignore inline parameter when TaggedValue used #32251

@abonne01

Description

@abonne01

Symfony version(s) affected: symfony/yaml 4.3

Description

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

How to reproduce

       $rootYaml = array();
        foreach ($Admins as $Admin) {
            $adm = array(
                'id' => $Admin['samaccountname'][0],
                'annotations' => array(
                    'name' => $Admin['cn'][0],
                    'email' => $Admin['mail'][0]
            ));
            $rootYaml[] = new TaggedValue('user', $adm);
        }

        $value = Yaml::dump($rootYaml, 3);

I would expect to have

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

but it's returning

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

Possible bug location
comming from Dumper.php, line 58 on if condition
if ($inline <= 0 || !\is_array($input) || empty($input)) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions