Skip to content

Commit afce899

Browse files
committed
Merge pull request symfony#2623 from jbafford/i2570-22
Update yaml component docs to reflect Yaml::parse(filename) deprecation
2 parents 436b7fb + 9b1f327 commit afce899

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/yaml/introduction.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,26 @@ 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+
.. caution::
138+
139+
Because it is currently possible to pass a filename to this method, you
140+
must validate the input first. Passing a filename is deprecated in
141+
Symfony 2.2, and will be removed in Symfony 3.0.
142+
137143
Executing PHP Inside YAML Files
138144
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139145

0 commit comments

Comments
 (0)