Skip to content

Deprecate implicit bool to string coercion #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Zend/tests/017.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ string(5) "array"
int(%d)
string(5) "array"
int(%d)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
string(5) "array"
int(%d)
Expand Down
3 changes: 2 additions & 1 deletion Zend/tests/call_user_func_strict_arginfo_check.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace Foo;
var_dump(call_user_func('strlen', false));

?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
int(0)
2 changes: 2 additions & 0 deletions Zend/tests/type_declarations/scalar_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ string(%d) "%d"
string(3) "NAN"

*** Trying bool(true)
E_DEPRECATED: Implicit bool to string coercion is deprecated on line %d
string(1) "1"

*** Trying bool(false)
E_DEPRECATED: Implicit bool to string coercion is deprecated on line %d
string(0) ""

*** Trying NULL
Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/type_declarations/scalar_return_basic_64bit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ string(19) "9223372036854775807"
*** Trying float(NAN)
string(3) "NAN"
*** Trying bool(true)
E_DEPRECATED: Implicit bool to string coercion is deprecated on line %d
string(1) "1"
*** Trying bool(false)
E_DEPRECATED: Implicit bool to string coercion is deprecated on line %d
string(0) ""
*** Trying NULL
*** Caught {closure}(): Return value must be of type string, null returned in %s on line %d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ INF => "INF"
"42x" => "42x"
"x" => "x"
"" => ""
true => "1"
false => ""
true => "1" (Implicit bool to string coercion is deprecated)
false => "" (Implicit bool to string coercion is deprecated)
null => Argument ... must be of type array|string, null given
[] => []
new stdClass => Argument ... must be of type array|string, stdClass given
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **des
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
return 0;
}
if (UNEXPECTED(Z_TYPE_P(arg) == IS_TRUE || Z_TYPE_P(arg) == IS_FALSE)) {
zend_error(E_DEPRECATED, "Implicit bool to string coercion is deprecated");
}
convert_to_string(arg);
*dest = Z_STR_P(arg);
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
Expand Down
4 changes: 4 additions & 0 deletions ext/iconv/tests/bug48147.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ bool(false)
string(10) "aa%C3%B8aa"

Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
string(0) ""
string(8) "%C3%B8aa"

Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
string(0) ""
2 changes: 2 additions & 0 deletions ext/iconv/tests/iconv_mime_decode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ do_regression_test();
(32) "Subject: Prüfung PrüfungkůÔńÓlet"
(31) "Subject: PrüfungPrüfungkůÔńÓlet"
2: iconv_mime_decode(): Malformed string
8192: Implicit bool to string coercion is deprecated
(0) ""
(27) "From: サンプル文字列サンプル文字列日本語テキスト"
(31) "Subject: PrüfungPrüfungkůÔńÓlet"
(32) "Subject: Prüfung PrüfungkůÔńÓlet"
(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?="
2: iconv_mime_decode(): Malformed string
8192: Implicit bool to string coercion is deprecated
(0) ""
(27) "From: サンプル文字列サンプル文字列日本語テキスト"
(31) "Subject: PrüfungPrüfungkůÔńÓlet"
Expand Down
5 changes: 4 additions & 1 deletion ext/json/tests/bug69187.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var_dump(json_last_error());
json_decode("\"\x00\"");
var_dump(json_last_error());
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
NULL
int(4)
NULL
Expand All @@ -35,6 +36,8 @@ int(0)
int(0)
int(1)
int(0)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
int(1)
int(0)
int(5)
Expand Down
8 changes: 4 additions & 4 deletions ext/pdo/tests/pdo_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class PDOTest {
// create an instance of the PDO driver, based on
// the current environment
static function factory($classname = 'PDO', $drop_test_tables = true) {
$dsn = getenv('PDOTEST_DSN');
$user = getenv('PDOTEST_USER');
$pass = getenv('PDOTEST_PASS');
$attr = getenv('PDOTEST_ATTR');
$dsn = getenv('PDOTEST_DSN') ?: '';
$user = getenv('PDOTEST_USER') ?: '';
$pass = getenv('PDOTEST_PASS') ?: '';
$attr = getenv('PDOTEST_ATTR') ?: '';
if (is_string($attr) && strlen($attr)) {
$attr = unserialize($attr);
} else {
Expand Down
6 changes: 5 additions & 1 deletion ext/reflection/tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ foreach($r->getMethods() as $m)
}

?>
--EXPECT--
--EXPECTF--
string(19) "Comment for class A"
string(15) "Method A::bla()"

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
string(22) "* Comment for A::baz()"
2 changes: 2 additions & 0 deletions ext/reflection/tests/ReflectionClass_constructor_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ ReflectionClass::__construct() expects exactly 1 argument, 0 given

Deprecated: ReflectionClass::__construct(): Passing null to parameter #1 ($objectOrClass) of type object|string is deprecated in %s on line %d
Class "" does not exist

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
Class "1" does not exist
Class "1" does not exist
ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given
Expand Down
4 changes: 3 additions & 1 deletion ext/reflection/tests/ReflectionClass_getConstant_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ var_dump($rc->getConstant(1));
var_dump($rc->getConstant(1.5));
var_dump($rc->getConstant(true));
?>
--EXPECT--
--EXPECTF--
Check invalid params:
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
2 changes: 2 additions & 0 deletions ext/reflection/tests/ReflectionClass_getMethod_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Deprecated: ReflectionClass::getMethod(): Passing null to parameter #1 ($name) o
Method C::() does not exist
Method C::1() does not exist
Method C::1.5() does not exist

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
Method C::1() does not exist
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, array given
ReflectionClass::getMethod(): Argument #1 ($name) must be of type string, C given
2 changes: 2 additions & 0 deletions ext/reflection/tests/ReflectionClass_getProperty_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name)
Property C::$ does not exist
Property C::$1 does not exist
Property C::$1.5 does not exist

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
Property C::$1 does not exist
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given
ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given
4 changes: 3 additions & 1 deletion ext/reflection/tests/ReflectionClass_hasConstant_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ var_dump($rc->hasConstant(1));
var_dump($rc->hasConstant(1.5));
var_dump($rc->hasConstant(true));
?>
--EXPECT--
--EXPECTF--
Check invalid params:
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
4 changes: 3 additions & 1 deletion ext/reflection/tests/ReflectionClass_hasMethod_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ var_dump($rc->hasMethod(1));
var_dump($rc->hasMethod(1.5));
var_dump($rc->hasMethod(true));
?>
--EXPECT--
--EXPECTF--
Check invalid params:
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
4 changes: 3 additions & 1 deletion ext/reflection/tests/ReflectionClass_hasProperty_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ var_dump($rc->hasProperty(1));
var_dump($rc->hasProperty(1.5));
var_dump($rc->hasProperty(true));
?>
--EXPECT--
--EXPECTF--
Check invalid params:
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
6 changes: 6 additions & 0 deletions ext/reflection/tests/ReflectionMethod_constructor_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ try {
?>
--EXPECTF--
Wrong type of argument (bool):

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('1')
Expand All @@ -75,11 +77,15 @@ Stack trace:
#0 %s ReflectionMethod->__construct('3')
#1 {main}
Wrong type of argument (bool, string):

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
ReflectionException: Class "1" does not exist in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('1', 'foo')
#1 {main}
Wrong type of argument (string, bool):

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
ReflectionException: Method TestClass::1() does not exist in %s:%d
Stack trace:
#0 %s ReflectionMethod->__construct('TestClass', '1')
Expand Down
5 changes: 4 additions & 1 deletion ext/reflection/tests/bug64936.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ $rb = new ReflectionClass('B');
var_dump(strip_doc_comment($rb->getDocComment()));

?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
3 changes: 2 additions & 1 deletion ext/session/tests/010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ error_reporting(E_ALL);
$session_array = explode(";", @session_encode());
print "I live\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
I live
2 changes: 2 additions & 0 deletions ext/session/tests/session_encode_variation8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Warning: session_start(): Cannot find session serialization handler "blah" - ses
bool(false)

Warning: session_encode(): Cannot encode non-existent session in %s on line %d

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
string(0) ""

Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d
Expand Down
2 changes: 2 additions & 0 deletions ext/session/tests/session_set_save_handler_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ rmdir($path);
*** Testing session_set_save_handler() : basic functionality ***
string(%d) "%s"

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
bool(false)

Expand Down
2 changes: 2 additions & 0 deletions ext/session/tests/session_set_save_handler_closures.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ ob_end_flush();
*** Testing session_set_save_handler() : using closures as callbacks ***
string(%d) "%s"

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
bool(false)

Expand Down
2 changes: 2 additions & 0 deletions ext/session/tests/session_set_save_handler_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ob_end_flush();
*** Testing session_set_save_handler() : variation ***
string(%d) "%s"

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
bool(false)
string(%d) "%s"
Expand Down
8 changes: 8 additions & 0 deletions ext/standard/tests/file/005_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ echo "Done";

*** testing touch ***

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: Undefined variable $a in %s on line %d
NULL
bool(false)
Expand All @@ -65,8 +67,14 @@ bool(true)
*** testing file info ***
-- File '' --
-- File access time is =>
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

-- File modification time is =>
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

-- inode change time is =>
Deprecated: Implicit bool to string coercion is deprecated in %s on line %d


-- File '' --
-- File access time is =>
Expand Down
4 changes: 3 additions & 1 deletion ext/standard/tests/file/file_exists_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ var_dump(file_exists(' '));
var_dump(file_exists('|'));
echo "Done";
?>
--EXPECT--
--EXPECTF--
*** Testing file_exists() : usage variations ***

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)
bool(false)
bool(false)
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/file/file_get_contents_variation8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ Warning: file_get_contents(-1): Failed to open stream: No such file or directory
bool(false)
-- Iteration 1 --

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: file_get_contents(1): Failed to open stream: No such file or directory in %s on line %d
bool(false)
-- Iteration 2 --

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
ValueError: Path cannot be empty
-- Iteration 3 --
ValueError: Path cannot be empty
Expand Down
6 changes: 6 additions & 0 deletions ext/standard/tests/file/file_put_contents_variation8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ echo "\n*** Done ***\n";
-- Iteration 0 --
9 bytes written to: '-1'
-- Iteration 1 --

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
9 bytes written to: '1'

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
-- Iteration 2 --

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
ValueError: Path cannot be empty
-- Iteration 3 --
ValueError: Path cannot be empty
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/file/filegroup_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ Warning: filegroup(): stat failed for in %s on line %d
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: filegroup(): stat failed for 1 in %s on line %d
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)

Warning: filegroup(): stat failed for 1234 in %s on line %d
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/file/fileinode_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ Warning: fileinode(): stat failed for in %s on line %d
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: fileinode(): stat failed for 1 in %s on line %d
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)

Warning: fileinode(): stat failed for 1234 in %s on line %d
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/file/fileowner_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ Warning: fileowner(): stat failed for in %s on line %d
bool(false)
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d

Warning: fileowner(): stat failed for 1 in %s on line %d
bool(false)

Deprecated: Implicit bool to string coercion is deprecated in %s on line %d
bool(false)

Warning: fileowner(): stat failed for 1234 in %s on line %d
Expand Down
Loading