Permalink
Browse files

[Yaml] removed support for YAML 1.1 spec

  • Loading branch information...
1 parent e993626 commit 252ddda0b6e4f86ad359ae06cd39424ef65f9784 @fabpot fabpot committed Jun 14, 2011
Showing with 3 additions and 42 deletions.
  1. +3 −14 Inline.php
  2. +0 −28 Yaml.php
View
@@ -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.');
@@ -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;
@@ -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:
@@ -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);
View
@@ -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.
*

0 comments on commit 252ddda

Please sign in to comment.