Support binary notation.

This commit is contained in:
Tomasz Kowalczyk 2013-08-12 21:25:17 +02:00 committed by Fabien Potencier
parent e617ddb746
commit 78de59d0b3
2 changed files with 3 additions and 0 deletions

View File

@ -127,6 +127,7 @@ class XmlUtilsTest extends \PHPUnit_Framework_TestCase
array('111,222,333,444', '111,222,333,444'),
array('1111,2222,3333,4444,5555', '1111,2222,3333,4444,5555'),
array('foo', 'foo'),
array(6, '0b0110'),
);
}
}

View File

@ -191,6 +191,8 @@ class XmlUtils
return true;
case 'false' === $lowercaseValue:
return false;
case strlen($value) > 2 && '0b' == $value[0].$value[1]:
return bindec($value);
case is_numeric($value):
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);
case preg_match('/^(-|\+)?[0-9]+(\.[0-9]+)?$/', $value):