Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Added note on YAML mappings as objects#6590
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
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 | ||
Contributor 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. 2.5? ContributorAuthor 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. 2.6 :) ContributorAuthor 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. So it was added to Member 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. Ah indeed, this was a bit inconsistent. But as we should prefer the static API 2.7 is a good choice here. | ||
| Support for parsing mappings as objects was introduced in Symfony 2.6. | ||
Member 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. ContributorAuthor 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 Member 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 | ||
| ~~~~~~~~~~~~~~~~~~ | ||