Skip to content

Deprecate passing null to non-nullable arg of internal function #6475

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 14 commits into from
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions Zend/tests/bug43201.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,37 @@ Warning: Undefined variable $ref in %s on line %d

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17

Warning: Undefined variable $undef in %s on line %d

Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d

Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
ok
2 changes: 1 addition & 1 deletion Zend/tests/bug64677.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class cat {
}
}
$cat = new cat();
$cat->show_output('Files: ', trim(`cd .`)); // this gives invalid args to shell_exec
$cat->show_output('Files: ', trim((string) `cd .`)); // this gives invalid args to shell_exec
$cat->show_output('Files: ', `cd .`); // this causes a segmentation fault
$cat->show_output(`cd .`); // this causes a segmentation fault

Expand Down
2 changes: 0 additions & 2 deletions Zend/tests/class_exists_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ class foo {
}

var_dump(class_exists(''));
var_dump(class_exists(NULL));
var_dump(class_exists('FOO'));
var_dump(class_exists('bar'));
var_dump(class_exists(1));

?>
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
2 changes: 1 addition & 1 deletion Zend/tests/exception_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ try {
try {
try {
try {
throw new Exception(NULL);
throw new Exception();
} catch (Exception $e) {
var_dump($e->getMessage());
throw $e;
Expand Down
2 changes: 0 additions & 2 deletions Zend/tests/interface_exists_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ interface foo {

var_dump(interface_exists('foo'));
var_dump(interface_exists(1));
var_dump(interface_exists(NULL));

?>
--EXPECT--
bool(true)
bool(false)
bool(false)
12 changes: 12 additions & 0 deletions Zend/tests/null_to_non_nullable_special_func.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Test null arg behavior for special functions
--FILE--
<?php

$null = null;
var_dump(strlen($null));

?>
--EXPECTF--
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
int(0)
9 changes: 9 additions & 0 deletions Zend/tests/nullsafe_operator/013.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ dump_error(fn() => array_key_exists('foo', $foo?->foo()));

?>
--EXPECTF--
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
int(0)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)

Deprecated: defined(): Passing null to parameter #1 ($constant_name) of type string is deprecated in %s on line %d
bool(false)

Deprecated: chr(): Passing null to parameter #1 ($codepoint) of type int is deprecated in %s on line %d
string(1) "%s"

Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in %s on line %d
int(0)
string(98) "call_user_func_array(): Argument #1 ($function) must be a valid callback, no array or string given"
string(77) "call_user_func_array(): Argument #2 ($args) must be of type array, null given"
Expand All @@ -55,6 +62,8 @@ string(4) "NULL"
string(52) "func_num_args() expects exactly 0 arguments, 1 given"
string(52) "func_get_args() expects exactly 0 arguments, 1 given"
string(69) "array_slice(): Argument #1 ($array) must be of type array, null given"

Deprecated: array_slice(): Passing null to parameter #2 ($offset) of type int is deprecated in %s on line %d
array(1) {
[0]=>
string(3) "foo"
Expand Down
4 changes: 3 additions & 1 deletion Zend/tests/str_or_obj_of_class_zpp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ try {
}

?>
--EXPECT--
--EXPECTF--
string(6) "string"
string(1) "1"

Deprecated: zend_string_or_stdclass(): Passing null to parameter #1 ($param) of type string is deprecated in %s on line %d
string(0) ""
object(stdClass)#1 (0) {
}
Expand Down
4 changes: 3 additions & 1 deletion Zend/tests/str_or_obj_zpp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ try {
}

?>
--EXPECT--
--EXPECTF--
string(6) "string"
string(1) "1"

Deprecated: zend_string_or_object(): Passing null to parameter #1 ($param) of type object|string is deprecated in %s on line %d
string(0) ""
object(stdClass)#1 (0) {
}
Expand Down
2 changes: 0 additions & 2 deletions Zend/tests/trait_exists_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ trait foo {

var_dump(trait_exists('foo'));
var_dump(trait_exists(1));
var_dump(trait_exists(NULL));

?>
--EXPECT--
bool(true)
bool(false)
bool(false)
Loading