@@ -213,24 +213,18 @@ class NumberFormatter
213
213
);
214
214
215
215
/**
216
- * The maximum values of the integer type in 32 bit platforms.
216
+ * The maximum value of the integer type in 32 bit platforms.
217
217
*
218
- * @var array
218
+ * @var int
219
219
*/
220
- private static $ int32Range = array (
221
- 'positive ' => 2147483647 ,
222
- 'negative ' => -2147483648 ,
223
- );
220
+ private static $ int32Max = 2147483647 ;
224
221
225
222
/**
226
- * The maximum values of the integer type in 64 bit platforms.
223
+ * The maximum value of the integer type in 64 bit platforms.
227
224
*
228
- * @var array
225
+ * @var int|float
229
226
*/
230
- private static $ int64Range = array (
231
- 'positive ' => 9223372036854775807 ,
232
- 'negative ' => -9223372036854775808 ,
233
- );
227
+ private static $ int64Max = 9223372036854775807 ;
234
228
235
229
private static $ enSymbols = array (
236
230
self ::DECIMAL => array ('. ' , ', ' , '; ' , '% ' , '0 ' , '# ' , '- ' , '+ ' , '¤ ' , '¤¤ ' , '. ' , 'E ' , '‰ ' , '* ' , '∞ ' , 'NaN ' , '@ ' , ', ' ),
@@ -795,7 +789,7 @@ private function convertValueDataType($value, $type)
795
789
*/
796
790
private function getInt32Value ($ value )
797
791
{
798
- if ($ value > self ::$ int32Range [ ' positive ' ] || $ value < self ::$ int32Range [ ' negative ' ] ) {
792
+ if ($ value > self ::$ int32Max || $ value < - self ::$ int32Max - 1 ) {
799
793
return false ;
800
794
}
801
795
@@ -813,15 +807,15 @@ private function getInt32Value($value)
813
807
*/
814
808
private function getInt64Value ($ value )
815
809
{
816
- if ($ value > self ::$ int64Range [ ' positive ' ] || $ value < self ::$ int64Range [ ' negative ' ] ) {
810
+ if ($ value > self ::$ int64Max || $ value < - self ::$ int64Max - 1 ) {
817
811
return false ;
818
812
}
819
813
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 )) {
821
815
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
822
816
// The negative PHP_INT_MAX was being converted to float
823
817
if (
824
- $ value == self ::$ int32Range [ ' negative ' ] &&
818
+ $ value == - self ::$ int32Max - 1 &&
825
819
((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314 ) || PHP_VERSION_ID >= 50404 || (extension_loaded ('intl ' ) && method_exists ('IntlDateFormatter ' , 'setTimeZone ' )))
826
820
) {
827
821
return (int ) $ value ;
@@ -834,7 +828,7 @@ private function getInt64Value($value)
834
828
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
835
829
// A 32 bit integer was being generated instead of a 64 bit integer
836
830
if (
837
- ($ value > self ::$ int32Range [ ' positive ' ] || $ value < self ::$ int32Range [ ' negative ' ] ) &&
831
+ ($ value > self ::$ int32Max || $ value < - self ::$ int32Max - 1 ) &&
838
832
(PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404 )) &&
839
833
!(extension_loaded ('intl ' ) && method_exists ('IntlDateFormatter ' , 'setTimeZone ' ))
840
834
) {
0 commit comments