Skip to content

Commit

Permalink
[Yaml] removed support for YAML 1.1 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 14, 2011
1 parent 3859589 commit a9dab71
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 84 deletions.
17 changes: 3 additions & 14 deletions src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -68,9 +68,6 @@ static public function parse($value)
*/
static public function dump($value)
{
$trueValues = '1.1' == Yaml::getSpecVersion() ? array('true', 'on', '+', 'yes', 'y') : array('true');
$falseValues = '1.1' == Yaml::getSpecVersion() ? array('false', 'off', '-', 'no', 'n') : array('false');

switch (true) {
case is_resource($value):
throw new Exception('Unable to dump PHP resources in a YAML file.');
Expand All @@ -95,12 +92,7 @@ static public function dump($value)
case '' == $value:
return "''";
case preg_match(self::getTimestampRegex(), $value):
return "'$value'";
case in_array(strtolower($value), $trueValues):
return "'$value'";
case in_array(strtolower($value), $falseValues):
return "'$value'";
case in_array(strtolower($value), array('null', '~')):
case in_array(strtolower($value), array('null', '~', 'true', 'false')):
return "'$value'";
default:
return $value;
Expand Down Expand Up @@ -340,9 +332,6 @@ static private function evaluateScalar($scalar)
{
$scalar = trim($scalar);

$trueValues = '1.1' == Yaml::getSpecVersion() ? array('true', 'on', '+', 'yes', 'y') : array('true');
$falseValues = '1.1' == Yaml::getSpecVersion() ? array('false', 'off', '-', 'no', 'n') : array('false');

switch (true) {
case 'null' == strtolower($scalar):
case '' == $scalar:
Expand All @@ -359,9 +348,9 @@ static private function evaluateScalar($scalar)
$cast = intval($scalar);

return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
case in_array(strtolower($scalar), $trueValues):
case 'true' === strtolower($scalar):
return true;
case in_array(strtolower($scalar), $falseValues):
case 'false' === strtolower($scalar):
return false;
case is_numeric($scalar):
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
Expand Down
28 changes: 0 additions & 28 deletions src/Symfony/Component/Yaml/Yaml.php
Expand Up @@ -20,34 +20,6 @@
*/
class Yaml
{
static private $spec = '1.2';

/**
* Sets the YAML specification version to use.
*
* @param string $version The YAML specification version
*
* @throws \InvalidArgumentException When version of YAML specs is not supported
*/
static public function setSpecVersion($version)
{
if (!in_array($version, array('1.1', '1.2'))) {
throw new \InvalidArgumentException(sprintf('Version %s of the YAML specifications is not supported', $version));
}

self::$spec = $version;
}

/**
* Gets the YAML specification version to use.
*
* @return string The YAML specification version
*/
static public function getSpecVersion()
{
return self::$spec;
}

/**
* Parses YAML into a PHP array.
*
Expand Down
5 changes: 0 additions & 5 deletions tests/Symfony/Tests/Component/Yaml/DumperTest.php
Expand Up @@ -21,11 +21,6 @@ class DumperTest extends \PHPUnit_Framework_TestCase
protected $dumper;
protected $path;

static public function setUpBeforeClass()
{
Yaml::setSpecVersion('1.1');
}

protected function setUp()
{
$this->parser = new Parser();
Expand Down
Expand Up @@ -542,8 +542,8 @@ test: Miscellaneous
spec: 2.21
yaml: |
null: ~
true: y
false: n
true: true
false: false
string: '12345'
php: |
array(
Expand Down Expand Up @@ -1519,7 +1519,7 @@ test: Boolean
yaml: |
false: used as key
logical: true
answer: no
answer: false
php: |
array(
false => 'used as key',
Expand Down
24 changes: 0 additions & 24 deletions tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml
Expand Up @@ -32,45 +32,21 @@ brief: >
Boolean
yaml: |
- false
- -
- off
- no
- true
- +
- on
- yes
- null
- ~
- 'false'
- '-'
- 'off'
- 'no'
- 'true'
- '+'
- 'on'
- 'yes'
- 'null'
- '~'
php: |
array(
false,
false,
false,
false,
true,
true,
true,
true,
null,
null,
'false',
'-',
'off',
'no',
'true',
'+',
'on',
'yes',
'null',
'~',
)
Expand Down
5 changes: 0 additions & 5 deletions tests/Symfony/Tests/Component/Yaml/InlineTest.php
Expand Up @@ -16,11 +16,6 @@

class InlineTest extends \PHPUnit_Framework_TestCase
{
static public function setUpBeforeClass()
{
Yaml::setSpecVersion('1.1');
}

public function testParse()
{
foreach ($this->getTestsForParse() as $yaml => $value) {
Expand Down
5 changes: 0 additions & 5 deletions tests/Symfony/Tests/Component/Yaml/ParserTest.php
Expand Up @@ -20,11 +20,6 @@ class ParserTest extends \PHPUnit_Framework_TestCase
protected $parser;
protected $path;

static public function setUpBeforeClass()
{
Yaml::setSpecVersion('1.1');
}

protected function setUp()
{
$this->parser = new Parser();
Expand Down

0 comments on commit a9dab71

Please sign in to comment.