-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documented the new parseFile() method #8523
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
Conversation
|
||
Because it is currently possible to pass a filename to this method, you | ||
must validate the input first. Passing a filename is deprecated in | ||
Symfony 2.2, and was removed in Symfony 3.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should already remove this block in the 3.3 docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #8554
components/yaml.rst
Outdated
Because it is currently possible to pass a filename to this method, you | ||
must validate the input first. Passing a filename is deprecated in | ||
Symfony 2.2, and was removed in Symfony 3.0. | ||
$value = Yaml::parse("foo:\n 'bar'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having the newline here looks wrong to me, I would just use $value = Yaml::parse('foo: bar');
components/yaml.rst
Outdated
~~~~~~~~~~~~~~~~~~ | ||
|
||
The :method:`Symfony\\Component\\Yaml\\Yaml::parseFile` method parses the YAML | ||
contents of the given file path and converts them to a PHP array: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the result must not necessarily be an array
components/yaml.rst
Outdated
The :method:`Symfony\\Component\\Yaml\\Yaml::parseFile` method parses the YAML | ||
contents of the given file path and converts them to a PHP array: | ||
|
||
.. code-block:: php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be omitted when terminating the previous paragraph with two colons
components/yaml.rst
Outdated
|
||
use Symfony\Component\Yaml\Yaml; | ||
|
||
$value = Yaml::parseFile(file_get_contents('/path/to/file.yml')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_get_contents()
must be omitted here
Thank you @javiereguiluz. |
|
||
use Symfony\Component\Yaml\Yaml; | ||
|
||
$value = Yaml::parseFile('/path/to/file.yml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is not static https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Yaml/Parser.php#L49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is static in the Yaml
class (which is used here): https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Yaml/Yaml.php#L53 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right!
This fixes #8424.