8000 [Yaml] Removed the ability to parse a file in Yaml::parse() · symfony/symfony@e1c19f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e1c19f8

Browse files
committed
[Yaml] Removed the ability to parse a file in Yaml::parse()
1 parent d6af4d6 commit e1c19f8

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

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

Lines 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

Lines 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