Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7dee89b

Browse filesBrowse files
committed
feature #13129 [Yaml] Removed the ability to parse a file in Yaml::parse() (saro0h)
This PR was merged into the 3.0-dev branch. Discussion ---------- [Yaml] Removed the ability to parse a file in Yaml::parse() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- e1c19f8 [Yaml] Removed the ability to parse a file in Yaml::parse()
2 parents d6af4d6 + e1c19f8 commit 7dee89b
Copy full SHA for 7dee89b

File tree

2 files changed

+2
-38
lines changed
Filter options

2 files changed

+2
-38
lines changed

‎src/Symfony/Component/Yaml/Tests/YamlTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/YamlTest.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,4 @@ public function testParseAndDump()
2222
$parsed = Yaml::parse($yml);
2323
$this->assertEquals($data, $parsed);
2424
}
25-
26-
public function testParseFromFile()
27-
{
28-
$filename = __DIR__.'/Fixtures/index.yml';
29-
$contents = file_get_contents($filename);
30-
$parsedByFilename = Yaml::parse($filename);
31-
$parsedByContents = Yaml::parse($contents);
32-
$this->assertEquals($parsedByFilename, $parsedByContents);
33-
}
3425
}

‎src/Symfony/Component/Yaml/Yaml.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Yaml.php
+2-29Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,21 @@ class Yaml
3434
* print_r($array);
3535
* </code>
3636
*
37-
* As this method accepts both plain strings and file names as an input,
38-
* you must validate the input before calling this method. Passing a file
39-
* as an input is a deprecated feature and will be removed in 3.0.
40-
*
41-
* @param string $input Path to a YAML file or a string containing YAML
37+
* @param string $input A string containing YAML
4238
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
4339
* @param bool $objectSupport True if object support is enabled, false otherwise
4440
*
4541
* @return array The YAML converted to a PHP array
4642
*
4743
* @throws ParseException If the YAML is not valid
4844
*
49-
* @deprecated The ability to pass file names to Yaml::parse() was deprecated in 2.2 and will be removed in 3.0. Please, pass the contents of the file instead.
50-
*
5145
* @api
5246
*/
5347
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false)
5448
{
55-
// if input is a file, process it
56-
$file = '';
57-
if (strpos($input, "\n") === false && is_file($input)) {
58-
trigger_error('The ability to pass file names to Yaml::parse() was deprecated in 2.2 and will be removed in 3.0. Please, pass the contents of the file instead.', E_USER_DEPRECATED);
59-
60-
if (false === is_readable($input)) {
61-
throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
62-
}
63-
64-
$file = $input;
65-
$input = file_get_contents($file);
66-
}
67-
6849
$yaml = new Parser();
6950

70-
try {
71-
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
72-
} catch (ParseException $e) {
73-
if ($file) {
74-
$e->setParsedFile($file);
75-
}
76-
77-
throw $e;
78-
}
51+
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
7952
}
8053

8154
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.