mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Allow null callback to array_filter()
With same behavior as not passing it.
This commit is contained in:
@@ -1380,6 +1380,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
|
||||
#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
|
||||
Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
|
||||
|
||||
#define Z_PARAM_FUNC_OR_NULL(dest_fci, dest_fcc) \
|
||||
Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 1, 0)
|
||||
|
||||
/* old "h" */
|
||||
#define Z_PARAM_ARRAY_HT_EX2(dest, check_null, deref, separate) \
|
||||
Z_PARAM_PROLOGUE(deref, separate); \
|
||||
|
||||
@@ -1067,7 +1067,7 @@ PHP_FUNCTION(libxml_set_external_entity_loader)
|
||||
zend_fcall_info_cache fcc;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_FUNC_EX(fci, fcc, 1, 0)
|
||||
Z_PARAM_FUNC_OR_NULL(fci, fcc)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
_php_libxml_destroy_fci(&LIBXML(entity_loader).fci, &LIBXML(entity_loader).object);
|
||||
|
||||
@@ -1361,7 +1361,7 @@ PHP_METHOD(SQLite3, setAuthorizer)
|
||||
zend_fcall_info_cache fcc;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_FUNC_EX(fci, fcc, 1, 0)
|
||||
Z_PARAM_FUNC_OR_NULL(fci, fcc)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
|
||||
|
||||
@@ -5958,7 +5958,7 @@ PHP_FUNCTION(array_filter)
|
||||
ZEND_PARSE_PARAMETERS_START(1, 3)
|
||||
Z_PARAM_ARRAY(array)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_FUNC(fci, fci_cache)
|
||||
Z_PARAM_FUNC_OR_NULL(fci, fci_cache)
|
||||
Z_PARAM_LONG(use_type)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
@@ -5969,7 +5969,7 @@ PHP_FUNCTION(array_filter)
|
||||
}
|
||||
array_init(return_value);
|
||||
|
||||
if (ZEND_NUM_ARGS() > 1) {
|
||||
if (ZEND_FCI_INITIALIZED(fci)) {
|
||||
have_callback = 1;
|
||||
fci.no_separation = 0;
|
||||
fci.retval = &retval;
|
||||
@@ -6045,7 +6045,7 @@ PHP_FUNCTION(array_map)
|
||||
uint32_t k, maxlen = 0;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(2, -1)
|
||||
Z_PARAM_FUNC_EX(fci, fci_cache, 1, 0)
|
||||
Z_PARAM_FUNC_OR_NULL(fci, fci_cache)
|
||||
Z_PARAM_VARIADIC('+', arrays, n_arrays)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ function array_product(array $arg): int|float {}
|
||||
/** @return mixed */
|
||||
function array_reduce(array $arg, callable $callback, $initial = null) {}
|
||||
|
||||
function array_filter(array $arg, callable $callback = UNKNOWN, int $use_keys = 0): array {}
|
||||
function array_filter(array $arg, ?callable $callback = null, int $use_keys = 0): array {}
|
||||
|
||||
function array_map(?callable $callback, array $arr1, array ...$arrays): array {}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_filter, 0, 1, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, arg, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, callback, IS_CALLABLE, 1, "null")
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_keys, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ var_dump( array_filter($input,"even") );
|
||||
|
||||
// with default arguments
|
||||
var_dump( array_filter($input) );
|
||||
// same as with default arguments
|
||||
var_dump( array_filter($input, null) );
|
||||
|
||||
echo "Done"
|
||||
?>
|
||||
@@ -52,4 +54,14 @@ array(4) {
|
||||
[4]=>
|
||||
int(-1)
|
||||
}
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[4]=>
|
||||
int(-1)
|
||||
}
|
||||
Done
|
||||
|
||||
Reference in New Issue
Block a user