Skip to content

Update yaml component docs for 2.3 Yaml::parse(filename) deprecation #2620

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 1 commit into from
Closed
Changes from all 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
13 changes: 11 additions & 2 deletions components/yaml/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,29 @@ error occurred:
As the parser is re-entrant, you can use the same parser object to load
different YAML strings.

When loading a YAML file, it is sometimes better to use the
It may also be convenient to use the
:method:`Symfony\\Component\\Yaml\\Yaml::parse` wrapper method:

.. code-block:: php

use Symfony\Component\Yaml\Yaml;

$yaml = Yaml::parse('/path/to/file.yml');
$yaml = Yaml::parse(file_get_contents('/path/to/file.yml'));

The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML
string or a file containing YAML. Internally, it calls the
:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but enhances the
error if something goes wrong by adding the filename to the message.

.. note::
Copy link
Member

Choose a reason for hiding this comment

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

I suggest a .. caution:: directive


Although it is currently possible to pass the
:method:`Symfony\\Component\\Yaml\\Yaml::parse` static method a
filename, this functionality is deprecated in Symfony 2.3, and will be
removed in Symfony 3.0. Because it is possible to pass a filename, if
you use this method, you must validate the input first.


Writing YAML Files
~~~~~~~~~~~~~~~~~~

Expand Down