@@ -64,14 +64,18 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
6464 $ dumpAsMap = Inline::isHash ($ input );
6565
6666 foreach ($ input as $ key => $ value ) {
67+ if ('' !== $ output && "\n" !== $ output [-1 ]) {
68+ $ output .= "\n" ;
69+ }
70+
6771 if ($ inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $ flags && \is_string ($ value ) && false !== strpos ($ value , "\n" ) && false === strpos ($ value , "\r" )) {
6872 // If the first line starts with a space character, the spec requires a blockIndicationIndicator
6973 // http://www.yaml.org/spec/1.2/spec.html#id2793979
7074 $ blockIndentationIndicator = (' ' === substr ($ value , 0 , 1 )) ? (string ) $ this ->indentation : '' ;
71- $ output .= sprintf (" %s%s%s |%s \n" , $ prefix , $ dumpAsMap ? Inline::dump ($ key , $ flags ).': ' : '- ' , '' , $ blockIndentationIndicator );
75+ $ output .= sprintf (' %s%s%s |%s- ' , $ prefix , $ dumpAsMap ? Inline::dump ($ key , $ flags ).': ' : '- ' , '' , $ blockIndentationIndicator );
7276
7377 foreach (explode ("\n" , $ value ) as $ row ) {
74- $ output .= sprintf ("%s%s%s \n " , $ prefix , str_repeat (' ' , $ this ->indentation ), $ row );
78+ $ output .= sprintf ("\n %s%s%s " , $ prefix , str_repeat (' ' , $ this ->indentation ), $ row );
7579 }
7680
7781 continue ;
@@ -84,10 +88,10 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0):
8488 // If the first line starts with a space character, the spec requires a blockIndicationIndicator
8589 // http://www.yaml.org/spec/1.2/spec.html#id2793979
8690 $ blockIndentationIndicator = (' ' === substr ($ value ->getValue (), 0 , 1 )) ? (string ) $ this ->indentation : '' ;
87- $ output .= sprintf (" |%s \n" , $ blockIndentationIndicator );
91+ $ output .= sprintf (' |%s ' , $ blockIndentationIndicator );
8892
8993 foreach (explode ("\n" , $ value ->getValue ()) as $ row ) {
90- $ output .= sprintf ("%s%s%s \n " , $ prefix , str_repeat (' ' , $ this ->indentation ), $ row );
94+ $ output .= sprintf ("\n %s%s%s " , $ prefix , str_repeat (' ' , $ this ->indentation ), $ row );
9195 }
9296
9397 continue ;
0 commit comments