Skip to content

Commit a939805

Browse files
committed
Use serialize_precision for var_dump()
var_dump() is debugging functionality, so it should print floating-point numbers accurately. We do this by switching to serialize_precision, which (by default) will print with as much precision as necessary to preserve the exact value of the float. This also affects debug_zval_dump(). Closes GH-5172.
1 parent c3aa913 commit a939805

File tree

111 files changed

+1472
-1465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1472
-1465
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ PHP 8.0 UPGRADE NOTES
342342
http://example.com/foo?# => query = "", fragment = ""
343343

344344
Previously all cases resulted in query and fragment being null.
345+
. var_dump() and debug_zval_dump() will now print floating-point numbers
346+
using serialize_precision rather than precision. In a default configuration,
347+
this means that floating-point numbers are now printed with full accuracy
348+
by these debugging functions.
345349

346350
- tidy:
347351
. The $use_include_path parameter, which was not used internally, has been

Zend/tests/add_005.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ var_dump($c);
1717
echo "Done\n";
1818
?>
1919
--EXPECT--
20-
float(2834756759.1231)
21-
float(2834756759.1231)
20+
float(2834756759.123123)
21+
float(2834756759.123123)
2222
Done

Zend/tests/binary-32bit.phpt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
testing binary literals
3-
--INI--
4-
precision=14
53
--SKIPIF--
64
<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?>
75
--FILE--
@@ -126,27 +124,27 @@ float(8796093022207)
126124
float(17592186044415)
127125
float(35184372088831)
128126
float(70368744177663)
129-
float(1.4073748835533E+14)
130-
float(2.8147497671066E+14)
131-
float(5.6294995342131E+14)
132-
float(1.1258999068426E+15)
133-
float(2.2517998136852E+15)
134-
float(4.5035996273705E+15)
135-
float(9.007199254741E+15)
136-
float(1.8014398509482E+16)
137-
float(3.6028797018964E+16)
138-
float(7.2057594037928E+16)
139-
float(1.4411518807586E+17)
140-
float(2.8823037615171E+17)
141-
float(5.7646075230342E+17)
142-
float(1.1529215046068E+18)
143-
float(2.3058430092137E+18)
144-
float(4.6116860184274E+18)
145-
float(9.2233720368548E+18)
146-
float(1.844674407371E+19)
147-
float(-1.844674407371E+19)
148-
float(-9.2233720368548E+18)
149-
float(-4.6116860184274E+18)
127+
float(140737488355327)
128+
float(281474976710655)
129+
float(562949953421311)
130+
float(1125899906842623)
131+
float(2251799813685247)
132+
float(4503599627370495)
133+
float(9007199254740992)
134+
float(18014398509481984)
135+
float(36028797018963970)
136+
float(72057594037927940)
137+
float(1.4411518807585587E+17)
138+
float(2.8823037615171174E+17)
139+
float(5.764607523034234E+17)
140+
float(1.1529215046068468E+18)
141+
float(2.3058430092136937E+18)
142+
float(4.6116860184273874E+18)
143+
float(9.223372036854775E+18)
144+
float(1.844674407370955E+19)
145+
float(-1.844674407370955E+19)
146+
float(-9.223372036854775E+18)
147+
float(-4.6116860184273874E+18)
150148
float(-8589934591)
151149
float(-4294967295)
152150
int(-2147483647)

Zend/tests/binary.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ int(1152921504606846975)
143143
int(2305843009213693951)
144144
int(4611686018427387903)
145145
int(9223372036854775807)
146-
float(9223372036854775808)
147-
float(18446744073709549568)
148-
float(18446744073709549568)
149-
float(36893488147419099136)
150-
float(36893488147419099136)
151-
float(-18446744073709549568)
146+
float(9.223372036854776E+18)
147+
float(1.844674407370955E+19)
148+
float(1.844674407370955E+19)
149+
float(3.68934881474191E+19)
150+
float(3.68934881474191E+19)
151+
float(-1.844674407370955E+19)
152152
int(-9223372036854775807)
153153
int(-4611686018427387903)
154154
int(-1)

Zend/tests/decrement_001_64bit.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ object(stdClass)#%d (0) {
5555
}
5656
array(0) {
5757
}
58-
float(-9.2233720368548E+18)
59-
float(-9.2233720368548E+18)
58+
float(-9.223372036854776E+18)
59+
float(-9.223372036854776E+18)
6060
Done

Zend/tests/div_001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var_dump($c);
2626
echo "Done\n";
2727
?>
2828
--EXPECT--
29-
float(394758.39454545)
30-
float(394758.39454545)
31-
float(394758.39454545)
29+
float(394758.39454545453)
30+
float(394758.39454545453)
31+
float(394758.39454545453)
3232
Done

Zend/tests/hex_overflow_32bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
testing integer overflow (32bit)
33
--INI--
4-
precision=14
4+
serialize_precision=14
55
--SKIPIF--
66
<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?>
77
--FILE--

Zend/tests/numeric_string_errors.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int(0)
8888
Notice: A non well formed numeric value encountered in %s on line %d
8989

9090
Notice: A non well formed numeric value encountered in %s on line %d
91-
float(0.89473684210526)
91+
float(0.8947368421052632)
9292

9393
Warning: A non-numeric value encountered in %s on line %d
9494

@@ -101,7 +101,7 @@ float(NAN)
101101
Notice: A non well formed numeric value encountered in %s on line %d
102102

103103
Notice: A non well formed numeric value encountered in %s on line %d
104-
float(3.0910586430935E+39)
104+
float(3.0910586430935376E+39)
105105

106106
Warning: A non-numeric value encountered in %s on line %d
107107

Zend/tests/numeric_string_errors_assign.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int(0)
143143
Notice: A non well formed numeric value encountered in %s on line %d
144144

145145
Notice: A non well formed numeric value encountered in %s on line %d
146-
float(0.89473684210526)
146+
float(0.8947368421052632)
147147

148148
Warning: A non-numeric value encountered in %s on line %d
149149

@@ -156,7 +156,7 @@ float(NAN)
156156
Notice: A non well formed numeric value encountered in %s on line %d
157157

158158
Notice: A non well formed numeric value encountered in %s on line %d
159-
float(3.0910586430935E+39)
159+
float(3.0910586430935376E+39)
160160

161161
Warning: A non-numeric value encountered in %s on line %d
162162

Zend/tests/type_declarations/scalar_return_basic_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ float(1)
117117
*** Trying string(0) ""
118118
*** Caught Return value of {closure}() must be of type float, string returned in %s on line %d
119119
*** Trying int(9223372036854775807)
120-
float(9.2233720368548E+18)
120+
float(9.223372036854776E+18)
121121
*** Trying float(NAN)
122122
float(NAN)
123123
*** Trying bool(true)

Zend/tests/type_declarations/scalar_strict_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ float(1.5)
131131
*** Caught {closure}() expects argument #1 ($f) to be of type float, string given, called in %s on line %d
132132

133133
*** Trying int(9223372036854775807)
134-
float(9.2233720368548E+18)
134+
float(9.223372036854776E+18)
135135

136136
*** Trying float(NAN)
137137
float(NAN)

Zend/tests/zend_signed_multiply-64bit-2.phpt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ for($c = 0; $c <= 16; $c++) {
1616
--EXPECT--
1717
int(-16)
1818
int(-922337203685477580)
19-
float(1.4757395258968E+19)
19+
float(1.4757395258967642E+19)
2020
-----------
2121
int(-15)
2222
int(-922337203685477580)
23-
float(1.3835058055282E+19)
23+
float(1.3835058055282164E+19)
2424
-----------
2525
int(-14)
2626
int(-922337203685477580)
27-
float(1.2912720851597E+19)
27+
float(1.2912720851596687E+19)
2828
-----------
2929
int(-13)
3030
int(-922337203685477580)
31-
float(1.1990383647911E+19)
31+
float(1.1990383647911209E+19)
3232
-----------
3333
int(-12)
3434
int(-922337203685477580)
35-
float(1.1068046444226E+19)
35+
float(1.1068046444225733E+19)
3636
-----------
3737
int(-11)
3838
int(-922337203685477580)
39-
float(1.014570924054E+19)
39+
float(1.0145709240540254E+19)
4040
-----------
4141
int(-10)
4242
int(-922337203685477580)
@@ -124,25 +124,25 @@ int(9223372036854775800)
124124
-----------
125125
int(11)
126126
int(922337203685477580)
127-
float(1.014570924054E+19)
127+
float(1.0145709240540254E+19)
128128
-----------
129129
int(12)
130130
int(922337203685477580)
131-
float(1.1068046444226E+19)
131+
float(1.1068046444225733E+19)
132132
-----------
133133
int(13)
134134
int(922337203685477580)
135-
float(1.1990383647911E+19)
135+
float(1.1990383647911209E+19)
136136
-----------
137137
int(14)
138138
int(922337203685477580)
139-
float(1.2912720851597E+19)
139+
float(1.2912720851596687E+19)
140140
-----------
141141
int(15)
142142
int(922337203685477580)
143-
float(1.3835058055282E+19)
143+
float(1.3835058055282164E+19)
144144
-----------
145145
int(16)
146146
int(922337203685477580)
147-
float(1.4757395258968E+19)
147+
float(1.4757395258967642E+19)
148148
-----------

Zend/tests/zend_signed_multiply-64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ var_dump(0x80000001 * -0xffffffff);
1111
--EXPECT--
1212
int(-9223372034707292160)
1313
int(9223372036854775806)
14-
float(-9.2233720390023E+18)
14+
float(-9.22337203900226E+18)

Zend/tests/zend_strtod.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ echo "Done\n";
1414
--EXPECT--
1515
float(-100)
1616
float(808792757210)
17-
float(-4.5646456464565E+27)
18-
float(-1.1276204760067E+16)
17+
float(-4.5646456464564635E+27)
18+
float(-11276204760067310)
1919
Done

ext/exif/tests/float_cast_overflow.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ array(8) {
3838
["ImageWidth"]=>
3939
int(1)
4040
["ImageLength"]=>
41-
float(-2.5961487387524E+33)
41+
float(-2.5961487387524236E+33)
4242
}
4343
}

ext/json/tests/008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ var_dump($x->largenum);
1212
echo "Done\n";
1313
?>
1414
--EXPECT--
15-
float(1.2345678901235E+29)
15+
float(1.2345678901234568E+29)
1616
string(30) "123456789012345678901234567890"
1717
Done

ext/json/tests/bug63737.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ decode('-123456789012345678901234567890.1');
2121
echo "Done\n";
2222
?>
2323
--EXPECT--
24-
float(1.2345678901235E+29)
24+
float(1.2345678901234568E+29)
2525
string(30) "123456789012345678901234567890"
26-
float(-1.2345678901235E+29)
26+
float(-1.2345678901234568E+29)
2727
string(31) "-123456789012345678901234567890"
28-
float(1.2345678901235E+29)
29-
float(1.2345678901235E+29)
30-
float(-1.2345678901235E+29)
31-
float(-1.2345678901235E+29)
28+
float(1.2345678901234568E+29)
29+
float(1.2345678901234568E+29)
30+
float(-1.2345678901234568E+29)
31+
float(-1.2345678901234568E+29)
3232
Done

ext/mysqli/tests/010.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ array(7) {
6868
[2]=>
6969
float(0)
7070
[3]=>
71-
float(1.0E+12)
71+
float(1000000000000)
7272
[4]=>
7373
float(0.564642)
7474
[5]=>
7575
float(1)
7676
[6]=>
77-
float(8.88889E+14)
77+
float(888889000000000)
7878
}
7979
done!

ext/standard/tests/array/001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ array(11) {
6565
[5]=>
6666
string(6) "monkey"
6767
[6]=>
68-
float(-0.33333333333333)
68+
float(-0.3333333333333333)
6969
[7]=>
7070
array(1) {
7171
[0]=>
@@ -121,7 +121,7 @@ array(2) {
121121
int(5)
122122
string(6) "monkey"
123123
int(6)
124-
float(-0.33333333333333)
124+
float(-0.3333333333333333)
125125
int(7)
126126
array(1) {
127127
[0]=>

0 commit comments

Comments
 (0)