bug #33377 [Yaml] fix dumping not inlined scalar tag values (xabbuh)

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
-------

390f4f4329 fix dumping not inlined scalar tag values
This commit is contained in:
Christian Flothmann 2019-08-29 12:29:31 +02:00
commit b3cf4fb192
2 changed files with 21 additions and 0 deletions

View File

@ -120,6 +120,10 @@ class Dumper
} 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;

View File

@ -525,6 +525,23 @@ YAML;
$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 = [