From 390f4f43294784af0e127c2e682e1668e438630c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 29 Aug 2019 10:14:38 +0200 Subject: [PATCH] fix dumping not inlined scalar tag values --- src/Symfony/Component/Yaml/Dumper.php | 4 ++++ src/Symfony/Component/Yaml/Tests/DumperTest.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 0012df4a35..7f38a5435c 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -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; diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 4646c0c38b..d4554392a2 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -525,6 +525,23 @@ YAML; $this->assertSame($expected, $yaml); } + public function testDumpingNotInlinedScalarTaggedValue() + { + $data = [ + 'user1' => new TaggedValue('user', 'jane'), + 'user2' => new TaggedValue('user', 'john'), + ]; + $expected = <<assertSame($expected, $this->dumper->dump($data, 2)); + } + public function testDumpMultiLineStringAsScalarBlock() { $data = [