From 999c0a5501866c38d37f9dd2c4acde893003c0a4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 17 Mar 2016 12:09:45 +0100 Subject: [PATCH] [NumberFormatter] Fix invalid numeric literal on PHP 7 --- .../Intl/NumberFormatter/NumberFormatter.php | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index f89ce8a46927..7118a0351568 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -213,24 +213,18 @@ class NumberFormatter ); /** - * The maximum values of the integer type in 32 bit platforms. + * The maximum value of the integer type in 32 bit platforms. * - * @var array + * @var int */ - private static $int32Range = array( - 'positive' => 2147483647, - 'negative' => -2147483648, - ); + private static $int32Max = 2147483647; /** - * The maximum values of the integer type in 64 bit platforms. + * The maximum value of the integer type in 64 bit platforms. * - * @var array + * @var int|float */ - private static $int64Range = array( - 'positive' => 9223372036854775807, - 'negative' => -9223372036854775808, - ); + private static $int64Max = 9223372036854775807; private static $enSymbols = array( self::DECIMAL => array('.', ',', ';', '%', '0', '#', '-', '+', '¤', '¤¤', '.', 'E', '‰', '*', '∞', 'NaN', '@', ','), @@ -508,7 +502,7 @@ public function parseCurrency($value, &$currency, &$position = null) * @param int $type Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default * @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended * - * @return bool|string The parsed value of false on error + * @return int|float|false The parsed value of false on error * * @see http://www.php.net/manual/en/numberformatter.parse.php */ @@ -795,7 +789,7 @@ private function convertValueDataType($value, $type) */ private function getInt32Value($value) { - if ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) { + if ($value > self::$int32Max || $value < -self::$int32Max - 1) { return false; } @@ -808,20 +802,18 @@ private function getInt32Value($value) * @param mixed $value The value to be converted * * @return int|float|false The converted value - * - * @see https://bugs.php.net/bug.php?id=59597 Bug #59597 */ private function getInt64Value($value) { - if ($value > self::$int64Range['positive'] || $value < self::$int64Range['negative']) { + if ($value > self::$int64Max || $value < -self::$int64Max - 1) { return false; } - if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value <= self::$int32Range['negative'])) { + if (PHP_INT_SIZE !== 8 && ($value > self::$int32Max || $value <= -self::$int32Max - 1)) { // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // The negative PHP_INT_MAX was being converted to float if ( - $value == self::$int32Range['negative'] && + $value == -self::$int32Max - 1 && ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) ) { return (int) $value; @@ -834,7 +826,7 @@ private function getInt64Value($value) // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // A 32 bit integer was being generated instead of a 64 bit integer if ( - ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && + ($value > self::$int32Max || $value < -self::$int32Max - 1) && (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone')) ) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy