Skip to content

Commit 717182d

Browse files
committed
fix dumping not inlined scalar tag values
1 parent 3dc414b commit 717182d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Dumper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
120120
} else {
121121
$output .= "\n";
122122
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
123+
124+
if (is_scalar($value->getValue())) {
125+
$output .= "\n";
126+
}
123127
}
124128

125129
continue;

Tests/DumperTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,23 @@ public function testDumpingTaggedValueMapWithInlinedTagValues()
525525
$this->assertSame($expected, $yaml);
526526
}
527527

528+
public function testDumpingNotInlinedScalarTaggedValue()
529+
{
530+
$data = [
531+
'user1' => new TaggedValue('user', 'jane'),
532+
'user2' => new TaggedValue('user', 'john'),
533+
];
534+
$expected = <<<YAML
535+
user1: !user
536+
jane
537+
user2: !user
538+
john
539+
540+
YAML;
541+
542+
$this->assertSame($expected, $this->dumper->dump($data, 2));
543+
}
544+
528545
public function testDumpMultiLineStringAsScalarBlock()
529546
{
530547
$data = [

0 commit comments

Comments
 (0)