Skip to content

[Yaml] Parser: Number in TaggedValue becomes a string #46718

Closed
@donquixote

Description

@donquixote

Symfony version(s) affected

6.1.0

Description

Starting with [new TaggedValue('a', 5)], after a round trip through yaml, the number 5 becomes a string '5'.
The problem is clearly with the parser, because the dumped yml code seems correct.

How to reproduce

        $data = [5, new TaggedValue('a', 5)];
        $yaml = $this->dumper->dump($data, 2);
        $expected = <<<YAML
- 5
- !a 5

YAML;
        $this->assertSame($expected, $yaml);  // Pass.
        $this->assertSame($data, $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS));  // Fail.

The standalone 5 survives the round-trip.
The tagged 5 becomes a string.

Possible Solution

Fix the parser. Not sure where exactly.

Additional Context

No response

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