Skip to content

Commit 381e820

Browse files
committed
Update tests for lossy bool conversion deprecation
Tests which only exist to pass each type to one parameter of a function (such as the "different data types" variation tests and "invalid params" tests) are removed, as this type juggling is global behavior already covered by the Zend type declaration tests. Other tests which included booleans in their list of int, float, or string inputs, or other scalars in their list of bool inputs, no longer pass them, so they won't need updating again when the deprecation becomes a TypeError. The fscanf() tests which write booleans to a file as test data now convert them to strings explicitly. The deprecations are recorded only in tests of the coercion behavior itself, such as the scalar and union type declaration tests, exit() values, and the NAN coercion tests, and in the regression test for bug #79919, which needs the bool returned by error_log() to reproduce the bug. The GH-22112 test now ignores the deprecation in its error handler, so it continues to cover an exception thrown by the NAN warning. The 32-bit and non-Windows variants of affected tests were updated to match, but could not be run locally.
1 parent 325f979 commit 381e820

159 files changed

Lines changed: 466 additions & 3842 deletions

File tree

Some content is hidden

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

‎Zend/tests/backtrace/debug_backtrace_options.phpt‎

Lines changed: 3 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ function doit($a, $b, $how)
1616
{
1717
echo "==default\n";
1818
$how();
19-
echo "==true\n";
20-
$how(true);
21-
echo "==false\n";
22-
$how(false);
2319
echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n";
2420
$how(DEBUG_BACKTRACE_PROVIDE_OBJECT);
2521
echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n";
@@ -48,14 +44,6 @@ foo::statCall("doit", "backtrace_print");
4844
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
4945
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
5046
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
51-
==true
52-
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
53-
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
54-
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
55-
==false
56-
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
57-
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
58-
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
5947
==DEBUG_BACKTRACE_PROVIDE_OBJECT
6048
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
6149
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
@@ -130,138 +118,14 @@ Array
130118

131119
)
132120

133-
)
134-
==true
135-
Array
136-
(
137-
[0] => Array
138-
(
139-
[file] => %sdebug_backtrace_options.php
140-
[line] => 17
141-
[function] => backtrace_print
142-
[args] => Array
143-
(
144-
[0] => 1
145-
)
146-
147-
)
148-
149-
[1] => Array
150-
(
151-
[file] => %sdebug_backtrace_options.php
152-
[line] => %d
153-
[function] => doit
154-
[args] => Array
155-
(
156-
[0] => a
157-
[1] => b
158-
[2] => backtrace_print
159-
)
160-
161-
)
162-
163-
[2] => Array
164-
(
165-
[file] => %sdebug_backtrace_options.php
166-
[line] => %d
167-
[function] => doCall
168-
[class] => foo
169-
[object] => foo Object
170-
(
171-
)
172-
173-
[type] => ->
174-
[args] => Array
175-
(
176-
[0] => doit
177-
[1] => backtrace_print
178-
)
179-
180-
)
181-
182-
[3] => Array
183-
(
184-
[file] => %sdebug_backtrace_options.php
185-
[line] => %d
186-
[function] => statCall
187-
[class] => foo
188-
[type] => ::
189-
[args] => Array
190-
(
191-
[0] => doit
192-
[1] => backtrace_print
193-
)
194-
195-
)
196-
197-
)
198-
==false
199-
Array
200-
(
201-
[0] => Array
202-
(
203-
[file] => %sdebug_backtrace_options.php
204-
[line] => 19
205-
[function] => backtrace_print
206-
[args] => Array
207-
(
208-
[0] =>
209-
)
210-
211-
)
212-
213-
[1] => Array
214-
(
215-
[file] => %sdebug_backtrace_options.php
216-
[line] => %d
217-
[function] => doit
218-
[args] => Array
219-
(
220-
[0] => a
221-
[1] => b
222-
[2] => backtrace_print
223-
)
224-
225-
)
226-
227-
[2] => Array
228-
(
229-
[file] => %sdebug_backtrace_options.php
230-
[line] => %d
231-
[function] => doCall
232-
[class] => foo
233-
[type] => ->
234-
[args] => Array
235-
(
236-
[0] => doit
237-
[1] => backtrace_print
238-
)
239-
240-
)
241-
242-
[3] => Array
243-
(
244-
[file] => %sdebug_backtrace_options.php
245-
[line] => %d
246-
[function] => statCall
247-
[class] => foo
248-
[type] => ::
249-
[args] => Array
250-
(
251-
[0] => doit
252-
[1] => backtrace_print
253-
)
254-
255-
)
256-
257121
)
258122
==DEBUG_BACKTRACE_PROVIDE_OBJECT
259123
Array
260124
(
261125
[0] => Array
262126
(
263127
[file] => %sdebug_backtrace_options.php
264-
[line] => 21
128+
[line] => 17
265129
[function] => backtrace_print
266130
[args] => Array
267131
(
@@ -325,7 +189,7 @@ Array
325189
[0] => Array
326190
(
327191
[file] => %sdebug_backtrace_options.php
328-
[line] => 23
192+
[line] => 19
329193
[function] => backtrace_print
330194
)
331195

@@ -361,7 +225,7 @@ Array
361225
[0] => Array
362226
(
363227
[file] => %sdebug_backtrace_options.php
364-
[line] => 25
228+
[line] => 21
365229
[function] => backtrace_print
366230
)
367231

‎Zend/tests/builtin_functions/builtin_functions_basic.phpt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ var_dump(count(get_defined_functions()));
2828
var_dump(gettype(get_declared_interfaces()));
2929
var_dump(count(get_declared_interfaces()));
3030

31-
var_dump(get_extension_funcs(true));
3231
var_dump(gettype(get_extension_funcs("standard")));
3332
var_dump(count(get_extension_funcs("standard")));
3433
var_dump(gettype(get_extension_funcs("zend")));
@@ -51,7 +50,6 @@ string(5) "array"
5150
int(%d)
5251
string(5) "array"
5352
int(%d)
54-
bool(false)
5553
string(5) "array"
5654
int(%d)
5755
string(5) "array"

‎Zend/tests/call_user_functions/call_user_func_strict_arginfo_check.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ declare(strict_types=1);
77
namespace Foo;
88

99
// strlen() will be called with strict_types=0, so this is legal.
10-
var_dump(call_user_func('strlen', false));
10+
var_dump(call_user_func('strlen', 25));
1111

1212
?>
1313
--EXPECT--
14-
int(0)
14+
int(2)

‎Zend/tests/constants/bug79919.phpt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ $b = error_log(0);
1010
$b = simplexml_load_string('<xml/>', null, $b);
1111
define(0, $b);
1212
?>
13-
--EXPECT--
13+
--EXPECTF--
1414
0
15+
16+
Deprecated: Implicit conversion from true to int in %s on line %d

‎Zend/tests/exit/exit_values.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ Deprecated: exit(): Passing null to parameter #1 ($status) of type string|int is
8484
Using false as value:
8585
Exit status is: 0
8686
Output is:
87-
87+
Deprecated: Implicit conversion from false to int in %s on line %d
8888
Using true as value:
8989
Exit status is: 1
9090
Output is:
91-
91+
Deprecated: Implicit conversion from true to int in %s on line %d
9292
Using 0 as value:
9393
Exit status is: 0
9494
Output is:
@@ -136,11 +136,11 @@ Deprecated: exit(): Passing null to parameter #1 ($status) of type string|int is
136136
Using false as value:
137137
Exit status is: 0
138138
Output is:
139-
139+
Deprecated: Implicit conversion from false to int in %s on line %d
140140
Using true as value:
141141
Exit status is: 1
142142
Output is:
143-
143+
Deprecated: Implicit conversion from true to int in %s on line %d
144144
Using 0 as value:
145145
Exit status is: 0
146146
Output is:

‎Zend/tests/type_coercion/gh22112.phpt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ GH-22112 (Assertion failure when error handler throws during NaN to bool/string
44
<?php
55

66
set_error_handler(function ($errno, $errstr) {
7+
if ($errno === E_DEPRECATED) {
8+
// Ignore the lossy bool coercion deprecation, so that the NAN warning is reached
9+
return true;
10+
}
711
throw new Exception($errstr);
812
});
913

‎Zend/tests/type_coercion/nan_to_other.phpt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ foreach ($types as $type) {
4141
--EXPECTF--
4242
float(NAN)
4343

44+
Deprecated: Implicit conversion from float NAN to bool in %s on line %d
45+
4446
Warning: unexpected NAN value was coerced to bool in %s on line %d
4547
bool(true)
4648

‎Zend/tests/type_declarations/scalar_basic.phpt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ int(%d)
9191
TypeError: {closure:%s:%d}(): Argument #1 ($i) must be of type int, float given, called in %s on line %d
9292

9393
*** Trying bool(true)
94+
E_DEPRECATED: Implicit conversion from true to int on line 14
9495
int(1)
9596

9697
*** Trying bool(false)
98+
E_DEPRECATED: Implicit conversion from false to int on line 14
9799
int(0)
98100

99101
*** Trying NULL
@@ -144,9 +146,11 @@ float(%s)
144146
float(NAN)
145147

146148
*** Trying bool(true)
149+
E_DEPRECATED: Implicit conversion from true to float on line 15
147150
float(1)
148151

149152
*** Trying bool(false)
153+
E_DEPRECATED: Implicit conversion from false to float on line 15
150154
float(0)
151155

152156
*** Trying NULL
@@ -198,9 +202,11 @@ E_WARNING: unexpected NAN value was coerced to string on line %d
198202
string(3) "NAN"
199203

200204
*** Trying bool(true)
205+
E_DEPRECATED: Implicit conversion from true to string on line 16
201206
string(1) "1"
202207

203208
*** Trying bool(false)
209+
E_DEPRECATED: Implicit conversion from false to string on line 16
204210
string(0) ""
205211

206212
*** Trying NULL
@@ -230,24 +236,31 @@ bool(true)
230236
bool(true)
231237

232238
*** Trying float(1)
239+
E_DEPRECATED: Implicit conversion from float 1 to bool on line 17
233240
bool(true)
234241

235242
*** Trying float(1.5)
243+
E_DEPRECATED: Implicit conversion from float 1.5 to bool on line 17
236244
bool(true)
237245

238246
*** Trying string(2) "1a"
247+
E_DEPRECATED: Implicit conversion from string "1a" to bool on line 17
239248
bool(true)
240249

241250
*** Trying string(1) "a"
251+
E_DEPRECATED: Implicit conversion from string "a" to bool on line 17
242252
bool(true)
243253

244254
*** Trying string(0) ""
255+
E_DEPRECATED: Implicit conversion from string "" to bool on line 17
245256
bool(false)
246257

247258
*** Trying int(%d)
259+
E_DEPRECATED: Implicit conversion from int 9223372036854775807 to bool on line 17
248260
bool(true)
249261

250262
*** Trying float(NAN)
263+
E_DEPRECATED: Implicit conversion from float NAN to bool on line 17
251264
E_WARNING: unexpected NAN value was coerced to bool on line %d
252265
bool(true)
253266

‎Zend/tests/type_declarations/scalar_return_basic.phpt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ int(2147483647)
8484
*** Trying float(NAN)
8585
*** Caught {closure:%s:%d}(): Return value must be of type int, float returned in %s on line %d
8686
*** Trying bool(true)
87+
E_DEPRECATED: Implicit conversion from true to int on line 14
8788
int(1)
8889
*** Trying bool(false)
90+
E_DEPRECATED: Implicit conversion from false to int on line 14
8991
int(0)
9092
*** Trying NULL
9193
*** Caught {closure:%s:%d}(): Return value must be of type int, null returned in %s on line %d
@@ -121,8 +123,10 @@ float(2147483647)
121123
*** Trying float(NAN)
122124
float(NAN)
123125
*** Trying bool(true)
126+
E_DEPRECATED: Implicit conversion from true to float on line 15
124127
float(1)
125128
*** Trying bool(false)
129+
E_DEPRECATED: Implicit conversion from false to float on line 15
126130
float(0)
127131
*** Trying NULL
128132
*** Caught {closure:%s:%d}(): Return value must be of type float, null returned in %s on line %d
@@ -159,8 +163,10 @@ string(10) "2147483647"
159163
E_WARNING: unexpected NAN value was coerced to string on line %d
160164
string(3) "NAN"
161165
*** Trying bool(true)
166+
E_DEPRECATED: Implicit conversion from true to string on line 16
162167
string(1) "1"
163168
*** Trying bool(false)
169+
E_DEPRECATED: Implicit conversion from false to string on line 16
164170
string(0) ""
165171
*** Trying NULL
166172
*** Caught {closure:%s:%d}(): Return value must be of type string, null returned in %s on line %d
@@ -182,18 +188,25 @@ bool(true)
182188
*** Trying string(1) "1"
183189
bool(true)
184190
*** Trying float(1)
191+
E_DEPRECATED: Implicit conversion from float 1 to bool on line 17
185192
bool(true)
186193
*** Trying float(1.5)
194+
E_DEPRECATED: Implicit conversion from float 1.5 to bool on line 17
187195
bool(true)
188196
*** Trying string(2) "1a"
197+
E_DEPRECATED: Implicit conversion from string "1a" to bool on line 17
189198
bool(true)
190199
*** Trying string(1) "a"
200+
E_DEPRECATED: Implicit conversion from string "a" to bool on line 17
191201
bool(true)
192202
*** Trying string(0) ""
203+
E_DEPRECATED: Implicit conversion from string "" to bool on line 17
193204
bool(false)
194205
*** Trying int(2147483647)
206+
E_DEPRECATED: Implicit conversion from int 9223372036854775807 to bool on line 17
195207
bool(true)
196208
*** Trying float(NAN)
209+
E_DEPRECATED: Implicit conversion from float NAN to bool on line 17
197210
E_WARNING: unexpected NAN value was coerced to bool on line %d
198211
bool(true)
199212
*** Trying bool(true)

0 commit comments

Comments
 (0)