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)

0 commit comments

Comments
 (0)