-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] option to dump multi line strings as scalar blocks #17943
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
Conversation
xabbuh
commented
Feb 27, 2016
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #16236, #16604, #17912, #17391 |
License | MIT |
Doc PR | symfony/symfony-docs#6226 |
$prefix, | ||
str_repeat(' ', $this->indentation), | ||
$dumpedRow | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably on one line.
👍 |
@@ -84,6 +84,30 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0) | |||
$isAHash = array_keys($input) !== range(0, count($input) - 1); | |||
|
|||
foreach ($input as $key => $value) { | |||
if ($inline - 1 > 0 && Yaml::DUMP_MULTI_LINE_AS_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say $inline > 1
, to avoid an operation (even though OPCache might be able to detect this optimization)
7175f64
to
b438a68
Compare
I would like to rename the |
The rename sounds like a good idea to me. |
I renamed the constant and added a changelog entry. This is ready for the final review. |
👍 We will need a doc PR for that though |
Thank you @xabbuh. |
…cks (xabbuh) This PR was merged into the 3.1-dev branch. Discussion ---------- [Yaml] option to dump multi line strings as scalar blocks | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16236, #16604, #17912, #17391 | License | MIT | Doc PR | TODO Commits ------- eff6902 option to dump multi line strings as scalar blocks
Hi, i'm not sure if i'm doing something horrible wrong of if there is something buggy. Running this simple example
throws
the resulting string in $yaml is:
foo and bar is not indented, why is that? Thanks, Dirk |
@schorsch3000 Sorry for that and thank you for testing the new feature. :) Would you mind opening an issue for this? It looks indeed like a bug to me. |
No problem, if my wishes get fullfilled im fine doing beta-testing :) |
@schorsch3000 Oh wait, I just noticed that you passed |
Damn, i've just reported that bug.
without thinking about it. |
@schorsch3000 I put some explanation in #17977 (comment). |
@stof I have now added all new YAML features to the list in symfony/symfony-docs#6226. |
…abbuh) This PR was merged into the 2.3 branch. Discussion ---------- [Yaml] ensure dump indentation to be greather than zero | Q | A | ------------- | --- | Branch | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17943 (comment), #17977 | License | MIT | Doc PR | Commits ------- 3464282 ensure dump indentation to be greather than zero