Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ea3cb1

Browse files
[NumberFormatter] Fix invalid numeric literal on PHP 7
1 parent 56624e6 commit 1ea3cb1

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,24 +213,18 @@ class NumberFormatter
213213
);
214214

215215
/**
216-
* The maximum values of the integer type in 32 bit platforms.
216+
* The maximum value of the integer type in 32 bit platforms.
217217
*
218-
* @var array
218+
* @var int
219219
*/
220-
private static $int32Range = array(
221-
'positive' => 2147483647,
222-
'negative' => -2147483648,
223-
);
220+
private static $int32Max = 2147483647;
224221

225222
/**
226-
* The maximum values of the integer type in 64 bit platforms.
223+
* The maximum value of the integer type in 64 bit platforms.
227224
*
228-
* @var array
225+
* @var int|float
229226
*/
230-
private static $int64Range = array(
231-
'positive' => 9223372036854775807,
232-
'negative' => -9223372036854775808,
233-
);
227+
private static $int64Max = 9223372036854775807;
234228

235229
private static $enSymbols = array(
236230
self::DECIMAL => array('.', ',', ';', '%', '0', '#', '-', '+', '¤', '¤¤', '.', 'E', '', '*', '', 'NaN', '@', ','),
@@ -795,7 +789,7 @@ private function convertValueDataType($value, $type)
795789
*/
796790
private function getInt32Value($value)
797791
{
798-
if ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) {
792+
if ($value > self::$int32Max || $value < -self::$int32Max - 1) {
799793
return false;
800794
}
801795

@@ -813,15 +807,15 @@ private function getInt32Value($value)
813807
*/
814808
private function getInt64Value($value)
815809
{
816-
if ($value > self::$int64Range['positive'] || $value < self::$int64Range['negative']) {
810+
if ($value > self::$int64Max || $value < -self::$int64Max - 1) {
817811
return false;
818812
}
819813

820-
if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value <= self::$int32Range['negative'])) {
814+
if (PHP_INT_SIZE !== 8 && ($value > self::$int32Max || $value <= -self::$int32Max - 1)) {
821815
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
822816
// The negative PHP_INT_MAX was being converted to float
823817
if (
824-
$value == self::$int32Range['negative'] &&
818+
$value == -self::$int32Max - 1 &&
825819
((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone')))
826820
) {
827821
return (int) $value;
@@ -834,7 +828,7 @@ private function getInt64Value($value)
834828
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
835829
// A 32 bit integer was being generated instead of a 64 bit integer
836830
if (
837-
($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) &&
831+
($value > self::$int32Max || $value < -self::$int32Max - 1) &&
838832
(PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) &&
839833
!(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))
840834
) {

0 commit comments

Comments
 (0)