Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromxabbuh:issue-16236
Mar 1, 2016

Conversation

@xabbuh
Copy link
Member

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#16236,#16604,#17912,#17391
LicenseMIT
Doc PRsymfony/symfony-docs#6226

$prefix,
str_repeat('',$this->indentation),
$dumpedRow
);
Copy link
Member

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.

@fabpot
Copy link
Member

👍

$isAHash =array_keys($input) !==range(0,count($input) -1);

foreach ($inputas$key =>$value) {
if ($inline -1 >0 && Yaml::DUMP_MULTI_LINE_AS_BLOCK &$flags &&is_string($value) &&false !==strpos($value,"\n")) {
Copy link
Member

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)

@xabbuhxabbuhforce-pushed theissue-16236 branch 4 times, most recently from7175f64 tob438a68CompareMarch 1, 2016 15:32
@xabbuh
Copy link
MemberAuthor

I would like to rename theDUMP_MULTI_LINE_AS_BLOCK constant toDUMP_MULTI_LINE_LITERAL_BLOCK. What do you think?

@fabpot
Copy link
Member

The rename sounds like a good idea to me.

@xabbuh
Copy link
MemberAuthor

I renamed the constant and added a changelog entry. This is ready for the final review.

@stof
Copy link
Member

stof commentedMar 1, 2016

👍

We will need a doc PR for that though

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commiteff6902 intosymfony:masterMar 1, 2016
fabpot added a commit that referenced this pull requestMar 1, 2016
…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        | TODOCommits-------eff6902 option to dump multi line strings as scalar blocks
@xabbuhxabbuh deleted the issue-16236 branchMarch 1, 2016 17:34
@schorsch3000
Copy link

Hi,
nice to see someone worked on that, thanks :)

i'm not sure if i'm doing something horrible wrong of if there is something buggy.
i'm requiring "symfony/yaml": "dev-master" with composer.

Running this simple example

<?phpinclude 'vendor/autoload.php';use Symfony\Component\Yaml\Yaml;$data = ['foo' => 'bar', 'error' => "foo\nbar"];$yaml = Yaml::dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);Yaml::parse($yaml);;

throws

Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException' with message 'Unable to parse at line 3 (near "foo").' in vendor/symfony/yaml/Parser.php on line 321

the resulting string in $yaml is:

foo: barerror: |foobar

foo and bar is not indented, why is that?

Thanks, Dirk

@xabbuh
Copy link
MemberAuthor

@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.

@schorsch3000
Copy link

No problem, if my wishes get fullfilled im fine doing beta-testing :)
Sure, i'll report a bug, i just wanted to know id i did something wrong :)

@xabbuh
Copy link
MemberAuthor

@schorsch3000 Oh wait, I just noticed that you passed0 as the number of spaces to indent. This number must in fact be greater than zero.

@schorsch3000
Copy link

Damn, i've just reported that bug.
yes, with a sane number there everything is fine.
i've copied the call from the test-case:

$this->dumper->dump($data, 3, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));

without thinking about it.
seems this test-case is odd?

@xabbuh
Copy link
MemberAuthor

@schorsch3000 I put some explanation in#17977 (comment).

@xabbuhxabbuh mentioned this pull requestMar 1, 2016
7 tasks
@xabbuh
Copy link
MemberAuthor

@stof I have now added all new YAML features to the list insymfony/symfony-docs#6226.

fabpot added a commit that referenced this pull requestMar 2, 2016
…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
@fabpotfabpot mentioned this pull requestMay 13, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@xabbuh@fabpot@stof@schorsch3000@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp