From bc6ec0a109177bae7ee662c4f1d0b19b3bc3150b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 18 Nov 2021 10:36:35 +0100 Subject: [PATCH] Clarify that preg_match_all() cannot return null --- ext/pcre/php_pcre.c | 2 +- ext/pcre/php_pcre.stub.php | 2 +- ext/pcre/php_pcre_arginfo.h | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 19567889d88..340e103857f 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1206,7 +1206,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, if (subpats != NULL) { subpats = zend_try_array_init(subpats); if (!subpats) { - return; + RETURN_THROWS(); } } diff --git a/ext/pcre/php_pcre.stub.php b/ext/pcre/php_pcre.stub.php index b2862a2f62e..cf091f1dd60 100644 --- a/ext/pcre/php_pcre.stub.php +++ b/ext/pcre/php_pcre.stub.php @@ -6,7 +6,7 @@ function preg_match(string $pattern, string $subject, &$matches = null, int $flags = 0, int $offset = 0): int|false {} /** @param array $matches */ -function preg_match_all(string $pattern, string $subject, &$matches = null, int $flags = 0, int $offset = 0): int|false|null {} +function preg_match_all(string $pattern, string $subject, &$matches = null, int $flags = 0, int $offset = 0): int|false {} /** @param int $count */ function preg_replace(string|array $pattern, string|array $replacement, string|array $subject, int $limit = -1, &$count = null): string|array|null {} diff --git a/ext/pcre/php_pcre_arginfo.h b/ext/pcre/php_pcre_arginfo.h index c53f35559e3..1e58849c84b 100644 --- a/ext/pcre/php_pcre_arginfo.h +++ b/ext/pcre/php_pcre_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2e5a9edc9635edd4f5a00e9d888fb34c1746a5b8 */ + * Stub hash: 8b3d31a0fc1542bcb432f1200a7b9f49afbf0f1f */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) @@ -9,13 +9,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match, 0, 2, MAY_BE_LONG|MA ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match_all, 0, 2, MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_NULL) - ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, matches, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() +#define arginfo_preg_match_all arginfo_preg_match ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_replace, 0, 3, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_NULL) ZEND_ARG_TYPE_MASK(0, pattern, MAY_BE_STRING|MAY_BE_ARRAY, NULL)