Skip to content

Commit a39078c

Browse files
committed
Update yaml component docs to reflect 2.3 Yaml::parse(filename) deprecation
Using a filename as argument to Yaml::parse is deprecated as of 2.3 and will be removed from sf 3.0. Updated the documentation to indicate this, and include the warning from the source about the need to validate the input first. Conflicts: components/yaml/introduction.rst
1 parent 28b0904 commit a39078c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

components/yaml/introduction.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,28 @@ error occurred:
120120
As the parser is re-entrant, you can use the same parser object to load
121121
different YAML strings.
122122

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

126126
.. code-block:: php
127127
128128
use Symfony\Component\Yaml\Yaml;
129129
130-
$yaml = Yaml::parse('/path/to/file.yml');
130+
$yaml = Yaml::parse(file_get_contents('/path/to/file.yml'));
131131
132132
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML
133133
string or a file containing YAML. Internally, it calls the
134134
:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but enhances the
135135
error if something goes wrong by adding the filename to the message.
136136

137+
.. note::
138+
139+
Although it is currently possible to pass the
140+
:method:`Symfony\\Component\\Yaml\\Yaml::parse` static method a
141+
filename, this functionality is deprecated in Symfony 2.3, and will be
142+
removed in Symfony 3.0. Because it is possible to pass a filename, if
143+
you use this method, you must validate the input first.
144+
137145
Executing PHP Inside YAML Files
138146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139147

0 commit comments

Comments
 (0)