You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\Symfony\Component\Yaml\Dumper::dump only checks for leading spaces when deciding whether to add a block indentation indicator. If the value begins with a newline followed by spaces then the indicator isn't added.
// Create dumper with 2-space indentation.$dumper = new \Symfony\Component\Yaml\Dumper(2);
// Prepare value beginning with newline followed by four spaces.$data = ['key' => "\n multiline value\nwith leading newline\nfollowed by spaces"];
// Dump the value to YAML.$dumper->dump($data2, 1, 0, \Symfony\Component\Yaml\Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
Result:
key: |- multiline value with leading newline followed by spaces
Expected result:
key: |2- multiline value with leading newline followed by spaces
Possible Solution
Remove leading newlines when determining the value of $blockIndentationIndicator.