From 3859589daac0a6562faa81807d2fabfa657bfead Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 14 Jun 2011 12:19:35 +0200 Subject: [PATCH] [Yaml] renamed load() to parse() --- UPDATE.md | 2 ++ .../DependencyInjection/Loader/YamlFileLoader.php | 2 +- .../Component/Routing/Loader/YamlFileLoader.php | 2 +- .../Translation/Loader/YamlFileLoader.php | 2 +- .../Validator/Mapping/Loader/YamlFileLoader.php | 2 +- src/Symfony/Component/Yaml/Inline.php | 2 +- src/Symfony/Component/Yaml/Parser.php | 4 ++-- src/Symfony/Component/Yaml/Yaml.php | 8 ++++---- tests/Symfony/Tests/Component/Yaml/InlineTest.php | 14 +++++++------- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/UPDATE.md b/UPDATE.md index 5a3f08ecce..66812feaa6 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -9,6 +9,8 @@ timeline closely anyway. beta4 to beta5 -------------- +* `Yaml::load()` has been renamed to `Yaml::parse()` + * The `extensions` setting for Twig has been removed. There is now only one way to register Twig extensions, via the `twig.extension` tag. diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index f45659d773..7ae7c44bd9 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -228,7 +228,7 @@ class YamlFileLoader extends FileLoader */ private function loadFile($file) { - return $this->validate(Yaml::load($file), $file); + return $this->validate(Yaml::parse($file), $file); } /** diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index ae83da0680..3ff11a5e62 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -46,7 +46,7 @@ class YamlFileLoader extends FileLoader { $path = $this->locator->locate($file); - $config = Yaml::load($path); + $config = Yaml::parse($path); $collection = new RouteCollection(); $collection->addResource(new FileResource($path)); diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index e57e9b6e92..4ac885b0a2 100755 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -30,7 +30,7 @@ class YamlFileLoader extends ArrayLoader implements LoaderInterface */ public function load($resource, $locale, $domain = 'messages') { - $messages = Yaml::load($resource); + $messages = Yaml::parse($resource); // empty file if (null === $messages) { diff --git a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php index d112977018..2e7058f751 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php @@ -29,7 +29,7 @@ class YamlFileLoader extends FileLoader public function loadClassMetadata(ClassMetadata $metadata) { if (null === $this->classes) { - $this->classes = Yaml::load($this->file); + $this->classes = Yaml::parse($this->file); // empty file if (null === $this->classes) { diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 484ae35eda..0db5e80579 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -26,7 +26,7 @@ class Inline * * @return array A PHP array representing the YAML string */ - static public function load($value) + static public function parse($value) { $value = trim($value); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 4eab2b40cf..8e08dc5c7f 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -168,7 +168,7 @@ class Parser } else { // 1-liner followed by newline if (2 == count($this->lines) && empty($this->lines[1])) { - $value = Inline::load($this->lines[0]); + $value = Inline::parse($this->lines[0]); if (is_array($value)) { $first = reset($value); if (is_string($first) && '*' === substr($first, 0, 1)) { @@ -350,7 +350,7 @@ class Parser return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); } - return Inline::load($value); + return Inline::parse($value); } /** diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 6cbd85a4d0..36fbb364d8 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -49,14 +49,14 @@ class Yaml } /** - * Loads YAML into a PHP array. + * Parses YAML into a PHP array. * - * The load method, when supplied with a YAML stream (string or file), + * The parse method, when supplied with a YAML stream (string or file), * will do its best to convert YAML in a file into a PHP array. * * Usage: * - * $array = Yaml::load('config.yml'); + * $array = Yaml::parse('config.yml'); * print_r($array); * * @@ -68,7 +68,7 @@ class Yaml * * @api */ - static public function load($input) + static public function parse($input) { $file = ''; diff --git a/tests/Symfony/Tests/Component/Yaml/InlineTest.php b/tests/Symfony/Tests/Component/Yaml/InlineTest.php index dd5b32bf65..cb56503bf6 100644 --- a/tests/Symfony/Tests/Component/Yaml/InlineTest.php +++ b/tests/Symfony/Tests/Component/Yaml/InlineTest.php @@ -21,10 +21,10 @@ class InlineTest extends \PHPUnit_Framework_TestCase Yaml::setSpecVersion('1.1'); } - public function testLoad() + public function testParse() { - foreach ($this->getTestsForLoad() as $yaml => $value) { - $this->assertEquals($value, Inline::load($yaml), sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml)); + foreach ($this->getTestsForParse() as $yaml => $value) { + $this->assertEquals($value, Inline::parse($yaml), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml)); } } @@ -36,12 +36,12 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml)); } - foreach ($this->getTestsForLoad() as $yaml => $value) { + foreach ($this->getTestsForParse() as $yaml => $value) { if ($value == 1230) { continue; } - $this->assertEquals($value, Inline::load(Inline::dump($value)), 'check consistency'); + $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } foreach ($testsForDump as $yaml => $value) { @@ -49,11 +49,11 @@ class InlineTest extends \PHPUnit_Framework_TestCase continue; } - $this->assertEquals($value, Inline::load(Inline::dump($value)), 'check consistency'); + $this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency'); } } - protected function getTestsForLoad() + protected function getTestsForParse() { return array( '' => '',