[Yaml] removed deprecated support of PHP parsin when parsing YAML files
This commit is contained in:
parent
09a5969b89
commit
4e7943fad0
@ -15,7 +15,6 @@ use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testParseAndDump()
|
||||
{
|
||||
$data = array('lorem' => 'ipsum', 'dolor' => 'sit');
|
||||
@ -29,13 +28,4 @@ class YamlTest extends \PHPUnit_Framework_TestCase
|
||||
$parsedByContents = Yaml::parse($contents);
|
||||
$this->assertEquals($parsedByFilename, $parsedByContents);
|
||||
}
|
||||
|
||||
public function testEmbededPhp()
|
||||
{
|
||||
$filename = __DIR__.'/Fixtures/embededPhp.yml';
|
||||
Yaml::enablePhpParsing();
|
||||
$parsed = Yaml::parse($filename);
|
||||
$this->assertEquals(array('value' => 6), $parsed);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,53 +22,6 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
||||
*/
|
||||
class Yaml
|
||||
{
|
||||
/**
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static $enablePhpParsing = false;
|
||||
|
||||
/**
|
||||
* Enables PHP support when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function enablePhpParsing()
|
||||
{
|
||||
self::$enablePhpParsing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP support flag when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @param Boolean $boolean true if PHP parsing support is enabled, false otherwise
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function setPhpParsing($boolean)
|
||||
{
|
||||
self::$enablePhpParsing = (Boolean) $boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if PHP support is enabled when parsing YAML files.
|
||||
*
|
||||
* Be warned that PHP support will be removed in Symfony 2.3.
|
||||
*
|
||||
* @return Boolean true if PHP parsing support is enabled, false otherwise
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3.
|
||||
*/
|
||||
public static function supportsPhpParsing()
|
||||
{
|
||||
return self::$enablePhpParsing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses YAML into a PHP array.
|
||||
*
|
||||
@ -103,21 +56,7 @@ class Yaml
|
||||
}
|
||||
|
||||
$file = $input;
|
||||
if (self::$enablePhpParsing) {
|
||||
ob_start();
|
||||
$retval = include($file);
|
||||
$content = ob_get_clean();
|
||||
|
||||
// if an array is returned by the config file assume it's in plain php form else in YAML
|
||||
$input = is_array($retval) ? $retval : $content;
|
||||
|
||||
// if an array is returned by the config file assume it's in plain php form else in YAML
|
||||
if (is_array($input)) {
|
||||
return $input;
|
||||
}
|
||||
} else {
|
||||
$input = file_get_contents($file);
|
||||
}
|
||||
$input = file_get_contents($file);
|
||||
}
|
||||
|
||||
$yaml = new Parser();
|
||||
|
Reference in New Issue
Block a user