Bläddra i källkod

[Yaml] removed support for YAML 1.1 spec

Fabien Potencier 14 år sedan
förälder
incheckning
a9dab719df

+ 3 - 14
src/Symfony/Component/Yaml/Inline.php

@@ -68,9 +68,6 @@ class Inline
      */
     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.');
@@ -95,12 +92,7 @@ class Inline
             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;
@@ -340,9 +332,6 @@ class Inline
     {
         $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:
@@ -359,9 +348,9 @@ class Inline
                 $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);

+ 0 - 28
src/Symfony/Component/Yaml/Yaml.php

@@ -20,34 +20,6 @@ namespace Symfony\Component\Yaml;
  */
 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.
      *

+ 0 - 5
tests/Symfony/Tests/Component/Yaml/DumperTest.php

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

+ 3 - 3
tests/Symfony/Tests/Component/Yaml/Fixtures/YtsSpecificationExamples.yml

@@ -542,8 +542,8 @@ test: Miscellaneous
 spec: 2.21
 yaml: |
   null: ~
-  true: y
-  false: n
+  true: true
+  false: false
   string: '12345'
 php: |
   array(
@@ -1519,7 +1519,7 @@ test: Boolean
 yaml: |
    false: used as key
    logical:  true
-   answer: no
+   answer: false
 php: |
    array(
      false => 'used as key',

+ 0 - 24
tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml

@@ -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',
       '~',
     )

+ 0 - 5
tests/Symfony/Tests/Component/Yaml/InlineTest.php

@@ -16,11 +16,6 @@ use Symfony\Component\Yaml\Inline;
 
 class InlineTest extends \PHPUnit_Framework_TestCase
 {
-    static public function setUpBeforeClass()
-    {
-        Yaml::setSpecVersion('1.1');
-    }
-
     public function testParse()
     {
         foreach ($this->getTestsForParse() as $yaml => $value) {

+ 0 - 5
tests/Symfony/Tests/Component/Yaml/ParserTest.php

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