8000 fix the inline level for dumped multi-line strings · src-run/symfony@5269796 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5269796

Browse files
committed
fix the inline level for dumped multi-line strings
1 parent b9ed4bf commit 5269796

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/Symfony/Component/Yaml/Dumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
8888
$isAHash = Inline::isHash($input);
8989

9090
foreach ($input as $key => $value) {
91-
if ($inline > 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
91+
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
9292
$output .= sprintf("%s%s%s |\n", $prefix, $isAHash ? Inline::dump($key, $flags).':' : '-', '');
9393

9494
foreach (preg_split('/\n|\r\n/', $value) as $row) {

src/Symfony/Component/Yaml/Tests/DumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function testDumpMultiLineStringAsScalarBlock()
342342
),
343343
);
344344

345-
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 3, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
345+
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
346346
}
347347

348348
/**

src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ data:
1010
empty line:
1111
1212
baz
13-
nested_inlined_multi_line_string:
14-
inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz"
13+
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }

0 commit comments

Comments
 (0)
0