[Config] fixed handling of negative integer in XML support
This commit is contained in:
parent
494fe74b7e
commit
4e45067c8e
@ -112,6 +112,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(false, 'False'),
|
array(false, 'False'),
|
||||||
array(0, '0'),
|
array(0, '0'),
|
||||||
array(1, '1'),
|
array(1, '1'),
|
||||||
|
array(-1, '-1'),
|
||||||
array(0777, '0777'),
|
array(0777, '0777'),
|
||||||
array(255, '0xFF'),
|
array(255, '0xFF'),
|
||||||
array(100.0, '1e2'),
|
array(100.0, '1e2'),
|
||||||
|
@ -187,11 +187,16 @@ class XmlUtils
|
|||||||
$cast = intval($value);
|
$cast = intval($value);
|
||||||
|
|
||||||
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
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:
|
case 'true' === $lowercaseValue:
|
||||||
return true;
|
return true;
|
||||||
case 'false' === $lowercaseValue:
|
case 'false' === $lowercaseValue:
|
||||||
return false;
|
return false;
|
||||||
case strlen($value) > 2 && '0b' == $value[0].$value[1]:
|
case isset($value[1]) && '0b' == $value[0].$value[1]:
|
||||||
return bindec($value);
|
return bindec($value);
|
||||||
case is_numeric($value):
|
case is_numeric($value):
|
||||||
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
|
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
|
||||||
|
Reference in New Issue
Block a user