Skip to content

Commit

Permalink
bug #33377 [Yaml] fix dumping not inlined scalar tag values (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[Yaml] fix dumping not inlined scalar tag values

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #33354
| License       | MIT
| Doc PR        |

Commits
-------

390f4f4 fix dumping not inlined scalar tag values
  • Loading branch information
xabbuh committed Aug 29, 2019
2 parents c08b42a + 390f4f4 commit b3cf4fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Yaml/Dumper.php
Expand Up @@ -120,6 +120,10 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
} else {
$output .= "\n";
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);

if (is_scalar($value->getValue())) {
$output .= "\n";
}
}

continue;
Expand Down
17 changes: 17 additions & 0 deletions src/Symfony/Component/Yaml/Tests/DumperTest.php
Expand Up @@ -525,6 +525,23 @@ public function testDumpingTaggedValueMapWithInlinedTagValues()
$this->assertSame($expected, $yaml);
}

public function testDumpingNotInlinedScalarTaggedValue()
{
$data = [
'user1' => new TaggedValue('user', 'jane'),
'user2' => new TaggedValue('user', 'john'),
];
$expected = <<<YAML
user1: !user
jane
user2: !user
john
YAML;

$this->assertSame($expected, $this->dumper->dump($data, 2));
}

public function testDumpMultiLineStringAsScalarBlock()
{
$data = [
Expand Down

0 comments on commit b3cf4fb

Please sign in to comment.