[Yaml] renamed load() to parse()

This commit is contained in:
Fabien Potencier 2011-06-14 12:19:35 +02:00
parent 9b1b9373b8
commit 3859589daa
9 changed files with 20 additions and 18 deletions

View File

@ -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.

View File

@ -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);
}
/**

View File

@ -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));

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}
/**

View File

@ -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:
* <code>
* $array = Yaml::load('config.yml');
* $array = Yaml::parse('config.yml');
* print_r($array);
* </code>
*
@ -68,7 +68,7 @@ class Yaml
*
* @api
*/
static public function load($input)
static public function parse($input)
{
$file = '';

View File

@ -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(
'' => '',