Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletionscomponents/yaml/introduction.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

2.5?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

2.6 :)

HeahDude reacted with laugh emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

So it was added toParser#parse in2.6 but toYaml::parse in 2.7. Kept the note at 2.7 as I guessYaml is the main entry point.

xabbuh reacted with thumbs up emoji
Copy link
Member

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.

Support for parsing mappings as objects was introduced in Symfony 2.6.
Copy link
Member

Choose a reason for hiding this comment

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

It was added in 2.7.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hmm, it was added toParser in 2.6 and andYaml::parse in 2.7 :/

Copy link
Member

Choose a reason for hiding this comment

The 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
~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletionscomponents/yaml/yaml_format.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,6 +165,8 @@ YAML uses the ISO-8601 standard to express dates:
# simple date
2002-12-14

.. _yaml-format-collections:

Collections
-----------

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp