8000 bug #20732 fix the inline level for dumped multi-line strings (xabbuh) · src-run/symfony@b699e4b · GitHub
[go: up one dir, main page]

Skip to content

Commit b699e4b

Browse files
committed
bug symfony#20732 fix the inline level for dumped multi-line strings (xabbuh)
This PR was merged into the 3.1 branch. Discussion ---------- fix the inline level for dumped multi-line strings | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#20706 | License | MIT | Doc PR | Commits ------- 5269796 fix the inline level for dumped multi-line strings
2 parents b9ed4bf + 5269796 commit b699e4b

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