[Yaml] renamed load() to parse()
This commit is contained in:
parent
9b1b9373b8
commit
3859589daa
@ -9,6 +9,8 @@ timeline closely anyway.
|
|||||||
beta4 to beta5
|
beta4 to beta5
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
* `Yaml::load()` has been renamed to `Yaml::parse()`
|
||||||
|
|
||||||
* The `extensions` setting for Twig has been removed. There is now only one
|
* The `extensions` setting for Twig has been removed. There is now only one
|
||||||
way to register Twig extensions, via the `twig.extension` tag.
|
way to register Twig extensions, via the `twig.extension` tag.
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
*/
|
*/
|
||||||
private function loadFile($file)
|
private function loadFile($file)
|
||||||
{
|
{
|
||||||
return $this->validate(Yaml::load($file), $file);
|
return $this->validate(Yaml::parse($file), $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
{
|
{
|
||||||
$path = $this->locator->locate($file);
|
$path = $this->locator->locate($file);
|
||||||
|
|
||||||
$config = Yaml::load($path);
|
$config = Yaml::parse($path);
|
||||||
|
|
||||||
$collection = new RouteCollection();
|
$collection = new RouteCollection();
|
||||||
$collection->addResource(new FileResource($path));
|
$collection->addResource(new FileResource($path));
|
||||||
|
@ -30,7 +30,7 @@ class YamlFileLoader extends ArrayLoader implements LoaderInterface
|
|||||||
*/
|
*/
|
||||||
public function load($resource, $locale, $domain = 'messages')
|
public function load($resource, $locale, $domain = 'messages')
|
||||||
{
|
{
|
||||||
$messages = Yaml::load($resource);
|
$messages = Yaml::parse($resource);
|
||||||
|
|
||||||
// empty file
|
// empty file
|
||||||
if (null === $messages) {
|
if (null === $messages) {
|
||||||
|
@ -29,7 +29,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
public function loadClassMetadata(ClassMetadata $metadata)
|
public function loadClassMetadata(ClassMetadata $metadata)
|
||||||
{
|
{
|
||||||
if (null === $this->classes) {
|
if (null === $this->classes) {
|
||||||
$this->classes = Yaml::load($this->file);
|
$this->classes = Yaml::parse($this->file);
|
||||||
|
|
||||||
// empty file
|
// empty file
|
||||||
if (null === $this->classes) {
|
if (null === $this->classes) {
|
||||||
|
@ -26,7 +26,7 @@ class Inline
|
|||||||
*
|
*
|
||||||
* @return array A PHP array representing the YAML string
|
* @return array A PHP array representing the YAML string
|
||||||
*/
|
*/
|
||||||
static public function load($value)
|
static public function parse($value)
|
||||||
{
|
{
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class Parser
|
|||||||
} else {
|
} else {
|
||||||
// 1-liner followed by newline
|
// 1-liner followed by newline
|
||||||
if (2 == count($this->lines) && empty($this->lines[1])) {
|
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)) {
|
if (is_array($value)) {
|
||||||
$first = reset($value);
|
$first = reset($value);
|
||||||
if (is_string($first) && '*' === substr($first, 0, 1)) {
|
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 $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inline::load($value);
|
return Inline::parse($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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.
|
* will do its best to convert YAML in a file into a PHP array.
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* <code>
|
* <code>
|
||||||
* $array = Yaml::load('config.yml');
|
* $array = Yaml::parse('config.yml');
|
||||||
* print_r($array);
|
* print_r($array);
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
@ -68,7 +68,7 @@ class Yaml
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
static public function load($input)
|
static public function parse($input)
|
||||||
{
|
{
|
||||||
$file = '';
|
$file = '';
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||||||
Yaml::setSpecVersion('1.1');
|
Yaml::setSpecVersion('1.1');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoad()
|
public function testParse()
|
||||||
{
|
{
|
||||||
foreach ($this->getTestsForLoad() as $yaml => $value) {
|
foreach ($this->getTestsForParse() as $yaml => $value) {
|
||||||
$this->assertEquals($value, Inline::load($yaml), sprintf('::load() converts an inline YAML to a PHP structure (%s)', $yaml));
|
$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));
|
$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) {
|
if ($value == 1230) {
|
||||||
continue;
|
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) {
|
foreach ($testsForDump as $yaml => $value) {
|
||||||
@ -49,11 +49,11 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||||||
continue;
|
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(
|
return array(
|
||||||
'' => '',
|
'' => '',
|
||||||
|
Reference in New Issue
Block a user