-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
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 |
I am not convinced that we should do this for all objects. Maybe it would be better to only support this option for |
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) { |
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.
just if
as the previous if returns
393d06d
to
80f0b66
Compare
I updated here to have the mapping only work with |
see #17836 for the |
This one needs to be rebased |
rebased, failures are unrelated |
Thank you @xabbuh. |
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
…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