From 9dab2c99f9ffdd34f70c2c7b9b1877bb30ea95b1 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 31 Jan 2026 20:11:23 +0700 Subject: [PATCH 1/3] ext/standard: add `ARRAY_FILTER_USE_VALUE` to `UPGRADING` Closes GH-21100. --- UPGRADING | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UPGRADING b/UPGRADING index fec4b15c102bd..830709b2ae23f 100644 --- a/UPGRADING +++ b/UPGRADING @@ -142,6 +142,9 @@ PHP 8.6 UPGRADE NOTES . EAI_INTR. . EAI_IDN_ENCODE. +- Standard + . ARRAY_FILTER_USE_KEY. + ======================================== 11. Changes to INI File Handling ======================================== From 6419618f54157521ff65f3040f092b45aae98214 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 31 Jan 2026 20:11:40 +0700 Subject: [PATCH 2/3] 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. --- ext/standard/basic_functions.stub.php | 2 +- ext/standard/basic_functions_arginfo.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 4ad26063a6718..4f77cf9b7f8ef 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -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 {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 2a1aa634fcdac..d63ea5e4e488b 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -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) From a01a8e72acdf3cba61abe51b7408968dcc81da09 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 1 Feb 2026 14:13:31 +0100 Subject: [PATCH 3/3] Fix failed assertion for assignment in expression context This code path is reachable for all assignments expressions, not just true variable expressions. Really surprising we have no tests that caught this. --- Zend/tests/gh20628_005.phpt | 20 ++++++++++++++++++++ Zend/zend_compile.c | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/gh20628_005.phpt diff --git a/Zend/tests/gh20628_005.phpt b/Zend/tests/gh20628_005.phpt new file mode 100644 index 0000000000000..43b49e0c18f2d --- /dev/null +++ b/Zend/tests/gh20628_005.phpt @@ -0,0 +1,20 @@ +--TEST-- +Failed assertion for assignment in expression context +--CREDITS-- +Matteo Beccati (mbeccati) +--FILE-- + 'baz']; +} + +var_dump(($v = foo())['bar'], $v); + +?> +--EXPECT-- +string(3) "baz" +array(1) { + ["bar"]=> + string(3) "baz" +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 325953e158e80..a013efab85964 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -12303,7 +12303,6 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty zend_compile_assign_ref(result, ast, type); return NULL; case ZEND_AST_ASSIGN: - ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ARRAY && zend_propagate_list_refs(ast->child[0])); zend_compile_assign(result, ast, false, type); return NULL; default: