Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

javiereguiluz
Copy link
Member

This finishes #6226.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 3.2
Support for parsing and dumping objectas as maps was introduced in Symfony 3.2.
Copy link
Member

Choose a reason for hiding this comment

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

objects

$object->foo = 'bar';

$dumped = Yaml::dump(array('data' => $object), 2, 4, Yaml::DUMP_OBJECT_AS_MAP);
// $dumped = "data:\nfoo:\nSbar"
Copy link
Member

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?


$parsed = Yaml::parse($dumped, Yaml::PARSE_OBJECT);
var_dump(is_object($parsed)); // true
echo $parsed->foo; // bar
Copy link
Member

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

@javiereguiluz
Copy link
Member Author

@xabbuh thanks for the review. To be 100% sure about the code, I created an snippet and run it to double check the results.

javiereguiluz added a commit that referenced this pull request Feb 7, 2018
This PR was squashed before being merged into the 3.4 branch (closes #9205).

Discussion
----------

Documented the missing YAML flags

This finishes #6226.

Commits
-------

6ecf051 Documented the missing YAML flags
@javiereguiluz javiereguiluz mentioned this pull request Feb 7, 2018
7 tasks
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.

3 participants