-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Added note on YAML mappings as objects #6590
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,20 @@ error if something goes wrong by adding the filename to the message. | |
|
||
.. _components-yaml-dump: | ||
|
||
Objects for Mappings | ||
.................... | ||
|
||
.. versionadded:: 2.7 | ||
Support for parsing mappings as objects was introduced in Symfony 2.6. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was added in 2.7. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it was added to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should prefer the static API (see #6598) so using 2.7 here is the best idea imo. |
||
|
||
Yaml :ref:`mappings <yaml-format-collections>` are basically associative | ||
arrays. You can instruct the parser to return mappings as objects (i.e. | ||
``\stdClass`` instances) by setting the fourth argument to ``true``:: | ||
|
||
$object = Yaml::parse('{"foo": "bar"}', false, false, true); | ||
echo get_class($object); // stdClass | ||
echo $object->foo; // bar | ||
|
||
Writing YAML Files | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
|
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.
2.5?
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.
2.6 :)
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.
So it was added to
Parser#parse
in2.6
but toYaml::parse
in 2.7. Kept the note at 2.7 as I guessYaml
is the main entry point.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.
Ah indeed, this was a bit inconsistent. But as we should prefer the static API 2.7 is a good choice here.