1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/standard: update array_filter $mode param default value to ARRAY_FILTER_USE_VALUE

In GH-15647, the `array_filter` function was changed to throw a
`ValueError` exception when the `$mode` parameter receives an
invalid.

Additionally, it declares a new `ARRAY_FILTER_USE_VALUE`, assigned
(`int 1`) to it.

This changes the default value of the `array_filter` function's
`$mode` parameter to use the new constant, changing it from
`int $mode = 0` to `int $mode = ARRAY_FILTER_USE_KEY)`.

Closes GH-21100.
This commit is contained in:
Ayesh Karunaratne
2026-01-31 20:11:40 +07:00
parent 9dab2c99f9
commit 6419618f54
2 changed files with 3 additions and 3 deletions

View File

@@ -1871,7 +1871,7 @@ function array_product(array $array): int|float {}
function array_reduce(array $array, callable $callback, mixed $initial = null): mixed {}
function array_filter(array $array, ?callable $callback = null, int $mode = 0): array {}
function array_filter(array $array, ?callable $callback = null, int $mode = ARRAY_FILTER_USE_KEY): array {}
function array_find(array $array, callable $callback): mixed {}

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit basic_functions.stub.php instead.
* Stub hash: a4324854949e2df355625c18a4e26d066c8f7a17 */
* Stub hash: 9857f77dbcc832992bf6b20b02d4b81dad8909b2 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@@ -345,7 +345,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, array, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, callback, IS_CALLABLE, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "ARRAY_FILTER_USE_KEY")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_find, 0, 2, IS_MIXED, 0)