Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Multiline string as scalar block for tagged values #34450

Closed
natepage opened this issue Nov 19, 2019 · 1 comment
Closed

[YAML] Multiline string as scalar block for tagged values #34450

natepage opened this issue Nov 19, 2019 · 1 comment

Comments

@natepage
Copy link
Contributor

natepage commented Nov 19, 2019

Symfony version(s) affected: 3.4 to latest

Description
The Yaml component is able to parse scalar bock for tagged values:

foo: !bar |
    foo
    another line

If parse the above YAML string you will get the expected TaggedValue containing the string with line breaks, amazing!

However if you try to dump a PHP value to this YAML string you are not getting the intended output but the following:

foo: !bar "foo\nanother line"

And that's because the parsing tag Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK isn't used for tagged value.

How to reproduce
Try to dump a PHP value containing a TaggedValue with a string with line breaks as a value while the tag Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK is passed.

use Symfony\Component\Yaml\Tag\TaggedValue;
use Symfony\Component\Yaml\Yaml;

$php = ['foo' => new TaggedValue('bar', "foo\nanother line")];
$yaml = Yaml::dump($php, 1, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);

Possible Solution
If this is identified as a legit issue, I've created a PR to fix it. #34449

@fancyweb
Copy link
Contributor

Can you please close the issue as your PR was merged? Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants