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] Allow dumping empty array as YAML sequence#21471

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 3 commits intosymfony:masterfromc960657:yaml-empty-array
Feb 19, 2017

Conversation

@c960657
Copy link
Contributor

@c960657c960657 commentedJan 31, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#9870,#15937,#16266
LicenseMIT
Doc PR

PHP arrays are dumped as either YAML sequences or mappings, depending on whether the array has continuos integer keys or not.

An empty array is always dumped as a YAML mapping. Sometimes you want it dumped as a YAML sequence instead.

$dump =$this->dumper->dump(array(),9,0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
$this->assertEquals('[]',$dump);

$dump =$this->dumper->dump(new \ArrayObject(),0,0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
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 not expect an empty sequence as the result with this input.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agreed. Fixed.

$dump =$this->dumper->dump(new \ArrayObject(),0,0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
$this->assertEquals('[]',$dump);

$dump =$this->dumper->dump(new \stdClass(),0,0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

same here

@nicolas-grekasnicolas-grekas added this to the3.x milestoneJan 31, 2017
@fabpot
Copy link
Member

@xabbuh I let you merge this one?

@xabbuh
Copy link
Member

@fabpot Sure, can I understand your comment as a +1 vote?

constDUMP_OBJECT_AS_MAP =64;
constDUMP_MULTI_LINE_LITERAL_BLOCK =128;
constPARSE_CONSTANT =256;
constDUMP_EMPTY_ARRAY_AS_SEQUENCE =512;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

alpha order?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do you want me to sort all constants alphabetically? I don't see this convention being used elsewhere in Symfony.

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 keep it this way. Otherwise, it's becoming hard to add new flags as you need to be extra careful to not reuse one of the existing flag values.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can't we change the values of the consts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I like the way it is now, the more recent addition are last with a higher number. I don't see why we should order them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sorry for being late here, but I had no time during the weekend to do the final review. This value must be adjusted as 512 is already used by the new tags support feature (see#21678).

CHANGELOG
=========

3.2.3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

wrong version

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed.

CHANGELOG
=========

3.2.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's still not right. New features are only added in minor versions. So this needs to be3.3.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed again :-)

@fabpot
Copy link
Member

Thank you@c960657.

@fabpotfabpot closed thisFeb 19, 2017
@fabpotfabpot merged commit87ffaf2 intosymfony:masterFeb 19, 2017
fabpot added a commit that referenced this pull requestFeb 19, 2017
…0657)This PR was squashed before being merged into the 3.3-dev branch (closes#21471).Discussion----------[Yaml] Allow dumping empty array as YAML sequence| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#9870,#15937,#16266| License       | MIT| Doc PR        |PHP arrays are dumped as either YAML sequences or mappings, depending on whether the array has continuos integer keys or not.An empty array is always dumped as a YAML mapping. Sometimes you want it dumped as a YAML sequence instead.Commits-------87ffaf2 Bump version numberaf7067c Dump empty object as mappinga6d94c1 [Yaml] Allow dumping empty array as YAML sequence
@nicolas-grekasnicolas-grekas modified the milestones:3.x,3.3Mar 24, 2017
@fabpotfabpot mentioned this pull requestMay 1, 2017
@c960657c960657 deleted the yaml-empty-array branchMay 22, 2017 08:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@c960657@fabpot@xabbuh@nicolas-grekas@stof

[8]ページ先頭

©2009-2025 Movatter.jp