-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documented the missing YAML flags #9205
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
components/yaml.rst
Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 3.2 | ||
Support for parsing and dumping objectas as maps was introduced in Symfony 3.2. |
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.
objects
components/yaml.rst
Outdated
$object->foo = 'bar'; | ||
|
||
$dumped = Yaml::dump(array('data' => $object), 2, 4, Yaml::DUMP_OBJECT_AS_MAP); | ||
// $dumped = "data:\nfoo:\nSbar" |
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.
data:\n foo:\nbar
because of the indentation, right?
components/yaml.rst
Outdated
|
||
$parsed = Yaml::parse($dumped, Yaml::PARSE_OBJECT); | ||
var_dump(is_object($parsed)); // true | ||
echo $parsed->foo; // bar |
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.
if $dumped
has the same value as above, we would need to account for data
here or omit it above while dumping
@xabbuh thanks for the review. To be 100% sure about the code, I created an snippet and run it to double check the results. |
This finishes #6226.