[Config] fixed handling of negative integer in XML support

This commit is contained in:
Fabien Potencier 2013-08-13 13:38:43 +02:00
parent 494fe74b7e
commit 4e45067c8e
2 changed files with 7 additions and 1 deletions

View File

@ -112,6 +112,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
array(false, 'False'),
array(0, '0'),
array(1, '1'),
array(-1, '-1'),
array(0777, '0777'),
array(255, '0xFF'),
array(100.0, '1e2'),

View File

@ -187,11 +187,16 @@ class XmlUtils
$cast = intval($value);
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
case '-' === $value[0] && ctype_digit(substr($value, 1)):
$raw = $value;
$cast = intval($value);
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
case 'true' === $lowercaseValue:
return true;
case 'false' === $lowercaseValue:
return false;
case strlen($value) > 2 && '0b' == $value[0].$value[1]:
case isset($value[1]) && '0b' == $value[0].$value[1]:
return bindec($value);
case is_numeric($value):
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);