Skip to content

RFC: Deprecate type juggling to and from bool for function type juggling context #18879

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

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6eefa34
Zend/zend_execute: make some functions private
Girgias Jun 19, 2025
68958a8
Deprecate type juggling to/from bool for function context
Girgias Jun 19, 2025
49313ac
fix some tests
Girgias Jun 19, 2025
15ab227
Fix
Girgias Jun 20, 2025
194a1a6
tests: Fix tests affected by bool type juggling deprecation
Girgias Jun 20, 2025
6674fff
ext/date: Fix tests
Girgias Jun 20, 2025
863b5ae
ext/filter: Remove ZPP test
Girgias Jun 20, 2025
7451eca
ext/calendar: Remove ZPP test
Girgias Jun 20, 2025
e5bd04e
ext/mbstring: Remove ZPP tests
Girgias Jun 20, 2025
b3447a3
ext/phar: Fix tests [WIP]
Girgias Jun 20, 2025
81069bd
ext/reflection: Remove ZPP tests and use bool
Girgias Jun 20, 2025
c5fad3b
ext/standard/tests/array: Fix tests and remove ZPP tests
Girgias Jun 20, 2025
3eed3b2
ext/standard/tests/file: Fix most tests and remove ZPP tests
Girgias Jun 20, 2025
7531938
ext/standard/tests/general_functions: Fix tests and remove ZPP tests
Girgias Jun 21, 2025
5a40dec
ext/standard/tests/http: Fix tests
Girgias Jun 21, 2025
c699b28
ext/standard/tests/math: Fix tests and remove ZPP tests
Girgias Jun 21, 2025
81082e0
ext/standard/tests/misc: Fix tests
Girgias Jun 21, 2025
1af771d
ext/standard/tests/network: Fix tests
Girgias Jun 21, 2025
5bfff08
ext/standard/tests/url: Fix tests
Girgias Jun 21, 2025
67af7c3
ext/standard/tests/streams: Fix tests
Girgias Jun 21, 2025
737b20f
ext/standard/tests/strings: W.I.P. Fix tests and remove ZPP tests
Girgias Jun 21, 2025
8f5f75b
ext/json: Remove bool type coercions in tests
Girgias Jun 21, 2025
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: 0 additions & 2 deletions Zend/tests/017.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var_dump(count(get_defined_functions()));
var_dump(gettype(get_declared_interfaces()));
var_dump(count(get_declared_interfaces()));

var_dump(get_extension_funcs(true));
var_dump(gettype(get_extension_funcs("standard")));
var_dump(count(get_extension_funcs("standard")));
var_dump(gettype(get_extension_funcs("zend")));
Expand All @@ -51,7 +50,6 @@ string(5) "array"
int(%d)
string(5) "array"
int(%d)
bool(false)
string(5) "array"
int(%d)
string(5) "array"
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/arrow_functions/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ try {
}

try {
assert((fn&(int... $args): ?bool => $args[0])(false));
assert((fn&(int... $args): ?int => $args[0])(0));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}

?>
--EXPECT--
assert(): assert((fn() => false)()) failed
assert(): assert((fn&(int ...$args): ?bool => $args[0])(false)) failed
assert(): assert((fn&(int ...$args): ?int => $args[0])(0)) failed
142 changes: 3 additions & 139 deletions Zend/tests/backtrace/debug_backtrace_options.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ function doit($a, $b, $how)
{
echo "==default\n";
$how();
echo "==true\n";
$how(true);
echo "==false\n";
$how(false);
echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n";
$how(DEBUG_BACKTRACE_PROVIDE_OBJECT);
echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n";
Expand Down Expand Up @@ -48,14 +44,6 @@ foo::statCall("doit", "backtrace_print");
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
==true
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
==false
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
#2 %sdebug_backtrace_options.php(%d): foo::statCall('doit', 'debug_print_bac...')
==DEBUG_BACKTRACE_PROVIDE_OBJECT
#0 %sdebug_backtrace_options.php(%d): doit('a', 'b', 'debug_print_bac...')
#1 %sdebug_backtrace_options.php(%d): foo->doCall('doit', 'debug_print_bac...')
Expand Down Expand Up @@ -130,138 +118,14 @@ Array

)

)
==true
Array
(
[0] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => 17
[function] => backtrace_print
[args] => Array
(
[0] => 1
)

)

[1] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => doit
[args] => Array
(
[0] => a
[1] => b
[2] => backtrace_print
)

)

[2] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => doCall
[class] => foo
[object] => foo Object
(
)

[type] => ->
[args] => Array
(
[0] => doit
[1] => backtrace_print
)

)

[3] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => statCall
[class] => foo
[type] => ::
[args] => Array
(
[0] => doit
[1] => backtrace_print
)

)

)
==false
Array
(
[0] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => 19
[function] => backtrace_print
[args] => Array
(
[0] =>
)

)

[1] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => doit
[args] => Array
(
[0] => a
[1] => b
[2] => backtrace_print
)

)

[2] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => doCall
[class] => foo
[type] => ->
[args] => Array
(
[0] => doit
[1] => backtrace_print
)

)

[3] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => %d
[function] => statCall
[class] => foo
[type] => ::
[args] => Array
(
[0] => doit
[1] => backtrace_print
)

)

)
==DEBUG_BACKTRACE_PROVIDE_OBJECT
Array
(
[0] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => 21
[line] => 17
[function] => backtrace_print
[args] => Array
(
Expand Down Expand Up @@ -325,7 +189,7 @@ Array
[0] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => 23
[line] => 19
[function] => backtrace_print
)

Expand Down Expand Up @@ -361,7 +225,7 @@ Array
[0] => Array
(
[file] => %sdebug_backtrace_options.php
[line] => 25
[line] => 21
[function] => backtrace_print
)

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug36513.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bug #36513 (comment will be output in last line)
--FILE--
<?php
function test($s) {
echo "'".trim(str_replace("&nbsp;", " ", htmlspecialchars_decode(strip_tags(highlight_string($s,1)))))."'\n";
echo "'".trim(str_replace("&nbsp;", " ", htmlspecialchars_decode(strip_tags(highlight_string($s, true)))))."'\n";
}

eval('echo "1";//2');
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/bug39944.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ addToArray($b, "xx3");
addToArray(getArray(), "xx4");
$a = getArray();
addToArray($a, "xx5");
echo "arrTheArray = " . print_r($arrTheArray, 1);
echo "arrTheArray = " . print_r($arrTheArray, true);

/****/

Expand All @@ -69,7 +69,7 @@ $objRefTest->Add("xx1");
$objRefTest->Add("xx2");
$objRefTest->Add("xx3");

echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), 1);
echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), true);
?>
--EXPECT--
intTheValue = 10
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/bug79022.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bug #79022 (class_exists returns True for classes that are not ready to be used)
--FILE--
<?php
function my_autoloader($class) {
if (class_exists('Foo', 0)) {
if (class_exists('Foo', false)) {
new Foo();
}
if ($class == 'Foo') {
Expand All @@ -19,7 +19,7 @@ function my_autoloader($class) {
}


if (interface_exists('iFoo', 0)) {
if (interface_exists('iFoo', false)) {
new Dummy();
}
if ($class == 'iFoo') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ declare(strict_types=1);
namespace Foo;

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

?>
--EXPECT--
int(0)
int(2)
2 changes: 1 addition & 1 deletion Zend/tests/class_alias/class_alias_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spl_autoload_register(function ($a) {
class foo { }
});

class_alias('foo', 'bar', 1);
class_alias('foo', 'bar', true);

var_dump(new foo, new bar);

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/dynamic_call/bug47880.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bug #47880 (crashes in call_user_func_array())
<?php
class bomb {
static function go($n) {
$backtrace = debug_backtrace(false);
$backtrace = debug_backtrace(0);
$backtrace[1]['args'][1] = 'bomb';
}
}
Expand Down
10 changes: 5 additions & 5 deletions Zend/tests/exit/exit_values.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
exit(false);
Exit with different values
--FILE--
<?php

Expand Down Expand Up @@ -84,11 +84,11 @@ Deprecated: exit(): Passing null to parameter #1 ($status) of type string|int is
Using false as value:
Exit status is: 0
Output is:

Deprecated: exit(): Passing bool to parameter #1 ($status) of type string|int is deprecated in %s on line %d
Using true as value:
Exit status is: 1
Output is:

Deprecated: exit(): Passing bool to parameter #1 ($status) of type string|int is deprecated in %s on line %d
Using 0 as value:
Exit status is: 0
Output is:
Expand Down Expand Up @@ -136,11 +136,11 @@ Deprecated: exit(): Passing null to parameter #1 ($status) of type string|int is
Using false as value:
Exit status is: 0
Output is:

Deprecated: exit(): Passing bool to parameter #1 ($status) of type string|int is deprecated in %s on line %d
Using true as value:
Exit status is: 1
Output is:

Deprecated: exit(): Passing bool to parameter #1 ($status) of type string|int is deprecated in %s on line %d
Using 0 as value:
Exit status is: 0
Output is:
Expand Down
8 changes: 8 additions & 0 deletions Zend/tests/number_or_str_zpp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ float(5.5)

Deprecated: zend_number_or_string(): Passing null to parameter #1 ($param) of type string|int|float is deprecated in %s on line %d
int(0)

Deprecated: zend_number_or_string(): Passing bool to parameter #1 ($param) of type string|int|float is deprecated in %s on line %d
int(0)

Deprecated: zend_number_or_string(): Passing bool to parameter #1 ($param) of type string|int|float is deprecated in %s on line %d
int(1)
string(8) "ToString"
zend_string_or_object(): Argument #1 ($param) must be of type object|string, array given
Expand All @@ -67,7 +71,11 @@ string(6) "string"
int(1)
float(5.5)
NULL

Deprecated: zend_number_or_string_or_null(): Passing bool to parameter #1 ($param) of type string|int|float|null is deprecated in %s on line %d
int(0)

Deprecated: zend_number_or_string_or_null(): Passing bool to parameter #1 ($param) of type string|int|float|null is deprecated in %s on line %d
int(1)
string(8) "ToString"
zend_number_or_string_or_null(): Argument #1 ($param) must be of type string|int|float|null, array given
Expand Down
4 changes: 3 additions & 1 deletion Zend/tests/property_hooks/recursion.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ var_dump(isset($test->prop2));
var_dump($test);

?>
--EXPECT--
--EXPECTF--
int(40)
bool(true)

Deprecated: Test::$prop2::get(): Returning type bool which is implicitly converted to type int is deprecated in %s on line %d
bool(true)
object(Test)#1 (1) {
["prop"]=>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ try {
}

?>
--EXPECT--
--EXPECTF--
Deprecated: P::foo(): Returning type int which is implicitly converted to type bool is deprecated in %s on line %d
bool(false)
C::foo(): Return value must be of type array|false, int returned
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ try {
}

?>
--EXPECT--
--EXPECTF--
Deprecated: P::foo(): Returning type int which is implicitly converted to type bool is deprecated in %s on line %d
bool(true)
C::foo(): Return value must be of type array|true, int returned
Loading
Loading