Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b699e4b

Browse filesBrowse files
committed
bug #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 | #20706 | License | MIT | Doc PR | Commits ------- 5269796 fix the inline level for dumped multi-line strings
2 parents b9ed4bf + 5269796 commit b699e4b
Copy full SHA for b699e4b

File tree

3 files changed

+3
-4
lines changed
Filter options

3 files changed

+3
-4
lines changed

‎src/Symfony/Component/Yaml/Dumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Dumper.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/DumperTest.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
+1-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.