Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Yaml] add option to dump objects as maps #17728

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

Merged
merged 1 commit into from
Feb 28, 2016
Merged

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Feb 8, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #9870, #12860, #15781, #15937, #16266
License MIT
Doc PR symfony/symfony-docs#6226

@xabbuh
Copy link
Member Author

xabbuh commented Feb 8, 2016

I am not convinced that we should do this for all objects. Maybe it would be better to only support this option for stdClass instances.

@stof
Copy link
Member

stof commented Feb 9, 2016

I agree that it should not be done for any object. It makes sense for stdClass, ArrayObject, and maybe other Traversable objects.

DateTime and DateTimeImmutable should be better dumped as a Yaml timestamp (with a parser flag to parse timestamps as a DateTime rather than as an integer too btw)

@@ -112,6 +112,8 @@ public static function dump($value, $exceptionOnInvalidType = false, $flags = 0)
case is_object($value):
if (Yaml::DUMP_OBJECT & $flags) {
return '!php/object:'.serialize($value);
} elseif (Yaml::DUMP_OBJECT_AS_MAP & $flags) {
Copy link
Member

Choose a reason for hiding this comment

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

just if as the previous if returns

@xabbuh xabbuh force-pushed the issue-12860 branch 3 times, most recently from 393d06d to 80f0b66 Compare February 15, 2016 16:26
@xabbuh
Copy link
Member Author

xabbuh commented Feb 15, 2016

I updated here to have the mapping only work with stdClass and ArrayObject instances instead of each and every kind of object.

@xabbuh
Copy link
Member Author

xabbuh commented Feb 17, 2016

see #17836 for the DateTime support

@fabpot
Copy link
Member

fabpot commented Feb 26, 2016

This one needs to be rebased

@xabbuh
Copy link
Member Author

xabbuh commented Feb 27, 2016

rebased, failures are unrelated

@fabpot
Copy link
Member

fabpot commented Feb 28, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit 3941d2e into symfony:master Feb 28, 2016
fabpot added a commit that referenced this pull request Feb 28, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[Yaml] add option to dump objects as maps

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9870, #12860, #15781, #15937, #16266
| License       | MIT
| Doc PR        | TODO

Commits
-------

3941d2e [Yaml] add option to dump objects as maps
@xabbuh xabbuh deleted the issue-12860 branch February 28, 2016 10:13
@xabbuh xabbuh mentioned this pull request Mar 1, 2016
7 tasks
@fabpot fabpot mentioned this pull request May 13, 2016
nicolas-grekas added a commit that referenced this pull request Apr 12, 2017
…bbuh)

This PR was merged into the 3.2 branch.

Discussion
----------

[Yaml] add changelog for the DUMP_OBJECT_AS_MAP flag

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17728
| License       | MIT
| Doc PR        |

Adds missing changelog entry for the `DUMP_OBJECT_AS_MAP` flag introduced in #17728.

Commits
-------

8fd3602 add changelog for the DUMP_OBJECT_AS_MAP flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants