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
This commit is contained in:
commit
b699e4b77b
@ -88,7 +88,7 @@ class Dumper
|
||||
$isAHash = Inline::isHash($input);
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if ($inline > 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
|
||||
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
|
||||
$output .= sprintf("%s%s%s |\n", $prefix, $isAHash ? Inline::dump($key, $flags).':' : '-', '');
|
||||
|
||||
foreach (preg_split('/\n|\r\n/', $value) as $row) {
|
||||
|
@ -342,7 +342,7 @@ EOF;
|
||||
),
|
||||
);
|
||||
|
||||
$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));
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,5 +10,4 @@ data:
|
||||
empty line:
|
||||
|
||||
baz
|
||||
nested_inlined_multi_line_string:
|
||||
inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz"
|
||||
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
|
||||
|
Reference in New Issue
Block a user