Skip to content

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

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 4 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
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 @@ Notice: Undefined variable: ref in %sbug43201.php on line 14

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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

Notice: Undefined variable: undef in %sbug43201.php on line 16

Deprecated: Passing null to argument of type string is deprecated in %s on line 16

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/bug54265.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function my_errorhandler($errno,$errormsg) {
echo "EROOR: $errormsg\n";
}
set_error_handler("my_errorhandler");
$my_var = str_repeat("A",$my_var[0]->errormsg = "xyz");
$my_var = array_fill_keys(["A"], $my_var[0]->errormsg = "xyz");
echo "ok\n";
?>
--EXPECT--
Expand Down
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: 2 additions & 0 deletions Zend/tests/class_exists_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var_dump(class_exists(new stdClass));
?>
--EXPECTF--
bool(false)

Deprecated: Passing null to argument of type string is deprecated in %s on line %d
bool(false)
bool(true)
bool(false)
Expand Down
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: 2 additions & 0 deletions Zend/tests/interface_exists_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var_dump(interface_exists(new stdClass));
--EXPECTF--
bool(true)
bool(false)

Deprecated: Passing null to argument of type string is deprecated in %s on line %d
bool(false)

Warning: interface_exists() expects parameter 1 to be string, object given in %s on line %d
Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/trait_exists_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var_dump(trait_exists(new stdClass));
--EXPECTF--
bool(true)
bool(false)

Deprecated: Passing null to argument of type string is deprecated in %s on line %d
bool(false)

Warning: trait_exists() expects parameter 1 to be string, object given in %s on line %d
Expand Down
15 changes: 15 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc
ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
zend_error(E_DEPRECATED, "Passing null to argument of type bool is deprecated");
}
*dest = zend_is_true(arg);
} else {
return 0;
Expand Down Expand Up @@ -411,6 +414,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
}
}
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
zend_error(E_DEPRECATED, "Passing null to argument of type int is deprecated");
}
*dest = 0;
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
*dest = 1;
Expand Down Expand Up @@ -452,6 +458,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *de
}
}
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
zend_error(E_DEPRECATED, "Passing null to argument of type int is deprecated");
}
*dest = 0;
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
*dest = 1;
Expand Down Expand Up @@ -487,6 +496,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /
}
}
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
zend_error(E_DEPRECATED, "Passing null to argument of type float is deprecated");
}
*dest = 0.0;
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
*dest = 1.0;
Expand All @@ -512,6 +524,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /
ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
zend_error(E_DEPRECATED, "Passing null to argument of type string is deprecated");
}
convert_to_string(arg);
*dest = Z_STR_P(arg);
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
Expand Down
4 changes: 2 additions & 2 deletions ext/phar/tests/files/phar_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ foreach($files as $name => $cont)
if (empty($ulen)) $ulen = strlen($cont);
if (empty($clen)) $clen = strlen($comp);
if (empty($crc32))$crc32= crc32((binary)$cont);
if (isset($meta)) $meta = serialize($meta);
$meta = isset($meta) ? serialize($meta) : '';

// write manifest entry
$manifest .= pack('V', strlen($name)) . (binary)$name;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
$manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;

// globals
$gflags |= $flags;
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/array/array_filter_variation9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ array(6) {
}

Warning: chr() expects parameter 1 to be int, string given in %s on line %d

Deprecated: Passing null to argument of type int is deprecated in %s on line %d
array(8) {
[0]=>
int(0)
Expand Down
10 changes: 6 additions & 4 deletions ext/standard/tests/array/count_recursive.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ For mode '-1.45' count is => int(3)
For mode '2' count is => int(3)
For mode '1' count is => int(9)
For mode '' count is => int(3)
For mode '' count is => int(3)
For mode '' count is =>
Deprecated: Passing null to argument of type int is deprecated in %s on line %d
int(3)

-- Testing error conditions --
Warning: count() expects at least 1 parameter, 0 given in %s on line %d
Expand All @@ -239,13 +241,13 @@ NULL

Warning: Use of undefined constant ABCD - assumed 'ABCD' (this will throw an Error in a future version of PHP) in %s on line %d

Warning: count() expects parameter 2 to be int, %s given in %s on line %d
Warning: count() expects parameter 2 to be int, string given in %s on line %d
NULL

Warning: count() expects parameter 2 to be int, %s given in %s on line %d
Warning: count() expects parameter 2 to be int, string given in %s on line %d
NULL

Warning: count() expects parameter 2 to be int, %s given in %s on line %d
Warning: count() expects parameter 2 to be int, string given in %s on line %d
NULL

Done
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 @@ -77,6 +77,8 @@ echo "Done";
*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***

*** testing touch ***

Deprecated: Passing null to argument of type string is deprecated in %s on line %d
bool(false)
bool(false)
bool(false)
Expand All @@ -86,8 +88,14 @@ bool(true)
*** testing file info ***
-- File '' --
-- File access time is =>
Deprecated: Passing null to argument of type string is deprecated in %s on line %d

-- File modification time is =>
Deprecated: Passing null to argument of type string is deprecated in %s on line %d

-- inode change time is =>
Deprecated: Passing null to argument of type string is deprecated in %s on line %d


-- File '' --
-- File access time is =>
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/007_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ Warning: feof() expects parameter 1 to be resource, object given in %s on line %
bool(false)
-- Iteration 7 --

Deprecated: Passing null to argument of type string is deprecated in %s on line %d

Warning: fopen(): Filename cannot be empty in %s on line %d
bool(false)

Expand Down
Binary file modified ext/standard/tests/file/basename.phpt
Binary file not shown.
4 changes: 3 additions & 1 deletion ext/standard/tests/file/basename_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ foreach ($file_paths as $file_path) {
}

?>
--EXPECT--
--EXPECTF--
string(3) "bar"
string(3) "bar"
string(3) "bar"
Expand Down Expand Up @@ -98,4 +98,6 @@ string(1) " "
string(1) " "
string(0) ""
string(0) ""

Deprecated: Passing null to argument of type string is deprecated in %s on line %d
string(0) ""
10 changes: 5 additions & 5 deletions ext/standard/tests/file/bug51094.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Fixed bug #51094 (parse_ini_file() with INI_SCANNER_RAW cuts a value that includ
--FILE--
<?php

$ini = parse_ini_string('ini="ini;raw"', null, INI_SCANNER_RAW);
$ini = parse_ini_string('ini="ini;raw"', false, INI_SCANNER_RAW);
var_dump($ini['ini']);
$ini = parse_ini_string('ini="ini;raw', null, INI_SCANNER_RAW);
$ini = parse_ini_string('ini="ini;raw', false, INI_SCANNER_RAW);
var_dump($ini['ini']);
$ini = parse_ini_string('ini=ini;raw', null, INI_SCANNER_RAW);
$ini = parse_ini_string('ini=ini;raw', false, INI_SCANNER_RAW);
var_dump($ini['ini']);
$ini = parse_ini_string('ini=ini"raw', null, INI_SCANNER_RAW);
$ini = parse_ini_string('ini=ini"raw', false, INI_SCANNER_RAW);
var_dump($ini['ini']);
$ini = parse_ini_string("ini=\r\niniraw", null, INI_SCANNER_RAW);
$ini = parse_ini_string("ini=\r\niniraw", false, INI_SCANNER_RAW);
var_dump($ini['ini']);
--EXPECT--
string(7) "ini;raw"
Expand Down
5 changes: 4 additions & 1 deletion ext/standard/tests/file/bug61961.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10));
unlink($tmp_empty_file);
?>
==DONE==
--EXPECT--
--EXPECTF--
Deprecated: Passing null to argument of type bool is deprecated in %s on line %d

Deprecated: Passing null to argument of type int is deprecated in %s on line %d
string(0) ""
==DONE==
Loading