summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/array.c6
-rwxr-xr-xext/standard/basic_functions.stub.php2
-rwxr-xr-xext/standard/basic_functions_arginfo.h2
-rw-r--r--ext/standard/tests/array/array_filter_basic.phpt12
4 files changed, 17 insertions, 5 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index fd0ceaa600..5138614858 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -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();
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 2017549e9b..71b922d7b2 100755
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -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 {}
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index 5e2e457ea2..23152bc22e 100755
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -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()
diff --git a/ext/standard/tests/array/array_filter_basic.phpt b/ext/standard/tests/array/array_filter_basic.phpt
index b2a51ab2c6..1b68649546 100644
--- a/ext/standard/tests/array/array_filter_basic.phpt
+++ b/ext/standard/tests/array/array_filter_basic.phpt
@@ -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