Skip to content

Commit 24075a7

Browse files
Merge branch '3.4' into 4.3
* 3.4: Update GitHub PR template don't dump a scalar tag value on its own line
2 parents 9973789 + 768f817 commit 24075a7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Dumper.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
8080
if ($value instanceof TaggedValue) {
8181
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
8282

83-
if ($inline - 1 <= 0) {
83+
if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) {
8484
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
8585
} else {
8686
$output .= "\n";
8787
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
88-
89-
if (is_scalar($value->getValue())) {
90-
$output .= "\n";
91-
}
9288
}
9389

9490
continue;

Tests/DumperTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,21 @@ public function testDumpingNotInlinedScalarTaggedValue()
466466
'user2' => new TaggedValue('user', 'john'),
467467
];
468468
$expected = <<<YAML
469-
user1: !user
470-
jane
471-
user2: !user
472-
john
469+
user1: !user jane
470+
user2: !user john
471+
472+
YAML;
473+
474+
$this->assertSame($expected, $this->dumper->dump($data, 2));
475+
}
476+
477+
public function testDumpingNotInlinedNullTaggedValue()
478+
{
479+
$data = [
480+
'foo' => new TaggedValue('bar', null),
481+
];
482+
$expected = <<<YAML
483+
foo: !bar null
473484
474485
YAML;
475486

0 commit comments

Comments
 (0)