Skip to content

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

Merged
merged 2 commits into from
Oct 29, 2017
Merged

Conversation

javiereguiluz
Copy link
Member

This fixes #8424.

@xabbuh xabbuh added this to the 3.4 milestone Oct 28, 2017

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.
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

see #8554

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'");
Copy link
Member

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');

~~~~~~~~~~~~~~~~~~

The :method:`Symfony\\Component\\Yaml\\Yaml::parseFile` method parses the YAML
contents of the given file path and converts them to a PHP array:
Copy link
Member

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

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
Copy link
Member

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


use Symfony\Component\Yaml\Yaml;

$value = Yaml::parseFile(file_get_contents('/path/to/file.yml'));
Copy link
Member

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

@weaverryan
Copy link
Member

Thank you @javiereguiluz.

@weaverryan weaverryan merged commit 647c117 into symfony:3.4 Oct 29, 2017
weaverryan added a commit that referenced this pull request Oct 29, 2017
This PR was squashed before being merged into the 3.4 branch (closes #8523).

Discussion
----------

Documented the new parseFile() method

This fixes #8424.

Commits
-------

647c117 Fixes
b55b03a Documented the new parseFile() method

use Symfony\Component\Yaml\Yaml;

$value = Yaml::parseFile('/path/to/file.yml');
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, you're right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants