From 996a5f0e09058834e59e120f03e7f611204f8bcd Mon Sep 17 00:00:00 2001 From: lacatoire Date: Sun, 16 Aug 2026 12:18:35 +0200 Subject: [PATCH] Narrow the return type of filter_var_array() to array|false The stub declares array|false|null, but null is unreachable. The function has two exits: RETURN_FALSE for an unknown filter id, and the array handler, which establishes an array on both of its branches before doing anything else. Its remaining exits throw. The sibling filter_input_array() is declared identically and does return null, deliberately, because its source superglobal may not exist. That case has no equivalent here, where the source is a required array parameter. null remains an ordinary element value in the returned array, which is likely where the wider union came from; that is the value type, not the return type. --- ext/filter/filter.stub.php | 2 +- ext/filter/filter_arginfo.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/filter/filter.stub.php b/ext/filter/filter.stub.php index 4332f9261e98..16a6fe5c940c 100644 --- a/ext/filter/filter.stub.php +++ b/ext/filter/filter.stub.php @@ -310,7 +310,7 @@ function filter_var(mixed $value, int $filter = FILTER_DEFAULT, array|int $optio function filter_input_array(int $type, array|int $options = FILTER_DEFAULT, bool $add_empty = true): array|false|null {} /** @refcount 1 */ -function filter_var_array(array $array, array|int $options = FILTER_DEFAULT, bool $add_empty = true): array|false|null {} +function filter_var_array(array $array, array|int $options = FILTER_DEFAULT, bool $add_empty = true): array|false {} /** * @return array diff --git a/ext/filter/filter_arginfo.h b/ext/filter/filter_arginfo.h index 4e24ede41a63..891647362997 100644 --- a/ext/filter/filter_arginfo.h +++ b/ext/filter/filter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit filter.stub.php instead. - * Stub hash: c3eb55dfec619af1e46be206f51a2b0893ed399f */ + * Stub hash: bd421586fdc068c456415b597d718787eb140517 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_filter_has_var, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, input_type, IS_LONG, 0) @@ -25,7 +25,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_filter_input_array, 0, 1, MAY_BE ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, add_empty, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_filter_var_array, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE|MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_filter_var_array, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_MASK(0, options, MAY_BE_ARRAY|MAY_BE_LONG, "FILTER_DEFAULT") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, add_empty, _IS_BOOL, 0, "true")