File tree Expand file tree Collapse file tree 3 files changed +36
-15
lines changed Expand file tree Collapse file tree 3 files changed +36
-15
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ PHP NEWS
24
24
. Fixed bug #79112 (IMAP extension can't find OpenSSL libraries at configure
25
25
time). (Nikita)
26
26
27
+ -Intl:
28
+ . Fixed bug #79212 (NumberFormatter::format() may detect wrong type). (cmb)
29
+
27
30
- MBString:
28
31
. Fixed bug #79149 (SEGV in mb_convert_encoding with non-string encodings).
29
32
(cmb)
Original file line number Diff line number Diff line change @@ -53,23 +53,23 @@ PHP_FUNCTION( numfmt_format )
53
53
/* Fetch the object. */
54
54
FORMATTER_METHOD_FETCH_OBJECT ;
55
55
56
- if (type == FORMAT_TYPE_DEFAULT ) {
57
- if (Z_TYPE_P (number ) == IS_STRING ) {
58
- convert_scalar_to_number_ex (number );
59
- }
60
-
61
- if (Z_TYPE_P (number ) == IS_LONG ) {
62
- /* take INT32 on 32-bit, int64 on 64-bit */
63
- type = (sizeof (zend_long ) == 8 )?FORMAT_TYPE_INT64 :FORMAT_TYPE_INT32 ;
64
- } else if (Z_TYPE_P (number ) == IS_DOUBLE ) {
65
- type = FORMAT_TYPE_DOUBLE ;
66
- } else {
67
- type = FORMAT_TYPE_INT32 ;
68
- }
56
+ if (Z_TYPE_P (number ) != IS_ARRAY ) {
57
+ convert_scalar_to_number_ex (number );
58
+ } else {
59
+ convert_to_long (number );
69
60
}
70
61
71
- if (Z_TYPE_P (number ) != IS_DOUBLE && Z_TYPE_P (number ) != IS_LONG ) {
72
- convert_scalar_to_number (number );
62
+ if (type == FORMAT_TYPE_DEFAULT ) {
63
+ switch (Z_TYPE_P (number )) {
64
+ case IS_LONG :
65
+ /* take INT32 on 32-bit, int64 on 64-bit */
66
+ type = (sizeof (zend_long ) == 8 )?FORMAT_TYPE_INT64 :FORMAT_TYPE_INT32 ;
67
+ break ;
68
+ case IS_DOUBLE :
69
+ type = FORMAT_TYPE_DOUBLE ;
70
+ break ;
71
+ EMPTY_SWITCH_DEFAULT_CASE ();
72
+ }
73
73
}
74
74
75
75
switch (type ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #79212 (NumberFormatter::format() may detect wrong type)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('intl ' )) die ('skip intl extension not available ' );
6
+ if (!extension_loaded ('gmp ' )) die ('skip gmp extension not available ' );
7
+ ?>
8
+ --FILE--
9
+ <?php
10
+ $ fmt = new NumberFormatter ('en_US ' , NumberFormatter::PATTERN_DECIMAL );
11
+ var_dump ($ fmt ->format (gmp_init ('823749273428379492374 ' )));
12
+
13
+ $ fmt = new NumberFormatter ('en_US ' , NumberFormatter::PATTERN_DECIMAL );
14
+ var_dump ($ fmt ->format ([1 ], NumberFormatter::TYPE_INT64 ));
15
+ ?>
16
+ --EXPECT--
17
+ string(21) "823749273428379400000"
18
+ string(1) "1"
You can’t perform that action at this time.
0 commit comments