@@ -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 ' , '@ ' , ', ' ),
@@ -508,7 +502,7 @@ public function parseCurrency($value, &$currency, &$position = null)
508
502
* @param int $type Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default
509
503
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
510
504
*
511
- * @return bool|string The parsed value of false on error
505
+ * @return int|float|false The parsed value of false on error
512
506
*
513
507
* @see http://www.php.net/manual/en/numberformatter.parse.php
514
508
*/
@@ -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
@@ -808,20 +802,18 @@ private function getInt32Value($value)
808
802
* @param mixed $value The value to be converted
809
803
*
810
804
* @return int|float|false The converted value
811
- *
812
- * @see https://bugs.php.net/bug.php?id=59597 Bug #59597
813
805
*/
814
806
private function getInt64Value ($ value )
815
807
{
816
- if ($ value > self ::$ int64Range [ ' positive ' ] || $ value < self ::$ int64Range [ ' negative ' ] ) {
808
+ if ($ value > self ::$ int64Max || $ value < - self ::$ int64Max - 1 ) {
817
809
return false ;
818
810
}
819
811
820
- if (PHP_INT_SIZE !== 8 && ($ value > self ::$ int32Range [ ' positive ' ] || $ value <= self ::$ int32Range [ ' negative ' ] )) {
812
+ if (PHP_INT_SIZE !== 8 && ($ value > self ::$ int32Max || $ value <= - self ::$ int32Max - 1 )) {
821
813
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
822
814
// The negative PHP_INT_MAX was being converted to float
823
815
if (
824
- $ value == self ::$ int32Range [ ' negative ' ] &&
816
+ $ value == - self ::$ int32Max - 1 &&
825
817
((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314 ) || PHP_VERSION_ID >= 50404 || (extension_loaded ('intl ' ) && method_exists ('IntlDateFormatter ' , 'setTimeZone ' )))
826
818
) {
827
819
return (int ) $ value ;
@@ -834,7 +826,7 @@ private function getInt64Value($value)
834
826
// Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
835
827
// A 32 bit integer was being generated instead of a 64 bit integer
836
828
if (
837
- ($ value > self ::$ int32Range [ ' positive ' ] || $ value < self ::$ int32Range [ ' negative ' ] ) &&
829
+ ($ value > self ::$ int32Max || $ value < - self ::$ int32Max - 1 ) &&
838
830
(PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404 )) &&
839
831
!(extension_loaded ('intl ' ) && method_exists ('IntlDateFormatter ' , 'setTimeZone ' ))
840
832
) {
0 commit comments