From 664c655404c7acbbeafbfa9d1b56b3c58f13f7af Mon Sep 17 00:00:00 2001 From: Vitaly Yakubenko Date: Tue, 27 Dec 2016 20:20:02 +0500 Subject: [PATCH 1/5] Add parseFile method --- src/Symfony/Component/Yaml/Yaml.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 46e6ef5c17a83..92dfb89412f46 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -79,6 +79,29 @@ public static function parse($input, $flags = 0) return $yaml->parse($input, $flags); } + /** + * Parses YAML file into a PHP value. + * + * Usage: + * + * $array = Yaml::parseFile('config.yml'); + * print_r($array); + * + * + * @param string $fileName A file containing YAML + * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior + * + * @return mixed The YAML converted to a PHP value + * + * @throws ParseException If the YAML is not valid + */ + public static function parseFile ($fileName, $flags = 0) + { + $input = file_get_contents($fileName); + + return self::parse($input, $flags = 0); + } + /** * Dumps a PHP value to a YAML string. * From 039241adfc2a48dfbbade04539c305be40822a22 Mon Sep 17 00:00:00 2001 From: lostcodder Date: Tue, 27 Dec 2016 20:45:15 +0500 Subject: [PATCH 2/5] Update Yaml.php --- src/Symfony/Component/Yaml/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 92dfb89412f46..751687bc1e340 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -95,7 +95,7 @@ public static function parse($input, $flags = 0) * * @throws ParseException If the YAML is not valid */ - public static function parseFile ($fileName, $flags = 0) + public static function parseFile($fileName, $flags = 0) { $input = file_get_contents($fileName); From 8438d22ad9274f56f6d25ff2bae1bf26aa154293 Mon Sep 17 00:00:00 2001 From: lostcodder Date: Tue, 27 Dec 2016 21:01:17 +0500 Subject: [PATCH 3/5] Update Yaml.php --- src/Symfony/Component/Yaml/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 751687bc1e340..063f2d93d16f4 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -99,7 +99,7 @@ public static function parseFile($fileName, $flags = 0) { $input = file_get_contents($fileName); - return self::parse($input, $flags = 0); + return self::parse($input, $flags); } /** From 5d7caf0e3803e5471876e753193ef85193509344 Mon Sep 17 00:00:00 2001 From: lostcodder Date: Tue, 27 Dec 2016 21:06:28 +0500 Subject: [PATCH 4/5] Update Yaml.php --- src/Symfony/Component/Yaml/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 063f2d93d16f4..e4ecfa1ce992c 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -89,7 +89,7 @@ public static function parse($input, $flags = 0) * * * @param string $fileName A file containing YAML - * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior + * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior * * @return mixed The YAML converted to a PHP value * From 571a39602e6e7571bf078011dc7e7fb37a7b2f6e Mon Sep 17 00:00:00 2001 From: lostcodder Date: Tue, 27 Dec 2016 21:16:41 +0500 Subject: [PATCH 5/5] Update Yaml.php --- src/Symfony/Component/Yaml/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index e4ecfa1ce992c..ea075a23f3425 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -101,7 +101,7 @@ public static function parseFile($fileName, $flags = 0) return self::parse($input, $flags); } - + /** * Dumps a PHP value to a YAML string. *