From: George Peter Banyard Date: Fri, 3 Apr 2020 17:20:26 +0000 (+0200) Subject: mb_scrub() can't return false anymore X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a34e73de5adf3999db66f0970da21bd0f6537595;p=php mb_scrub() can't return false anymore Also drop the intermediary function which was only used here --- diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 454440ef6e..960f67f7c5 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -4424,14 +4424,7 @@ PHP_FUNCTION(mb_chr) } /* }}} */ - -static inline char* php_mb_scrub(const char* str, size_t str_len, const mbfl_encoding *enc, size_t *ret_len) -{ - return php_mb_convert_encoding_ex(str, str_len, enc, enc, ret_len); -} - - -/* {{{ proto string|false mb_scrub([string str[, string encoding]]) */ +/* {{{ proto string mb_scrub([string str[, string encoding]]) */ PHP_FUNCTION(mb_scrub) { const mbfl_encoding *enc; @@ -4452,11 +4445,7 @@ PHP_FUNCTION(mb_scrub) RETURN_THROWS(); } - ret = php_mb_scrub(str, str_len, enc, &ret_len); - - if (ret == NULL) { - RETURN_FALSE; - } + ret = php_mb_convert_encoding_ex(str, str_len, enc, enc, &ret_len); RETVAL_STRINGL(ret, ret_len); efree(ret); diff --git a/ext/mbstring/mbstring.stub.php b/ext/mbstring/mbstring.stub.php index dfc920eb96..5210f7bf64 100644 --- a/ext/mbstring/mbstring.stub.php +++ b/ext/mbstring/mbstring.stub.php @@ -81,7 +81,7 @@ function mb_get_info(string $type = UNKNOWN): array|string|int|false {} function mb_check_encoding(array|string $var = UNKNOWN, string $encoding = UNKNOWN): bool {} -function mb_scrub(string $str, string $encoding = UNKNOWN): string|false {} +function mb_scrub(string $str, string $encoding = UNKNOWN): string {} function mb_ord(string $str, string $encoding = UNKNOWN): int|false {} diff --git a/ext/mbstring/mbstring_arginfo.h b/ext/mbstring/mbstring_arginfo.h index ea6af386e3..d6c237b410 100644 --- a/ext/mbstring/mbstring_arginfo.h +++ b/ext/mbstring/mbstring_arginfo.h @@ -193,7 +193,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_check_encoding, 0, 0, _IS_BOO ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_scrub, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_scrub, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO()