Deprecate passing null to non-nullable arg of internal function

This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
This commit is contained in:
Nikita Popov 2020-11-30 16:45:48 +01:00
parent f06895488a
commit b10416a652
314 changed files with 1091 additions and 6282 deletions

View file

@ -27,6 +27,16 @@ PHP 8.1 UPGRADE NOTES
array is no longer supported. For example, array_pop($GLOBALS) will result
in an error.
RFC: https://wiki.php.net/rfc/restrict_globals_usage
. Passing null to a non-nullable argument of a built-in function is
deprecated. This matches the behavior of user-defined functions, where null
is never accepted by non-nullable arguments.
user-defined functions.
var_dump(str_contains("foobar", null));
// Deprecated: Passing null to parameter #2 ($needle) of type string
// is deprecated
RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
- Fileinfo:
. The fileinfo functions now accept and return, respectively, finfo objects

View file

@ -30,25 +30,37 @@ Warning: Undefined variable $ref in %s on line %d
Warning: Undefined variable $undef 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
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

View file

@ -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

View file

@ -8,7 +8,6 @@ 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));
@ -16,7 +15,6 @@ var_dump(class_exists(1));
?>
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)

View file

@ -7,7 +7,7 @@ try {
try {
try {
try {
throw new Exception(NULL);
throw new Exception();
} catch (Exception $e) {
var_dump($e->getMessage());
throw $e;

View file

@ -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)

View file

@ -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)

View file

@ -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"
@ -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"

View file

@ -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) {
}

View file

@ -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) {
}

View file

@ -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)

View file

@ -426,9 +426,41 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **p
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest) /* {{{ */
static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32_t arg_num) {
zend_function *func = EG(current_execute_data)->func;
ZEND_ASSERT(arg_num > 0);
uint32_t arg_offset = arg_num - 1;
if (arg_offset >= func->common.num_args) {
ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_VARIADIC);
arg_offset = func->common.num_args;
}
zend_arg_info *arg_info = &func->common.arg_info[arg_offset];
zend_string *func_name = get_active_function_or_method_name();
const char *arg_name = get_active_function_arg_name(arg_num);
/* If no type is specified in arginfo, use the specified fallback_type determined through
* zend_parse_parameters instead. */
zend_string *type_str = zend_type_to_string(arg_info->type);
const char *type = type_str ? ZSTR_VAL(type_str) : fallback_type;
zend_error(E_DEPRECATED,
"%s(): Passing null to parameter #%" PRIu32 "%s%s%s of type %s is deprecated",
ZSTR_VAL(func_name), arg_num,
arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "",
type);
zend_string_release(func_name);
if (type_str) {
zend_string_release(type_str);
}
return !EG(exception);
}
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
return 0;
}
*dest = zend_is_true(arg);
} else {
return 0;
@ -437,16 +469,16 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest) /* {
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
{
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
}
return zend_parse_arg_bool_weak(arg, dest);
return zend_parse_arg_bool_weak(arg, dest, arg_num);
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
@ -479,6 +511,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
return 0;
}
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int", arg_num)) {
return 0;
}
*dest = 0;
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
*dest = 1;
@ -489,16 +524,16 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest)
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
{
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
}
return zend_parse_arg_long_weak(arg, dest);
return zend_parse_arg_long_weak(arg, dest, arg_num);
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest, uint32_t arg_num) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
*dest = (double)Z_LVAL_P(arg);
@ -517,6 +552,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest)
return 0;
}
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) {
return 0;
}
*dest = 0.0;
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
*dest = 1.0;
@ -527,7 +565,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest)
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest, uint32_t arg_num) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
/* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */
@ -535,11 +573,11 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest)
} else if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
}
return zend_parse_arg_double_weak(arg, dest);
return zend_parse_arg_double_weak(arg, dest, arg_num);
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, uint32_t arg_num) /* {{{ */
{
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
@ -558,6 +596,9 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /
}
zend_string_release(str);
} else if (Z_TYPE_P(arg) < IS_TRUE) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int|float", arg_num)) {
return 0;
}
ZVAL_LONG(arg, 0);
} else if (Z_TYPE_P(arg) == IS_TRUE) {
ZVAL_LONG(arg, 1);
@ -569,9 +610,12 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
{
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
return 0;
}
convert_to_string(arg);
*dest = Z_STR_P(arg);
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
@ -591,24 +635,24 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **des
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
{
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
}
return zend_parse_arg_str_weak(arg, dest);
return zend_parse_arg_str_weak(arg, dest, arg_num);
}
/* }}} */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long) /* {{{ */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num) /* {{{ */
{
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
return 0;
}
if (zend_parse_arg_long_weak(arg, dest_long)) {
if (zend_parse_arg_long_weak(arg, dest_long, arg_num)) {
*dest_str = NULL;
return 1;
} else if (zend_parse_arg_str_weak(arg, dest_str)) {
} else if (zend_parse_arg_str_weak(arg, dest_str, arg_num)) {
*dest_long = 0;
return 1;
} else {
@ -617,7 +661,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_stri
}
/* }}} */
static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec, char **error) /* {{{ */
static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec, char **error, uint32_t arg_num) /* {{{ */
{
const char *spec_walk = *spec;
char c = *spec_walk++;
@ -650,7 +694,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
is_null = va_arg(*va, bool *);
}
if (!zend_parse_arg_long(arg, p, is_null, check_null)) {
if (!zend_parse_arg_long(arg, p, is_null, check_null, arg_num)) {
return check_null ? "?int" : "int";
}
}
@ -665,7 +709,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
is_null = va_arg(*va, bool *);
}
if (!zend_parse_arg_double(arg, p, is_null, check_null)) {
if (!zend_parse_arg_double(arg, p, is_null, check_null, arg_num)) {
return check_null ? "?float" : "float";
}
}
@ -675,7 +719,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
{
zval **p = va_arg(*va, zval **);
if (!zend_parse_arg_number(arg, p, check_null)) {
if (!zend_parse_arg_number(arg, p, check_null, arg_num)) {
return check_null ? "int|float|null" : "int|float";
}
}
@ -685,7 +729,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
{
char **p = va_arg(*va, char **);
size_t *pl = va_arg(*va, size_t *);
if (!zend_parse_arg_string(arg, p, pl, check_null)) {
if (!zend_parse_arg_string(arg, p, pl, check_null, arg_num)) {
return check_null ? "?string" : "string";
}
}
@ -695,7 +739,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
{
char **p = va_arg(*va, char **);
size_t *pl = va_arg(*va, size_t *);
if (!zend_parse_arg_path(arg, p, pl, check_null)) {
if (!zend_parse_arg_path(arg, p, pl, check_null, arg_num)) {
if (Z_TYPE_P(arg) == IS_STRING) {
zend_spprintf(error, 0, "must not contain any null bytes");
return "";
@ -709,7 +753,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
case 'P':
{
zend_string **str = va_arg(*va, zend_string **);
if (!zend_parse_arg_path_str(arg, str, check_null)) {
if (!zend_parse_arg_path_str(arg, str, check_null, arg_num)) {
if (Z_TYPE_P(arg) == IS_STRING) {
zend_spprintf(error, 0, "must not contain any null bytes");
return "";
@ -723,7 +767,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
case 'S':
{
zend_string **str = va_arg(*va, zend_string **);
if (!zend_parse_arg_str(arg, str, check_null)) {
if (!zend_parse_arg_str(arg, str, check_null, arg_num)) {
return check_null ? "?string" : "string";
}
}
@ -738,7 +782,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec
is_null = va_arg(*va, bool *);
}
if (!zend_parse_arg_bool(arg, p, is_null, check_null)) {
if (!zend_parse_arg_bool(arg, p, is_null, check_null, arg_num)) {
return check_null ? "?bool" : "bool";
}
}
@ -899,7 +943,7 @@ static zend_result zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, cons
const char *expected_type = NULL;
char *error = NULL;
expected_type = zend_parse_arg_impl(arg, va, spec, &error);
expected_type = zend_parse_arg_impl(arg, va, spec, &error, arg_num);
if (expected_type) {
if (EG(exception)) {
return FAILURE;

View file

@ -1450,7 +1450,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "b" */
#define Z_PARAM_BOOL_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_BOOL_OR_NULL : Z_EXPECTED_BOOL; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1492,7 +1492,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_OBJ_OR_STR_EX(destination_object, destination_string, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_obj_or_str(_arg, &destination_object, NULL, &destination_string, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_obj_or_str(_arg, &destination_object, NULL, &destination_string, allow_null, _i))) { \
_expected_type = allow_null ? Z_EXPECTED_OBJECT_OR_STRING_OR_NULL : Z_EXPECTED_OBJECT_OR_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1506,7 +1506,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_OBJ_OF_CLASS_OR_STR_EX(destination_object, base_ce, destination_string, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_obj_or_str(_arg, &destination_object, base_ce, &destination_string, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_obj_or_str(_arg, &destination_object, base_ce, &destination_string, allow_null, _i))) { \
if (base_ce) { \
_error = ZSTR_VAL((base_ce)->name); \
_error_code = allow_null ? ZPP_ERROR_WRONG_CLASS_OR_STRING_OR_NULL : ZPP_ERROR_WRONG_CLASS_OR_STRING; \
@ -1527,7 +1527,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "d" */
#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_DOUBLE_OR_NULL : Z_EXPECTED_DOUBLE; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1578,7 +1578,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_ARRAY_HT_OR_LONG_EX(dest_ht, dest_long, is_null, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_array_ht_or_long(_arg, &dest_ht, &dest_long, &is_null, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_array_ht_or_long(_arg, &dest_ht, &dest_long, &is_null, allow_null, _i))) { \
_expected_type = allow_null ? Z_EXPECTED_ARRAY_OR_LONG_OR_NULL : Z_EXPECTED_ARRAY_OR_LONG; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1608,7 +1608,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "l" */
#define Z_PARAM_LONG_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_LONG_OR_NULL : Z_EXPECTED_LONG; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1623,7 +1623,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "n" */
#define Z_PARAM_NUMBER_EX(dest, check_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_number(_arg, &dest, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_number(_arg, &dest, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_NUMBER_OR_NULL : Z_EXPECTED_NUMBER; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1709,7 +1709,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_OBJ_OF_CLASS_OR_LONG_EX(dest_obj, _ce, dest_long, is_null, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_obj_or_long(_arg, &dest_obj, _ce, &dest_long, &is_null, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_obj_or_long(_arg, &dest_obj, _ce, &dest_long, &is_null, allow_null, _i))) { \
_error = ZSTR_VAL((_ce)->name); \
_error_code = allow_null ? ZPP_ERROR_WRONG_CLASS_OR_LONG_OR_NULL : ZPP_ERROR_WRONG_CLASS_OR_LONG; \
break; \
@ -1724,7 +1724,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "p" */
#define Z_PARAM_PATH_EX(dest, dest_len, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_PATH_OR_NULL : Z_EXPECTED_PATH; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1739,7 +1739,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "P" */
#define Z_PARAM_PATH_STR_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_PATH_OR_NULL : Z_EXPECTED_PATH; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1769,7 +1769,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "s" */
#define Z_PARAM_STRING_EX(dest, dest_len, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_STRING_OR_NULL : Z_EXPECTED_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1784,7 +1784,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* old "S" */
#define Z_PARAM_STR_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null, _i))) { \
_expected_type = check_null ? Z_EXPECTED_STRING_OR_NULL : Z_EXPECTED_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1849,7 +1849,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_ARRAY_HT_OR_STR_EX(dest_ht, dest_str, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_array_ht_or_str(_arg, &dest_ht, &dest_str, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_array_ht_or_str(_arg, &dest_ht, &dest_str, allow_null, _i))) { \
_expected_type = allow_null ? Z_EXPECTED_ARRAY_OR_STRING_OR_NULL : Z_EXPECTED_ARRAY_OR_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1863,7 +1863,7 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_STR_OR_LONG_EX(dest_str, dest_long, is_null, allow_null) \
Z_PARAM_PROLOGUE(0, 0); \
if (UNEXPECTED(!zend_parse_arg_str_or_long(_arg, &dest_str, &dest_long, &is_null, allow_null))) { \
if (UNEXPECTED(!zend_parse_arg_str_or_long(_arg, &dest_str, &dest_long, &is_null, allow_null, _i))) { \
_expected_type = allow_null ? Z_EXPECTED_STRING_OR_LONG_OR_NULL : Z_EXPECTED_STRING_OR_LONG; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@ -1880,18 +1880,18 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
/* Inlined implementations shared by new and old parameter parsing APIs */
ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, uint32_t arg_num);
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num);
static zend_always_inline bool zend_parse_arg_bool(zval *arg, bool *dest, bool *is_null, bool check_null)
static zend_always_inline bool zend_parse_arg_bool(zval *arg, bool *dest, bool *is_null, bool check_null, uint32_t arg_num)
{
if (check_null) {
*is_null = 0;
@ -1904,12 +1904,12 @@ static zend_always_inline bool zend_parse_arg_bool(zval *arg, bool *dest, bool *
*is_null = 1;
*dest = 0;
} else {
return zend_parse_arg_bool_slow(arg, dest);
return zend_parse_arg_bool_slow(arg, dest, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_long(zval *arg, zend_long *dest, bool *is_null, bool check_null)
static zend_always_inline bool zend_parse_arg_long(zval *arg, zend_long *dest, bool *is_null, bool check_null, uint32_t arg_num)
{
if (check_null) {
*is_null = 0;
@ -1920,12 +1920,12 @@ static zend_always_inline bool zend_parse_arg_long(zval *arg, zend_long *dest, b
*is_null = 1;
*dest = 0;
} else {
return zend_parse_arg_long_slow(arg, dest);
return zend_parse_arg_long_slow(arg, dest, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_double(zval *arg, double *dest, bool *is_null, bool check_null)
static zend_always_inline bool zend_parse_arg_double(zval *arg, double *dest, bool *is_null, bool check_null, uint32_t arg_num)
{
if (check_null) {
*is_null = 0;
@ -1936,40 +1936,40 @@ static zend_always_inline bool zend_parse_arg_double(zval *arg, double *dest, bo
*is_null = 1;
*dest = 0.0;
} else {
return zend_parse_arg_double_slow(arg, dest);
return zend_parse_arg_double_slow(arg, dest, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_number(zval *arg, zval **dest, bool check_null)
static zend_always_inline bool zend_parse_arg_number(zval *arg, zval **dest, bool check_null, uint32_t arg_num)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG || Z_TYPE_P(arg) == IS_DOUBLE)) {
*dest = arg;
} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
*dest = NULL;
} else {
return zend_parse_arg_number_slow(arg, dest);
return zend_parse_arg_number_slow(arg, dest, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null)
static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
*dest = Z_STR_P(arg);
} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
*dest = NULL;
} else {
return zend_parse_arg_str_slow(arg, dest);
return zend_parse_arg_str_slow(arg, dest, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, bool check_null)
static zend_always_inline bool zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, bool check_null, uint32_t arg_num)
{
zend_string *str;
if (!zend_parse_arg_str(arg, &str, check_null)) {
if (!zend_parse_arg_str(arg, &str, check_null, arg_num)) {
return 0;
}
if (check_null && UNEXPECTED(!str)) {
@ -1982,20 +1982,20 @@ static zend_always_inline bool zend_parse_arg_string(zval *arg, char **dest, siz
return 1;
}
static zend_always_inline bool zend_parse_arg_path_str(zval *arg, zend_string **dest, bool check_null)
static zend_always_inline bool zend_parse_arg_path_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
{
if (!zend_parse_arg_str(arg, dest, check_null) ||
if (!zend_parse_arg_str(arg, dest, check_null, arg_num) ||
(*dest && UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(*dest), ZSTR_LEN(*dest))))) {
return 0;
}
return 1;
}
static zend_always_inline bool zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, bool check_null)
static zend_always_inline bool zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, bool check_null, uint32_t arg_num)
{
zend_string *str;
if (!zend_parse_arg_path_str(arg, &str, check_null)) {
if (!zend_parse_arg_path_str(arg, &str, check_null, arg_num)) {
return 0;
}
if (check_null && UNEXPECTED(!str)) {
@ -2060,7 +2060,7 @@ static zend_always_inline bool zend_parse_arg_array_ht(zval *arg, HashTable **de
}
static zend_always_inline bool zend_parse_arg_array_ht_or_long(
zval *arg, HashTable **dest_ht, zend_long *dest_long, bool *is_null, bool allow_null
zval *arg, HashTable **dest_ht, zend_long *dest_long, bool *is_null, bool allow_null, uint32_t arg_num
) {
if (allow_null) {
*is_null = 0;
@ -2076,7 +2076,7 @@ static zend_always_inline bool zend_parse_arg_array_ht_or_long(
*is_null = 1;
} else {
*dest_ht = NULL;
return zend_parse_arg_long_slow(arg, dest_long);
return zend_parse_arg_long_slow(arg, dest_long, arg_num);
}
return 1;
@ -2109,7 +2109,7 @@ static zend_always_inline bool zend_parse_arg_obj(zval *arg, zend_object **dest,
}
static zend_always_inline bool zend_parse_arg_obj_or_long(
zval *arg, zend_object **dest_obj, zend_class_entry *ce, zend_long *dest_long, bool *is_null, bool allow_null
zval *arg, zend_object **dest_obj, zend_class_entry *ce, zend_long *dest_long, bool *is_null, bool allow_null, uint32_t arg_num
) {
if (allow_null) {
*is_null = 0;
@ -2125,7 +2125,7 @@ static zend_always_inline bool zend_parse_arg_obj_or_long(
*is_null = 1;
} else {
*dest_obj = NULL;
return zend_parse_arg_long_slow(arg, dest_long);
return zend_parse_arg_long_slow(arg, dest_long, arg_num);
}
return 1;
@ -2173,7 +2173,7 @@ static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest,
}
static zend_always_inline bool zend_parse_arg_array_ht_or_str(
zval *arg, HashTable **dest_ht, zend_string **dest_str, bool allow_null)
zval *arg, HashTable **dest_ht, zend_string **dest_str, bool allow_null, uint32_t arg_num)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
*dest_ht = NULL;
@ -2186,13 +2186,13 @@ static zend_always_inline bool zend_parse_arg_array_ht_or_str(
*dest_str = NULL;
} else {
*dest_ht = NULL;
return zend_parse_arg_str_slow(arg, dest_str);
return zend_parse_arg_str_slow(arg, dest_str, arg_num);
}
return 1;
}
static zend_always_inline bool zend_parse_arg_str_or_long(zval *arg, zend_string **dest_str, zend_long *dest_long,
bool *is_null, bool allow_null)
bool *is_null, bool allow_null, uint32_t arg_num)
{
if (allow_null) {
*is_null = 0;
@ -2206,7 +2206,7 @@ static zend_always_inline bool zend_parse_arg_str_or_long(zval *arg, zend_string
*dest_str = NULL;
*is_null = 1;
} else {
return zend_parse_arg_str_or_long_slow(arg, dest_str, dest_long);
return zend_parse_arg_str_or_long_slow(arg, dest_str, dest_long, arg_num);
}
return 1;
}
@ -2230,7 +2230,7 @@ static zend_always_inline bool zend_parse_arg_obj_or_class_name(
}
static zend_always_inline bool zend_parse_arg_obj_or_str(
zval *arg, zend_object **destination_object, zend_class_entry *base_ce, zend_string **destination_string, bool allow_null
zval *arg, zend_object **destination_object, zend_class_entry *base_ce, zend_string **destination_string, bool allow_null, uint32_t arg_num
) {
if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
if (!base_ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), base_ce))) {
@ -2241,7 +2241,7 @@ static zend_always_inline bool zend_parse_arg_obj_or_str(
}
*destination_object = NULL;
return zend_parse_arg_str(arg, destination_string, allow_null);
return zend_parse_arg_str(arg, destination_string, allow_null, arg_num);
}
END_EXTERN_C()

View file

@ -739,22 +739,22 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
ZVAL_DOUBLE(arg, dval);
return 1;
}
} else if (zend_parse_arg_long_weak(arg, &lval)) {
} else if (zend_parse_arg_long_weak(arg, &lval, 0)) {
zval_ptr_dtor(arg);
ZVAL_LONG(arg, lval);
return 1;
}
}
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) {
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) {
zval_ptr_dtor(arg);
ZVAL_DOUBLE(arg, dval);
return 1;
}
if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str)) {
if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str, 0)) {
/* on success "arg" is converted to IS_STRING */
return 1;
}
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) {
zval_ptr_dtor(arg);
ZVAL_BOOL(arg, bval);
return 1;
@ -781,16 +781,16 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask,
double dval;
bool bval;
if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval)) {
if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, 0)) {
return 1;
}
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) {
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) {
return 1;
}
if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) {
return 1;
}
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) {
return 1;
}
return 0;

View file

@ -8310,8 +8310,18 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMPVAR|CV, ANY)
zend_string *str;
zval tmp;
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
ZVAL_COPY(&tmp, value);
if (zend_parse_arg_str_weak(&tmp, &str)) {
if (zend_parse_arg_str_weak(&tmp, &str, 1)) {
ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
zval_ptr_dtor(&tmp);
break;

View file

@ -5286,8 +5286,18 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST
zend_string *str;
zval tmp;
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
ZVAL_COPY(&tmp, value);
if (zend_parse_arg_str_weak(&tmp, &str)) {
if (zend_parse_arg_str_weak(&tmp, &str, 1)) {
ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
zval_ptr_dtor(&tmp);
break;
@ -14459,8 +14469,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_TMPVAR_HANDLER(ZEN
zend_string *str;
zval tmp;
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
ZVAL_COPY(&tmp, value);
if (zend_parse_arg_str_weak(&tmp, &str)) {
if (zend_parse_arg_str_weak(&tmp, &str, 1)) {
ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
zval_ptr_dtor(&tmp);
break;
@ -38546,8 +38566,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OP
zend_string *str;
zval tmp;
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
ZVAL_COPY(&tmp, value);
if (zend_parse_arg_str_weak(&tmp, &str)) {
if (zend_parse_arg_str_weak(&tmp, &str, 1)) {
ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
zval_ptr_dtor(&tmp);
break;

View file

@ -10,5 +10,6 @@ try {
}
?>
--EXPECT--
--EXPECTF--
Deprecated: DatePeriod::__construct(): Passing null to parameter #1 ($start) of type string is deprecated in %s on line %d
string(51) "DatePeriod::__construct(): Unknown or bad format ()"

View file

@ -15,8 +15,8 @@ $e = new DateTime($es);
$d= $e->diff($s);
var_dump($d->days); // 0 ... but should be 30
$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$s = (new DateTime("now"))->setTimestamp(strtotime($ss)); // verbose setup method
$e = (new DateTime("now"))->setTimestamp(strtotime($es)); // verbose setup method
$d = $e->diff($s);
var_dump($d->days); // 30 ... and should be 30
@ -24,13 +24,13 @@ var_dump($d->days); // 30 ... and should be 30
Next we will try mix/match the code to see what happens, surprisingly it seems that the end date ($e)
is the important one, if it uses the verbose method it returns the correct values.
*/
$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
$s = (new DateTime("now"))->setTimestamp(strtotime($ss)); // verbose setup method
$e = new DateTime($es);
$d= $e->diff($s);
var_dump($d->days); // 0 ... but should be 30
$s = new DateTime($ss);
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$e = (new DateTime("now"))->setTimestamp(strtotime($es)); // verbose setup method
$d= $e->diff($s);
var_dump($d->days); // 30 ... and should be 30
@ -39,7 +39,7 @@ This test just proves that the $e date is important BUT NOT because it's the one
on, that's just coincidental that seems to imply that the "- 1 second" in the date string is the problem.
*/
$s = new DateTime($ss);
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$e = (new DateTime("now"))->setTimestamp(strtotime($es)); // verbose setup method
$d= $s->diff($e);
var_dump($d->days); // 30 ... and should be 30

View file

@ -8,5 +8,7 @@ $i = date_interval_create_from_date_string(null);
var_dump($i);
?>
--EXPECTF--
Deprecated: date_interval_create_from_date_string(): Passing null to parameter #1 ($datetime) of type string is deprecated in %s on line %d
Warning: date_interval_create_from_date_string(): Unknown or bad format () at position 0 ( ): Empty string in %sdate_interval_create_from_date_string_nullparam.php on line 2
bool(false)

View file

@ -13,7 +13,8 @@ $dtms021 = date_create();
var_dump(date_timestamp_set($dtms021, null));
?>
--EXPECT--
--EXPECTF--
Deprecated: date_timestamp_set(): Passing null to parameter #2 ($timestamp) of type int is deprecated in %s on line %d
object(DateTime)#1 (3) {
["date"]=>
string(26) "1970-01-01 00:00:00.000000"

View file

@ -1,56 +0,0 @@
--TEST--
Test wrong number of arguments for microtime()
--FILE--
<?php
/*
* Function is implemented in ext/standard/microtime.c
*/
echo "\n-- Bad Arg types --\n";
$bad_args = array(null,
1.5,
"hello",
array('k'=>'v', array(0)),
new stdClass,
1);
foreach ($bad_args as $bad_arg) {
echo "\n--> bad arg: ";
var_dump($bad_arg);
try {
var_dump(microtime($bad_arg));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
}
?>
--EXPECTF--
-- Bad Arg types --
--> bad arg: NULL
string(%d) "%s %s"
--> bad arg: float(1.5)
float(%s)
--> bad arg: string(5) "hello"
float(%s)
--> bad arg: array(2) {
["k"]=>
string(1) "v"
[0]=>
array(1) {
[0]=>
int(0)
}
}
microtime(): Argument #1 ($as_float) must be of type bool, array given
--> bad arg: object(stdClass)#%d (0) {
}
microtime(): Argument #1 ($as_float) must be of type bool, stdClass given
--> bad arg: int(1)
float(%s)

View file

@ -31,7 +31,7 @@ check(dba_handlers());
echo "Test 2\n";
check(dba_handlers(null));
check(dba_handlers(false));
echo "Test 3\n";

View file

@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
?>
--FILE--
<?php
$filename = null;
$filename = '';
$doc = new DOMDocument('1.0');
$root = $doc->createElement('html');
$root = $doc->appendChild($root);

View file

@ -16,11 +16,6 @@ try {
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump(finfo_file($fp, NULL));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
var_dump(finfo_file($fp, '.'));
var_dump(finfo_file($fp, '&'));
@ -28,7 +23,6 @@ var_dump(finfo_file($fp, '&'));
--EXPECTF--
finfo_file(): Argument #1 ($finfo) must not contain any null bytes
finfo_file(): Argument #1 ($finfo) cannot be empty
finfo_file(): Argument #1 ($finfo) cannot be empty
string(9) "directory"
Warning: finfo_file(&): Failed to open stream: No such file or directory in %s on line %d

View file

@ -5,18 +5,18 @@ filter_var() and FILTER_VALIDATE_MAC
--FILE--
<?php
$values = Array(
array("01-23-45-67-89-ab", null),
array("01-23-45-67-89-ab", 0),
array("01-23-45-67-89-ab", array("options" => array("separator" => "-"))),
array("01-23-45-67-89-ab", array("options" => array("separator" => "."))),
array("01-23-45-67-89-ab", array("options" => array("separator" => ":"))),
array("01-23-45-67-89-AB", null),
array("01-23-45-67-89-aB", null),
array("01:23:45:67:89:ab", null),
array("01:23:45:67:89:AB", null),
array("01:23:45:67:89:aB", null),
array("01:23:45-67:89:aB", null),
array("xx:23:45:67:89:aB", null),
array("0123.4567.89ab", null),
array("01-23-45-67-89-AB", 0),
array("01-23-45-67-89-aB", 0),
array("01:23:45:67:89:ab", 0),
array("01:23:45:67:89:AB", 0),
array("01:23:45:67:89:aB", 0),
array("01:23:45-67:89:aB", 0),
array("xx:23:45:67:89:aB", 0),
array("0123.4567.89ab", 0),
array("01-23-45-67-89-ab", array("options" => array("separator" => "--"))),
array("01-23-45-67-89-ab", array("options" => array("separator" => ""))),
);

View file

@ -19,9 +19,13 @@ foreach (array(null, true, false, 1, "", new stdClass) as $invalid) {
}
?>
--EXPECTF--
Deprecated: filter_input_array(): Passing null to parameter #2 ($options) of type array|int is deprecated in %s on line %d
Warning: filter_input_array(): Unknown filter with ID 0 in %s on line %d
bool(false)
Deprecated: filter_var_array(): Passing null to parameter #2 ($options) of type array|int is deprecated in %s on line %d
Warning: filter_var_array(): Unknown filter with ID 0 in %s on line %d
bool(false)

View file

@ -14,7 +14,7 @@ require __DIR__ . '/func.inc';
$image = imagecreatetruecolor(50, 50);
trycatch_dump(
fn() => imagetruecolortopalette($image, true, null)
fn() => imagetruecolortopalette($image, true, 0)
);
?>

View file

@ -628,7 +628,7 @@ static zend_result convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, ui
}
default: {
zend_long lval;
if (!zend_parse_arg_long_slow(val, &lval)) {
if (!zend_parse_arg_long_slow(val, &lval, arg_pos)) {
zend_argument_type_error(arg_pos, "must be of type GMP|string|int, %s given", zend_zval_type_name(val));
return FAILURE;
}

View file

@ -37,7 +37,7 @@ catch (\Error $e) {
?>
--EXPECT--
--EXPECTF--
*** Testing hash_init(): error conditions ***
-- Testing hash_init() function with unknown algorithms --
@ -48,4 +48,6 @@ hash_init(): Argument #1 ($algo) must be a cryptographic hashing algorithm if HM
-- Testing hash_init() function with HASH_HMAC and no key --
hash_init(): Argument #3 ($key) cannot be empty when HMAC is requested
Deprecated: hash_init(): Passing null to parameter #3 ($key) of type string is deprecated in %s on line %d
hash_init(): Argument #3 ($key) cannot be empty when HMAC is requested

View file

@ -5,7 +5,7 @@ iconv_mime_decode() charset parameter length checks (CVE-2007-4840)
--FILE--
<?php
$a = str_repeat("/", 9000000);
var_dump(iconv_mime_decode("a", null, $a));
var_dump(iconv_mime_decode("a", 0, $a));
?>
--EXPECTF--
Warning: iconv_mime_decode(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d

View file

@ -5,7 +5,7 @@ iconv_mime_decode_headers() charset parameter length checks (CVE-2007-4840)
--FILE--
<?php
$a = str_repeat("/", 9000000);
var_dump(iconv_mime_decode_headers("a", null, $a));
var_dump(iconv_mime_decode_headers("a", 0, $a));
?>
--EXPECTF--
Warning: iconv_mime_decode_headers(): Encoding parameter exceeds the maximum allowed length of 64 characters in %s on line %d

View file

@ -9,7 +9,7 @@ extension_loaded('imap') or die('skip imap extension not available in this build
$address = 'John Doe <john@example.com>';
var_dump($address);
imap_rfc822_parse_adrlist($address, null);
imap_rfc822_parse_adrlist($address, '');
var_dump($address);
?>

View file

@ -15,8 +15,10 @@ foreach (['', 1, NULL, $x] as $value) {
}
?>
--EXPECT--
--EXPECTF--
NumberFormatter::format(): Argument #1 ($num) must be of type int|float, string given
string(1) "1"
Deprecated: NumberFormatter::format(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
string(1) "0"
NumberFormatter::format(): Argument #1 ($num) must be of type int|float, NumberFormatter given

View file

@ -6,8 +6,7 @@ Bug #72241: get_icu_value_internal out-of-bounds read
<?php
$var1=str_repeat("A", 1000);
$out = locale_get_primary_language($var1);
echo strlen($out) . PHP_EOL;
echo unpack('H*', $out)[1] . PHP_EOL;
var_dump($out);
?>
--EXPECT--
0
NULL

View file

@ -71,12 +71,11 @@ function ut_main()
array( 'ab' , 'b' ),
array( 'ab' , 'a' ),
array( 123 , 'abc' ),
array( 'ac' , null ),
array( 'ac' , '' ),
array( '.' , '.' ),
// Try to compare long strings.
array( 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde',
'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'),
array( null , null )
);
$res_str .= compare_pairs( 'en_US', $test_params );
@ -91,7 +90,7 @@ function ut_main()
array( 'а', 'b' ),
array( 'а', 'bb' ),
array( 'а', 'ab' ),
array( 'а', null )
array( 'а', '' )
);
$res_str .= compare_pairs( 'ru_RU', $test_params );
@ -120,10 +119,9 @@ ut_run();
'ab' < 'b'
'ab' > 'a'
123 < 'abc'
'ac' > NULL
'ac' > ''
'.' = '.'
'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde' < 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'
NULL = NULL
'а' < 'б'
'а' < 'аа'
'аб' < 'ба'
@ -131,5 +129,5 @@ NULL = NULL
'а' < 'b'
'а' < 'bb'
'а' < 'ab'
'а' > NULL
'а' > ''
'y' < 'k'

View file

@ -33,7 +33,7 @@ function ut_main()
$test_params = array(
'abc', 'abd', 'aaa',
'аа', 'а', 'z',
'', null , '3',
'', '3',
'y' , 'i' , 'k'
);
@ -70,8 +70,6 @@ source: z
key: 5c01050105
source:
key: 0101
source:
key: 0101
source: 3
key: 1901050105
source: y

View file

@ -107,6 +107,18 @@ ArgumentCountError: NumberFormatter::create() expects at least 2 arguments, 0 gi
Error: NumberFormatter object is already constructed in %s on line %d
'U_ZERO_ERROR'
Deprecated: NumberFormatter::__construct(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: NumberFormatter::__construct(): Passing null to parameter #2 ($style) of type int is deprecated in %s on line %d
Deprecated: NumberFormatter::create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: NumberFormatter::create(): Passing null to parameter #2 ($style) of type int is deprecated in %s on line %d
Deprecated: numfmt_create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: numfmt_create(): Passing null to parameter #2 ($style) of type int is deprecated in %s on line %d
IntlException: Constructor failed in %s on line %d
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'
'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR'

View file

@ -29,7 +29,7 @@ try {
echo $e->getMessage(), "\n";
}
try {
var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
var_dump(new IntlGregorianCalendar(1,2,3,4,5,array()));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}

View file

@ -10,7 +10,7 @@ ini_set("intl.error_level", E_WARNING);
date_default_timezone_set('Europe/Amsterdam');
$intlcal = intlgregcal_create_instance(2012, 1, 29, 16, 0, NULL);
$intlcal = intlgregcal_create_instance(2012, 1, 29, 16, 0, 0);
var_dump($intlcal->getTimeZone()->getId());
var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:00:00') * 1000);

View file

@ -126,9 +126,21 @@ ArgumentCountError: msgfmt_create() expects exactly 2 arguments, 1 given in %s o
ArgumentCountError: MessageFormatter::create() expects exactly 2 arguments, 1 given in %s on line %d
'U_ZERO_ERROR'
Deprecated: MessageFormatter::__construct(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: MessageFormatter::__construct(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
Deprecated: MessageFormatter::create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: MessageFormatter::create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
Deprecated: msgfmt_create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d
Deprecated: msgfmt_create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d
'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR'
IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d

View file

@ -142,7 +142,7 @@ function ut_nfmt_create( $locale, $style, $pattern = null )
return numfmt_create( $locale, $style, $pattern );
}
}
function ut_nfmt_format( $fmt, $number, $type = null )
function ut_nfmt_format( $fmt, $number, $type = NumberFormatter::TYPE_DEFAULT )
{
return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type );
}

View file

@ -31,6 +31,8 @@ NULL
NULL
NULL
NULL
Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in %s on line %d
NULL
object(stdClass)#%d (1) {
["test"]=>

View file

@ -2,8 +2,6 @@
Bug #69187 json_last_error return BC in PHP7
--FILE--
<?php
var_dump(json_decode(NULL));
var_dump(json_last_error());
var_dump(json_decode(FALSE));
var_dump(json_last_error());
var_dump(json_decode(""));
@ -33,8 +31,6 @@ NULL
int(4)
NULL
int(4)
NULL
int(4)
int(0)
int(0)
int(1)

View file

@ -3,14 +3,14 @@ Bug #72069 (Behavior \JsonSerializable different from json_encode)
--FILE--
<?php
$result = json_encode(['end' => json_decode(null, true)]);
$result = json_encode(['end' => json_decode('', true)]);
var_dump($result);
class A implements \JsonSerializable
{
function jsonSerialize()
{
return ['end' => json_decode(null, true)];
return ['end' => json_decode('', true)];
}
}
$a = new A();

View file

@ -8,7 +8,7 @@ Chad Sikorra <Chad.Sikorra@gmail.com>
<?php
$subject = " Joe,= \rSmith ";
var_dump(ldap_escape($subject, null, LDAP_ESCAPE_DN));
var_dump(ldap_escape($subject, '', LDAP_ESCAPE_DN));
?>
--EXPECT--
string(24) "\20Joe\2c\3d \0dSmith\20"

View file

@ -9,11 +9,11 @@ require_once('skipif.inc');
/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('127.0.0.1', 3333);
ldap_mod_replace($ldap, null, array(
ldap_mod_replace($ldap, '', array(
'lockoutTime' => array(0),
));
ldap_modify_batch($ldap, null, array( [
ldap_modify_batch($ldap, '', array( [
"attrib" => "mail",
"modtype" => LDAP_MODIFY_BATCH_ADD,
"values" => [

View file

@ -7,7 +7,7 @@ ldap_escape() test filter and DN
$subject = 'foo=bar(baz)*';
var_dump(ldap_escape($subject, null, LDAP_ESCAPE_DN | LDAP_ESCAPE_FILTER));
var_dump(ldap_escape($subject, '', LDAP_ESCAPE_DN | LDAP_ESCAPE_FILTER));
?>
--EXPECT--

View file

@ -7,7 +7,7 @@ ldap_escape() test DN
$subject = 'foo=bar(baz)*';
var_dump(ldap_escape($subject, null, LDAP_ESCAPE_DN));
var_dump(ldap_escape($subject, '', LDAP_ESCAPE_DN));
?>
--EXPECT--

View file

@ -7,7 +7,7 @@ ldap_escape() test filter
$subject = 'foo=bar(baz)*';
var_dump(ldap_escape($subject, null, LDAP_ESCAPE_FILTER));
var_dump(ldap_escape($subject, '', LDAP_ESCAPE_FILTER));
?>
--EXPECT--

View file

@ -8,7 +8,7 @@ if (!extension_loaded('ldap')) die('skip ldap extension not available');
<?php
$array = [123, 456, 789];
try {
ldap_read(null, null, null, $array);
ldap_read(null, '', '', $array);
} catch (TypeError $err) {}
var_dump($array);
?>

View file

@ -20,7 +20,7 @@ ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, 44);
insert_dummy_data($link, $base);
var_dump(
$result = ldap_search($link, "$base", "(objectClass=person)", array(), null, 111, 22, LDAP_DEREF_NEVER),
$result = ldap_search($link, "$base", "(objectClass=person)", array(), 0, 111, 22, LDAP_DEREF_NEVER),
ldap_get_entries($link, $result)
);
var_dump(

View file

@ -13,10 +13,7 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build
* pattern is supplied to mb_ereg. Similar error message to ereg().
*/
$unset_var = 10;
unset ($unset_var);
$inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var,
@$unset_var);
$inputs = array(false, FALSE, "", '');
$iterator = 1;
foreach($inputs as $input) {
@ -70,31 +67,3 @@ mb_ereg(): Argument #1 ($pattern) must not be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
NULL
-- Iteration 5 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
NULL
-- Iteration 6 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
NULL
-- Iteration 7 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
NULL
-- Iteration 8 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
NULL

View file

@ -9,7 +9,7 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not available');
<?php
$var0 = "e";
$var2 = "";
$var3 = NULL;
$var3 = "";
try {
$var8 = mb_ereg_replace($var2,$var3,$var3,$var0);
var_dump($var8);

View file

@ -9,5 +9,6 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not available');
<?php
var_dump(mb_ereg_search_init(NULL));
?>
--EXPECT--
--EXPECTF--
Deprecated: mb_ereg_search_init(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
bool(true)

View file

@ -16,10 +16,6 @@ $replacement = 'string_val';
$string = 'string_val';
$option = '';
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
@ -49,10 +45,6 @@ $inputs = array(
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
@ -71,12 +63,6 @@ $inputs = array(
// object data
/*21*/ new classA(),
// undefined data
/*22*/ @$undefined_var,
// unset data
/*23*/ @$unset_var,
);
// loop through each element of the array for pattern
@ -121,7 +107,7 @@ string(10) "string_val"
string(10) "string_val"
-- Iteration 10 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
string(10) "string_val"
-- Iteration 11 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
@ -133,32 +119,20 @@ string(10) "string_val"
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
-- Iteration 14 --
string(10) "string_val"
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
-- Iteration 15 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
-- Iteration 16 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
string(10) "string_val"
-- Iteration 17 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
string(10) "string_val"
-- Iteration 18 --
string(10) "string_val"
-- Iteration 19 --
string(10) "string_val"
-- Iteration 20 --
string(10) "string_val"
-- Iteration 21 --
string(10) "string_val"
-- Iteration 22 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
-- Iteration 23 --
string(120) "string_valsstring_valtstring_valrstring_valistring_valnstring_valgstring_val_string_valvstring_valastring_vallstring_val"
Done

View file

@ -1,5 +1,5 @@
--TEST--
Optional long parameter might be null
Optional long parameter might be null (deprecated)
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
@ -16,15 +16,32 @@ echo mb_substr('foobarbaz', 6, null, 'UTF-8') . "\n";
echo mb_strcut('foobarbaz', 6, null, 'UTF-8') . "\n";
echo mb_strimwidth('foobar', 0, 3, null, 'UTF-8') . "\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: mb_strpos(): Passing null to parameter #3 ($offset) of type int is deprecated in %s on line %d
1
Deprecated: mb_strrpos(): Passing null to parameter #3 ($offset) of type int is deprecated in %s on line %d
2
Deprecated: mb_stripos(): Passing null to parameter #3 ($offset) of type int is deprecated in %s on line %d
1
Deprecated: mb_strripos(): Passing null to parameter #3 ($offset) of type int is deprecated in %s on line %d
2
Deprecated: mb_strstr(): Passing null to parameter #3 ($before_needle) of type bool is deprecated in %s on line %d
barbaz
Deprecated: mb_strrchr(): Passing null to parameter #3 ($before_needle) of type bool is deprecated in %s on line %d
baz
Deprecated: mb_stristr(): Passing null to parameter #3 ($before_needle) of type bool is deprecated in %s on line %d
barbaz
Deprecated: mb_strrichr(): Passing null to parameter #3 ($before_needle) of type bool is deprecated in %s on line %d
baz
baz
baz
Deprecated: mb_strimwidth(): Passing null to parameter #4 ($trim_marker) of type string is deprecated in %s on line %d
foo

View file

@ -12,13 +12,14 @@ class DbConnection {
public function connect() {
require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
/* Pass false as $connect_flags cannot be accessed via globals. */
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, false);
var_dump($link);
$link = mysqli_init();
var_dump($link);
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket, false);
$mysql->query("DROP TABLE IF EXISTS test_warnings");
$mysql->query("CREATE TABLE test_warnings (a int not null)");
$mysql->query("SET sql_mode=''");

View file

@ -12,11 +12,11 @@ if (!$IS_MYSQLND) {
<?php
error_reporting(E_ALL);
$tablica = array();
$test1 = mysqli_poll($test2, $test3, $tablica, null);
$test1 = mysqli_poll($test2, $test3, $tablica, 0);
$test2 = array();
$test2 = array();
$test1 = mysqli_poll($test2, $test3, $tablica, null);
$test1 = mysqli_poll($test2, $test3, $tablica, 0);
echo "okey";
?>
--EXPECTF--

View file

@ -11,9 +11,8 @@ require_once('skipifconnectfailure.inc');
require('table.inc');
// Zend will cast the NULL to 0
try {
mysqli_kill($link, null);
mysqli_kill($link, 0);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

View file

@ -35,12 +35,12 @@ if (!function_exists('mysqli_stmt_get_result'))
printf("[004] It is very unlikely that SHOW ENGINES returns no data, check manually\n");
} else {
$found = false;
foreach ($engines as $k => $engine)
foreach ($engine as $k => $v)
if (stristr($v, 'MyISAM')) {
$found = true;
break;
}
foreach ($engines as $engine) {
if (stristr($engine[0], 'MyISAM')) {
$found = true;
break;
}
}
if (!$found)
printf("[005] It is very unlikely that SHOW ENGINES does not show MyISAM, check manually\n");
}

View file

@ -22,6 +22,12 @@ var_dump(odbc_fetch_row($result));
--EXPECTF--
resource(%d) of type (odbc result)
bool(false)
Deprecated: odbc_columnprivileges(): Passing null to parameter #3 ($schema) of type string is deprecated in %s on line %d
Deprecated: odbc_columnprivileges(): Passing null to parameter #4 ($table) of type string is deprecated in %s on line %d
Deprecated: odbc_columnprivileges(): Passing null to parameter #5 ($column) of type string is deprecated in %s on line %d
resource(%d) of type (odbc result)
bool(false)
resource(%d) of type (odbc result)

View file

@ -24,7 +24,7 @@ foreach ($methods as $method) {
// no IV
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
NULL, $test['tag'], $test['aad']));
'', $test['tag'], $test['aad']));
// failed because no AAD
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $test['tag']));

View file

@ -22,7 +22,7 @@ foreach ($tests as $idx => $test) {
// no IV
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
NULL, $test['tag'], $test['aad']));
'', $test['tag'], $test['aad']));
// failed because no AAD
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
$test['iv'], $test['tag']));

View file

@ -22,7 +22,7 @@ foreach ($tests as $idx => $test) {
// no IV
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
NULL, $test['tag'], $test['aad']));
'', $test['tag'], $test['aad']));
// IV too long
var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,

View file

@ -24,7 +24,7 @@ foreach ($methods as $method) {
}
// Empty IV error
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
var_dump(openssl_encrypt('data', $method, 'password', 0, '', $tag, ''));
// Test setting different IV length and tag length
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 10), $tag, '', 14));

View file

@ -22,7 +22,7 @@ foreach ($tests as $idx => $test) {
}
// Empty IV error
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
var_dump(openssl_encrypt('data', $method, 'password', 0, '', $tag, ''));
// Failing to retrieve tag (max is 16 bytes)
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 32), $tag, '', 20));

View file

@ -22,7 +22,7 @@ foreach ($tests as $idx => $test) {
}
// Empty IV error
var_dump(openssl_encrypt('data', $method, 'password', 0, NULL, $tag, ''));
var_dump(openssl_encrypt('data', $method, 'password', 0, '', $tag, ''));
// Failing to retrieve tag (must be at most 16 bytes)
var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 12), $tag, '', 20));

View file

@ -29,9 +29,9 @@ if (PHP_EOL !== "\n") {
var_dump(strcmp($output, $a));
var_dump(strcmp($output, $output2));
var_dump(strcmp($output, $output3));
var_dump(strcmp($output, $output4)); // different
var_dump(strcmp($output, $output5)); // different
var_dump(strcmp($output, $output4));
var_dump($output3);
var_dump($output5);
?>
--EXPECTF--
bool(true)
@ -44,5 +44,5 @@ openssl_x509_export(): Argument #1 ($certificate) must be of type OpenSSLCertifi
int(0)
int(0)
int(%d)
int(0)
int(%d)
NULL
NULL

View file

@ -29,10 +29,12 @@ $db = new PDO($dsn, $user, $pass, [PDO::ATTR_DEFAULT_STR_PARAM => PDO::PARAM_STR
var_dump($db->getAttribute(PDO::ATTR_DEFAULT_STR_PARAM) === PDO::PARAM_STR_NATL);
?>
--EXPECT--
--EXPECTF--
string(3) "'1'"
string(2) "''"
string(4) "'42'"
Deprecated: PDO::quote(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
string(2) "''"
string(4) "''''"
string(5) "'foo'"

View file

@ -10,7 +10,7 @@ phar.readonly=0
--FILE--
<?php
$phar = __DIR__ . '/files/stuboflength1041.phar';
foreach (new RecursiveIteratorIterator(new Phar($phar, null, 'stuboflength1041.phar')) as $item) {
foreach (new RecursiveIteratorIterator(new Phar($phar, alias: 'stuboflength1041.phar')) as $item) {
var_dump($item->getFileName());
}
?>

View file

@ -13,9 +13,9 @@ var_dump(decoct(umask()));
$sFile = tempnam(__DIR__, 'test77022');
var_dump(decoct(stat($sFile)['mode']));
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $format => $ext) {
clearstatcache();
$phar = new PharData(__DIR__ . '/test77022.' . $ext, null, null, $mode);
$phar = new PharData(__DIR__ . '/test77022.' . $ext, format: $format);
$phar->addFile($sFile, 'test-file-phar');
$phar->addFromString("test-from-string", 'test-file-phar');
$phar->extractTo(__DIR__);
@ -33,4 +33,4 @@ string(6) "100600"
string(6) "100600"
string(6) "100644"
string(6) "100600"
string(6) "100644"
string(6) "100644"

View file

@ -12,9 +12,9 @@ var_dump(decoct(umask()));
chmod(__DIR__ . '/test79082/test79082-testfile', 0644);
chmod(__DIR__ . '/test79082/test79082-testfile2', 0400);
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $format => $ext) {
clearstatcache();
$phar = new PharData(__DIR__ . '/test79082.' . $ext, null, null, $mode);
$phar = new PharData(__DIR__ . '/test79082.' . $ext, format: $format);
$phar->buildFromIterator(new \RecursiveDirectoryIterator(__DIR__ . '/test79082', \FilesystemIterator::SKIP_DOTS), __DIR__ . '/test79082');
$phar->extractTo(__DIR__);
var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));
@ -22,9 +22,9 @@ foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
unlink(__DIR__ . '/test79082-testfile');
unlink(__DIR__ . '/test79082-testfile2');
}
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $format => $ext) {
clearstatcache();
$phar = new PharData(__DIR__ . '/test79082-d.' . $ext, null, null, $mode);
$phar = new PharData(__DIR__ . '/test79082-d.' . $ext, format: $format);
$phar->buildFromDirectory(__DIR__ . '/test79082');
$phar->extractTo(__DIR__);
var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));

View file

@ -35,7 +35,7 @@ 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;

View file

@ -8,7 +8,7 @@ if (!function_exists('posix_initgroups')) die('skip posix_initgroups() not found
--FILE--
<?php
var_dump(posix_initgroups(NULL, NULL));
var_dump(posix_initgroups('', 0));
?>
--EXPECT--

View file

@ -8,7 +8,7 @@ if (!function_exists('posix_mknod')) die('skip posix_mknod() not found');
--FILE--
<?php
var_dump(posix_mknod(NULL, NULL, NULL, NULL));
var_dump(posix_mknod('', 0, 0, 0));
?>
--EXPECT--

View file

@ -1,18 +0,0 @@
--TEST--
posix_mknod(): Basic tests
--SKIPIF--
<?php
if (!extension_loaded('posix')) die('skip - POSIX extension not loaded');
if (!function_exists('posix_mknod')) die('skip posix_mknod() not found');
?>
--FILE--
<?php
echo "Basic test of POSIX posix_mknod function\n";
var_dump(posix_mknod(NULL, NULL, NULL, NULL));
?>
===DONE====
--EXPECT--
Basic test of POSIX posix_mknod function
bool(false)
===DONE====

View file

@ -22,8 +22,6 @@ var_dump(pspell_config_runtogether($cfg, true));
$p = pspell_new_config($cfg);
var_dump(pspell_check($p, 'theoasis'));
var_dump(pspell_config_runtogether($cfg, NULL))
?>
--EXPECT--
bool(true)
@ -32,4 +30,3 @@ bool(false)
---
bool(true)
bool(true)
bool(true)

View file

@ -15,7 +15,6 @@ $name = tempnam(sys_get_temp_dir(), 'readline.tmp');
readline_add_history('foo');
readline_add_history('');
readline_add_history(1);
readline_add_history(NULL);
readline_write_history($name);
var_dump(file_get_contents($name));

View file

@ -16,7 +16,6 @@ $name = tempnam('/tmp', 'readline.tmp');
readline_add_history('foo');
readline_add_history('');
readline_add_history(1);
readline_add_history(NULL);
readline_write_history($name);
var_dump(file_get_contents($name));
@ -25,9 +24,8 @@ unlink($name);
?>
--EXPECT--
string(21) "_HiStOrY_V2_
string(20) "_HiStOrY_V2_
foo
1
"

View file

@ -7,7 +7,7 @@ readline_add_history(): Basic test
var_dump(readline_add_history('foo'));
var_dump(readline_list_history());
var_dump(readline_add_history(NULL));
var_dump(readline_add_history(''));
var_dump(readline_list_history());
var_dump(readline_clear_history());

View file

@ -13,7 +13,6 @@ $name = tempnam('/tmp', 'readline.tmp');
readline_add_history('foo');
readline_add_history('');
readline_add_history(1);
readline_add_history(NULL);
readline_write_history($name);
var_dump(file_get_contents($name));
@ -22,8 +21,7 @@ unlink($name);
?>
--EXPECT--
string(8) "foo
string(7) "foo
1
"

View file

@ -45,8 +45,10 @@ try {
}
?>
--EXPECT--
--EXPECTF--
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
Class "1" does not exist
Class "1" does not exist

View file

@ -8,7 +8,6 @@ class C {
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
var_dump($rc->getConstant(null));
var_dump($rc->getConstant(1));
var_dump($rc->getConstant(1.5));
var_dump($rc->getConstant(true));
@ -18,4 +17,3 @@ Check invalid params:
bool(false)
bool(false)
bool(false)
bool(false)

View file

@ -54,10 +54,12 @@ try {
?>
--EXPECT--
--EXPECTF--
Check invalid params:
ReflectionClass::getMethod() expects exactly 1 argument, 0 given
ReflectionClass::getMethod() expects exactly 1 argument, 2 given
Deprecated: ReflectionClass::getMethod(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
Method C::() does not exist
Method C::1() does not exist
Method C::1.5() does not exist

View file

@ -52,10 +52,12 @@ try {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
--EXPECTF--
Check invalid params:
ReflectionClass::getProperty() expects exactly 1 argument, 0 given
ReflectionClass::getProperty() expects exactly 1 argument, 2 given
Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
Property C::$ does not exist
Property C::$1 does not exist
Property C::$1.5 does not exist

View file

@ -38,9 +38,11 @@ try {
?>
--EXPECT--
--EXPECTF--
ReflectionClass::getStaticPropertyValue() expects at most 2 arguments, 3 given
ReflectionClass::getStaticPropertyValue() expects at least 1 argument, 0 given
Deprecated: ReflectionClass::getStaticPropertyValue(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
Property C::$ does not exist
string(3) "def"
ReflectionClass::getStaticPropertyValue(): Argument #1 ($name) must be of type string, array given

View file

@ -11,7 +11,6 @@ class C {
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
var_dump($rc->hasConstant(null));
var_dump($rc->hasConstant(1));
var_dump($rc->hasConstant(1.5));
var_dump($rc->hasConstant(true));
@ -21,4 +20,3 @@ Check invalid params:
bool(false)
bool(false)
bool(false)
bool(false)

View file

@ -11,7 +11,6 @@ class C {
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
var_dump($rc->hasMethod(null));
var_dump($rc->hasMethod(1));
var_dump($rc->hasMethod(1.5));
var_dump($rc->hasMethod(true));
@ -21,4 +20,3 @@ Check invalid params:
bool(false)
bool(false)
bool(false)
bool(false)

View file

@ -11,7 +11,6 @@ class C {
$rc = new ReflectionClass("C");
echo "Check invalid params:\n";
var_dump($rc->hasProperty(null));
var_dump($rc->hasProperty(1));
var_dump($rc->hasProperty(1.5));
var_dump($rc->hasProperty(true));
@ -21,4 +20,3 @@ Check invalid params:
bool(false)
bool(false)
bool(false)
bool(false)

View file

@ -65,7 +65,7 @@ try {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
--EXPECTF--
Does A implement A?
- Using object argument: A is not an interface
- Using string argument: A is not an interface
@ -146,6 +146,8 @@ Does I2 implement I2?
Test bad arguments:
ReflectionClass::implementsInterface() expects exactly 1 argument, 0 given
ReflectionClass::implementsInterface() expects exactly 1 argument, 2 given
Deprecated: ReflectionClass::implementsInterface(): Passing null to parameter #1 ($interface) of type ReflectionClass|string is deprecated in %s on line %d
Interface "" does not exist
Interface "ThisClassDoesNotExist" does not exist
Interface "2" does not exist

View file

@ -35,10 +35,12 @@ try {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
--EXPECTF--
Test bad arguments:
ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given
ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given
Deprecated: ReflectionClass::isSubclassOf(): Passing null to parameter #1 ($class) of type ReflectionClass|string is deprecated in %s on line %d
Class "" does not exist
Class "ThisClassDoesNotExist" does not exist
Class "2" does not exist

View file

@ -43,10 +43,12 @@ try {
?>
--EXPECT--
--EXPECTF--
ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 3 given
ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 0 given
ReflectionClass::setStaticPropertyValue() expects exactly 2 arguments, 1 given
Deprecated: ReflectionClass::setStaticPropertyValue(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d
Class C does not have a property named
Class C does not have a property named 1.5
ReflectionClass::setStaticPropertyValue(): Argument #1 ($name) must be of type string, array given

View file

@ -35,10 +35,12 @@ try {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
--EXPECTF--
Test bad arguments:
ReflectionClass::isSubclassOf() expects exactly 1 argument, 0 given
ReflectionClass::isSubclassOf() expects exactly 1 argument, 2 given
Deprecated: ReflectionClass::isSubclassOf(): Passing null to parameter #1 ($class) of type ReflectionClass|string is deprecated in %s on line %d
Class "" does not exist
Class "ThisClassDoesNotExist" does not exist
Class "2" does not exist

View file

@ -14,7 +14,7 @@ $sessionName = ini_get('session.name');
$sh->open($savePath, $sessionName);
$sh->write("foo", "bar");
var_dump($sh->read(@$id));
var_dump($sh->read(""));
?>
--EXPECTF--
Warning: SessionHandler::open(): Session is not active in %s on line 10

View file

@ -27,11 +27,11 @@ try {
}
// Warning outputs: Unable to attach or create shared memory segment
var_dump(shmop_open(null, 'a', 0644, 1024));
var_dump(shmop_open(0, 'a', 0644, 1024));
// Shared memory segment size must be greater than zero
try {
shmop_open(null, 'a', 0644, 1024);
shmop_open(0, 'a', 0644, 1024);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}

View file

@ -11,10 +11,10 @@ if (!extension_loaded('sockets')) {
--FILE--
<?php
var_dump(socket_create_pair(AF_INET, null, null, $sockets));
var_dump(socket_create_pair(AF_INET, 0, 0, $sockets));
try {
var_dump(socket_create_pair(31337, null, null, $sockets));
var_dump(socket_create_pair(31337, 0, 0, $sockets));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

View file

@ -11,10 +11,10 @@ if (!extension_loaded('sockets')) {
--FILE--
<?php
var_dump(socket_create_pair(AF_INET, null, null, $sockets));
var_dump(socket_create_pair(AF_INET, 0, 0, $sockets));
try {
var_dump(socket_create_pair(31337, null, null, $sockets));
var_dump(socket_create_pair(31337, 0, 0, $sockets));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

View file

@ -7,7 +7,7 @@ Check for libsodium utils
$a = 'test';
sodium_memzero($a);
if ($a !== 'test') {
echo strlen($a);
var_dump($a);
} else {
echo $a;
}
@ -107,7 +107,8 @@ try {
?>
--EXPECT--
0
NULL
bool(true)
bool(false)
string(22) "0000810102030405060708"

View file

@ -10,7 +10,8 @@ $array = new SplFixedArray( NULL );
print_r( $array );
?>
--EXPECT--
--EXPECTF--
Deprecated: SplFixedArray::__construct(): Passing null to parameter #1 ($size) of type int is deprecated in %s on line %d
SplFixedArray Object
(
)

View file

@ -8,6 +8,7 @@ $fixed_array = new SplFixedArray(2);
$fixed_array->setSize(null);
var_dump($fixed_array);
?>
--EXPECT--
--EXPECTF--
Deprecated: SplFixedArray::setSize(): Passing null to parameter #1 ($size) of type int is deprecated in %s on line %d
object(SplFixedArray)#1 (0) {
}

Some files were not shown because too many files have changed in this diff Show more