8000 [Config] fixed handling of negative integer in XML support · daifma/symfony@4e45067 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e45067

Browse files
committed
[Config] fixed handling of negative integer in XML support
1 parent 494fe74 commit 4e45067

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function getDataForPhpize()
112112
array(false, 'False'),
113113
array(0, '0'),
114114
array(1, '1'),
115+
array(-1, '-1'),
115116
array(0777, '0777'),
116117
array(255, '0xFF'),
117118
array(100.0, '1e2'),

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,16 @@ public static function phpize($value)
187187
$cast = intval($value);
188188

189189
return '0' == $value[0] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
190+
case '-' === $value[0] && ctype_digit(substr($value, 1)):
191+
$raw = $value;
192+
$cast = intval($value);
193+
194+
return '0' == $value[1] ? octdec($value) : (((string) $raw == (string) $cast) ? $cast : $raw);
190195
case 'true' === $lowercaseValue:
191196
return true;
192197
case 'false' === $lowercaseValue:
193198
return false;
194-
case strlen($value) > 2 && '0b' == $value[0].$value[1]:
199+
case isset($value[1]) && '0b' == $value[0].$value[1]:
195200
return bindec($value);
196201
case is_numeric($value):
197202
return '0x' == $value[0].$value[1] ? hexdec($value) : floatval($value);

0 commit comments

Comments
 (0)
0