Skip to content

Commit c612845

Browse files
committed
Deprecate passing null to non-nullable internal arg
A lot of test updates missing.
1 parent ac9ce0f commit c612845

File tree

10 files changed

+36
-3
lines changed

10 files changed

+36
-3
lines changed

Zend/tests/bug43201.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,37 @@ Notice: Undefined variable: ref in %sbug43201.php on line 14
3030

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

33+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
34+
3335
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
3436

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

39+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
40+
3741
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
3842

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

45+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
46+
4147
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
4248

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

51+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
52+
4553
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
4654

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

57+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
58+
4959
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
5060

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

63+
Deprecated: Passing null to argument of type string is deprecated in %s on line 16
64+
5365
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
5466
ok

Zend/tests/bug54265.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function my_errorhandler($errno,$errormsg) {
88
echo "EROOR: $errormsg\n";
99
}
1010
set_error_handler("my_errorhandler");
11-
$my_var = str_repeat("A",$my_var[0]->errormsg = "xyz");
11+
$my_var = array_fill_keys(["A"], $my_var[0]->errormsg = "xyz");
1212
echo "ok\n";
1313
?>
1414
--EXPECT--

Zend/tests/bug64677.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class cat {
77
}
88
}
99
$cat = new cat();
10-
$cat->show_output('Files: ', trim(`cd .`)); // this gives invalid args to shell_exec
10+
$cat->show_output('Files: ', trim((string) `cd .`)); // this gives invalid args to shell_exec
1111
$cat->show_output('Files: ', `cd .`); // this causes a segmentation fault
1212
$cat->show_output(`cd .`); // this causes a segmentation fault
1313

Zend/tests/class_exists_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var_dump(class_exists(new stdClass));
1717
?>
1818
--EXPECTF--
1919
bool(false)
20+
21+
Deprecated: Passing null to argument of type string is deprecated in %s on line %d
2022
bool(false)
2123
bool(true)
2224
bool(false)

Zend/tests/exception_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ try {
77
try {
88
try {
99
try {
10-
throw new Exception(NULL);
10+
throw new Exception();
1111
} catch (Exception $e) {
1212
var_dump($e->getMessage());
1313
throw $e;

Zend/tests/interface_exists_001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var_dump(interface_exists(new stdClass));
1515
--EXPECTF--
1616
bool(true)
1717
bool(false)
18+
19+
Deprecated: Passing null to argument of type string is deprecated in %s on line %d
1820
bool(false)
1921

2022
Warning: interface_exists() expects parameter 1 to be string, object given in %s on line %d

Zend/tests/trait_exists_001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var_dump(trait_exists(new stdClass));
1515
--EXPECTF--
1616
bool(true)
1717
bool(false)
18+
19+
Deprecated: Passing null to argument of type string is deprecated in %s on line %d
1820
bool(false)
1921

2022
Warning: trait_exists() expects parameter 1 to be string, object given in %s on line %d

Zend/zend_API.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc
364364
ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */
365365
{
366366
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
367+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
368+
zend_error(E_DEPRECATED, "Passing null to argument of type bool is deprecated");
369+
}
367370
*dest = zend_is_true(arg);
368371
} else {
369372
return 0;
@@ -411,6 +414,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
411414
}
412415
}
413416
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
417+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
418+
zend_error(E_DEPRECATED, "Passing null to argument of type int is deprecated");
419+
}
414420
*dest = 0;
415421
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
416422
*dest = 1;
@@ -452,6 +458,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *de
452458
}
453459
}
454460
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
461+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
462+
zend_error(E_DEPRECATED, "Passing null to argument of type int is deprecated");
463+
}
455464
*dest = 0;
456465
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
457466
*dest = 1;
@@ -487,6 +496,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /
487496
}
488497
}
489498
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
499+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
500+
zend_error(E_DEPRECATED, "Passing null to argument of type float is deprecated");
501+
}
490502
*dest = 0.0;
491503
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
492504
*dest = 1.0;
@@ -512,6 +524,9 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /
512524
ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */
513525
{
514526
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
527+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
528+
zend_error(E_DEPRECATED, "Passing null to argument of type string is deprecated");
529+
}
515530
convert_to_string(arg);
516531
*dest = Z_STR_P(arg);
517532
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
-2 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)