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 f7e80ce

Browse filesBrowse files
committed
[Yaml] Removed the ability to parse a file in Yaml::parse()
1 parent d6af4d6 commit f7e80ce
Copy full SHA for f7e80ce

File tree

Expand file treeCollapse file tree

2 files changed

+1
-33
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+1
-33
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
+1-24Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,23 @@ 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

7051
try {
7152
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
7253
} catch (ParseException $e) {
73-
if ($file) {
74-
$e->setParsedFile($file);
75-
}
76-
7754
throw $e;
7855
}
7956
}

0 commit comments

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