Skip to content

Commit 9e4d482

Browse files
committed
Deprecate implicit bool to string coercion
1 parent 8c60e21 commit 9e4d482

File tree

102 files changed

+1286
-134
lines changed

Some content is hidden

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

102 files changed

+1286
-134
lines changed

Zend/tests/017.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ string(5) "array"
5151
int(%d)
5252
string(5) "array"
5353
int(%d)
54+
55+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
5456
bool(false)
5557
string(5) "array"
5658
int(%d)

Zend/tests/call_user_func_strict_arginfo_check.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ namespace Foo;
1010
var_dump(call_user_func('strlen', false));
1111

1212
?>
13-
--EXPECT--
13+
--EXPECTF--
14+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
1415
int(0)

Zend/tests/type_declarations/scalar_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,11 @@ string(%d) "%d"
197197
string(3) "NAN"
198198

199199
*** Trying bool(true)
200+
E_DEPRECATED: Implicit bool to string coercion is deprecated on line 16
200201
string(1) "1"
201202

202203
*** Trying bool(false)
204+
E_DEPRECATED: Implicit bool to string coercion is deprecated on line 16
203205
string(0) ""
204206

205207
*** Trying NULL

Zend/tests/type_declarations/scalar_return_basic_64bit.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ string(19) "9223372036854775807"
158158
*** Trying float(NAN)
159159
string(3) "NAN"
160160
*** Trying bool(true)
161+
E_DEPRECATED: Implicit bool to string coercion is deprecated on line 16
161162
string(1) "1"
162163
*** Trying bool(false)
164+
E_DEPRECATED: Implicit bool to string coercion is deprecated on line 16
163165
string(0) ""
164166
*** Trying NULL
165167
*** Caught {closure}(): Return value must be of type string, null returned in %s on line %d

Zend/tests/type_declarations/union_types/type_checking_weak.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ INF => "INF"
181181
"42x" => "42x"
182182
"x" => "x"
183183
"" => ""
184-
true => "1"
185-
false => ""
184+
true => "1" (Implicit bool to string coercion is deprecated)
185+
false => "" (Implicit bool to string coercion is deprecated)
186186
null => Argument ... must be of type array|string, null given
187187
[] => []
188188
new stdClass => Argument ... must be of type array|string, stdClass given

Zend/zend_API.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **des
652652
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
653653
return 0;
654654
}
655+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_TRUE || Z_TYPE_P(arg) == IS_FALSE)) {
656+
zend_error(E_DEPRECATED, "Implicit bool to string coercion is deprecated");
657+
}
655658
convert_to_string(arg);
656659
*dest = Z_STR_P(arg);
657660
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {

ext/iconv/tests/bug48147.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ bool(false)
2020
string(10) "aa%C3%B8aa"
2121

2222
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
23+
24+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
2325
string(0) ""
2426
string(8) "%C3%B8aa"
2527

2628
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
29+
30+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
2731
string(0) ""

ext/iconv/tests/iconv_mime_decode.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ do_regression_test();
7070
(32) "Subject: Prüfung PrüfungkůÔńÓlet"
7171
(31) "Subject: PrüfungPrüfungkůÔńÓlet"
7272
2: iconv_mime_decode(): Malformed string
73+
8192: Implicit bool to string coercion is deprecated
7374
(0) ""
7475
(27) "From: サンプル文字列サンプル文字列日本語テキスト"
7576
(31) "Subject: PrüfungPrüfungkůÔńÓlet"
7677
(32) "Subject: Prüfung PrüfungkůÔńÓlet"
7778
(100) "Subject: =?ISO-8859-1?Q?Pr=FCfung?==?ISO-8859-1*de_DE?Q?Pr=FCfung?==?ISO-8859-2?Q?k=F9=D4=F1=D3let?="
7879
2: iconv_mime_decode(): Malformed string
80+
8192: Implicit bool to string coercion is deprecated
7981
(0) ""
8082
(27) "From: サンプル文字列サンプル文字列日本語テキスト"
8183
(31) "Subject: PrüfungPrüfungkůÔńÓlet"

ext/json/tests/bug69187.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ var_dump(json_last_error());
2626
json_decode("\"\x00\"");
2727
var_dump(json_last_error());
2828
?>
29-
--EXPECT--
29+
--EXPECTF--
30+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
3031
NULL
3132
int(4)
3233
NULL
@@ -35,6 +36,8 @@ int(0)
3536
int(0)
3637
int(1)
3738
int(0)
39+
40+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
3841
int(1)
3942
int(0)
4043
int(5)

ext/reflection/tests/005.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ foreach($r->getMethods() as $m)
4646
}
4747

4848
?>
49-
--EXPECT--
49+
--EXPECTF--
5050
string(19) "Comment for class A"
5151
string(15) "Method A::bla()"
52+
53+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
5254
bool(false)
55+
56+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
5357
bool(false)
5458
string(22) "* Comment for A::baz()"

ext/reflection/tests/ReflectionClass_constructor_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ ReflectionClass::__construct() expects exactly 1 argument, 0 given
5050

5151
Deprecated: ReflectionClass::__construct(): Passing null to parameter #1 ($objectOrClass) of type object|string is deprecated in %s on line %d
5252
Class "" does not exist
53+
54+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
5355
Class "1" does not exist
5456
Class "1" does not exist
5557
ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given

ext/reflection/tests/ReflectionClass_getConstant_error.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ var_dump($rc->getConstant(1));
1212
var_dump($rc->getConstant(1.5));
1313
var_dump($rc->getConstant(true));
1414
?>
15-
--EXPECT--
15+
--EXPECTF--
1616
Check invalid params:
1717
bool(false)
1818
bool(false)
19+
20+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
1921
bool(false)

ext/reflection/tests/ReflectionClass_getMethod_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Deprecated: ReflectionClass::getMethod(): Passing null to parameter #1 ($name) o
6363
Method C::() does not exist
6464
Method C::1() does not exist
6565
Method C::1.5() does not exist
66+
67+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6668
Method C::1() does not exist
6769
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given
6870
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given

ext/reflection/tests/ReflectionClass_getProperty_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name)
6161
Property C::$ does not exist
6262
Property C::$1 does not exist
6363
Property C::$1.5 does not exist
64+
65+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6466
Property C::$1 does not exist
6567
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given
6668
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given

ext/reflection/tests/ReflectionClass_hasConstant_002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ var_dump($rc->hasConstant(1));
1515
var_dump($rc->hasConstant(1.5));
1616
var_dump($rc->hasConstant(true));
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
1919
Check invalid params:
2020
bool(false)
2121
bool(false)
22+
23+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
2224
bool(false)

ext/reflection/tests/ReflectionClass_hasMethod_002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ var_dump($rc->hasMethod(1));
1515
var_dump($rc->hasMethod(1.5));
1616
var_dump($rc->hasMethod(true));
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
1919
Check invalid params:
2020
bool(false)
2121
bool(false)
22+
23+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
2224
bool(false)

ext/reflection/tests/ReflectionClass_hasProperty_002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ var_dump($rc->hasProperty(1));
1515
var_dump($rc->hasProperty(1.5));
1616
var_dump($rc->hasProperty(true));
1717
?>
18-
--EXPECT--
18+
--EXPECTF--
1919
Check invalid params:
2020
bool(false)
2121
bool(false)
22+
23+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
2224
bool(false)

ext/reflection/tests/ReflectionMethod_constructor_error1.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ try {
6565
?>
6666
--EXPECTF--
6767
Wrong type of argument (bool):
68+
69+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6870
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
6971
Stack trace:
7072
#0 %s ReflectionMethod->__construct('1')
@@ -75,11 +77,15 @@ Stack trace:
7577
#0 %s ReflectionMethod->__construct('3')
7678
#1 {main}
7779
Wrong type of argument (bool, string):
80+
81+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
7882
ReflectionException: Class "1" does not exist in %s:%d
7983
Stack trace:
8084
#0 %s ReflectionMethod->__construct('1', 'foo')
8185
#1 {main}
8286
Wrong type of argument (string, bool):
87+
88+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
8389
ReflectionException: Method TestClass::1() does not exist in %s:%d
8490
Stack trace:
8591
#0 %s ReflectionMethod->__construct('TestClass', '1')

ext/reflection/tests/bug64936.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ $rb = new ReflectionClass('B');
2828
var_dump(strip_doc_comment($rb->getDocComment()));
2929

3030
?>
31-
--EXPECT--
31+
--EXPECTF--
32+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
3233
bool(false)
34+
35+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
3336
bool(false)

ext/session/tests/010.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ error_reporting(E_ALL);
1414
$session_array = explode(";", @session_encode());
1515
print "I live\n";
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
1819
I live

ext/session/tests/session_encode_variation8.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Warning: session_start(): Cannot find session serialization handler "blah" - ses
2929
bool(false)
3030

3131
Warning: session_encode(): Cannot encode non-existent session in %s on line %d
32+
33+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
3234
string(0) ""
3335

3436
Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d

ext/session/tests/session_set_save_handler_basic.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ rmdir($path);
6464
*** Testing session_set_save_handler() : basic functionality ***
6565
string(%d) "%s"
6666

67+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
68+
6769
Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
6870
bool(false)
6971

ext/session/tests/session_set_save_handler_closures.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ob_end_flush();
5555
*** Testing session_set_save_handler() : using closures as callbacks ***
5656
string(%d) "%s"
5757

58+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
59+
5860
Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
5961
bool(false)
6062

ext/session/tests/session_set_save_handler_variation1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ ob_end_flush();
2525
*** Testing session_set_save_handler() : variation ***
2626
string(%d) "%s"
2727

28+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
29+
2830
Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
2931
bool(false)
3032
string(%d) "%s"

ext/standard/tests/file/005_variation2.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ echo "Done";
5555

5656
*** testing touch ***
5757

58+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
59+
5860
Warning: Undefined variable $a in %s on line %d
5961
NULL
6062
bool(false)
@@ -65,8 +67,14 @@ bool(true)
6567
*** testing file info ***
6668
-- File '' --
6769
-- File access time is =>
70+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
71+
6872
-- File modification time is =>
73+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
74+
6975
-- inode change time is =>
76+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
77+
7078

7179
-- File '' --
7280
-- File access time is =>

ext/standard/tests/file/file_exists_variation1.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ var_dump(file_exists(' '));
1212
var_dump(file_exists('|'));
1313
echo "Done";
1414
?>
15-
--EXPECT--
15+
--EXPECTF--
1616
*** Testing file_exists() : usage variations ***
17+
18+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
1719
bool(false)
1820
bool(false)
1921
bool(false)

ext/standard/tests/file/file_get_contents_variation8.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ Warning: file_get_contents(-1): Failed to open stream: No such file or directory
4949
bool(false)
5050
-- Iteration 1 --
5151

52+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
53+
5254
Warning: file_get_contents(1): Failed to open stream: No such file or directory in %s on line %d
5355
bool(false)
5456
-- Iteration 2 --
57+
58+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
5559
ValueError: Path cannot be empty
5660
-- Iteration 3 --
5761
ValueError: Path cannot be empty

ext/standard/tests/file/file_put_contents_variation8.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ echo "\n*** Done ***\n";
5757
-- Iteration 0 --
5858
9 bytes written to: '-1'
5959
-- Iteration 1 --
60+
61+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6062
9 bytes written to: '1'
63+
64+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6165
-- Iteration 2 --
66+
67+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
6268
ValueError: Path cannot be empty
6369
-- Iteration 3 --
6470
ValueError: Path cannot be empty

ext/standard/tests/file/filegroup_variation2.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ Warning: filegroup(): stat failed for in %s on line %d
4040
bool(false)
4141
bool(false)
4242

43+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
44+
4345
Warning: filegroup(): stat failed for 1 in %s on line %d
4446
bool(false)
47+
48+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
4549
bool(false)
4650

4751
Warning: filegroup(): stat failed for 1234 in %s on line %d

ext/standard/tests/file/fileinode_variation2.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ Warning: fileinode(): stat failed for in %s on line %d
4040
bool(false)
4141
bool(false)
4242

43+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
44+
4345
Warning: fileinode(): stat failed for 1 in %s on line %d
4446
bool(false)
47+
48+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
4549
bool(false)
4650

4751
Warning: fileinode(): stat failed for 1234 in %s on line %d

ext/standard/tests/file/fileowner_variation2.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ Warning: fileowner(): stat failed for in %s on line %d
4141
bool(false)
4242
bool(false)
4343

44+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
45+
4446
Warning: fileowner(): stat failed for 1 in %s on line %d
4547
bool(false)
48+
49+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
4650
bool(false)
4751

4852
Warning: fileowner(): stat failed for 1234 in %s on line %d

ext/standard/tests/file/fileperms_variation2.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ Warning: fileperms(): stat failed for in %s on line %d
4040
bool(false)
4141
bool(false)
4242

43+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
44+
4345
Warning: fileperms(): stat failed for 1 in %s on line %d
4446
bool(false)
47+
48+
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
4549
bool(false)
4650

4751
Warning: fileperms(): stat failed for 1234 in %s on line %d

0 commit comments

Comments
 (0)