mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
mb_detect_order(): Use proper array|string argument
This commit is contained in:
parent
500230fc85
commit
8a2ce27bba
3 changed files with 19 additions and 23 deletions
|
@ -1530,13 +1530,15 @@ PHP_FUNCTION(mb_http_output)
|
|||
Sets the current detect_order or Return the current detect_order as a array */
|
||||
PHP_FUNCTION(mb_detect_order)
|
||||
{
|
||||
zval *arg1 = NULL;
|
||||
zend_string *order_str = NULL;
|
||||
HashTable *order_ht = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg1) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
ZEND_PARSE_PARAMETERS_START(0, 1)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_STR_OR_ARRAY_HT(order_str, order_ht)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (!arg1) {
|
||||
if (!order_str && !order_ht) {
|
||||
size_t i;
|
||||
size_t n = MBSTRG(current_detect_order_list_size);
|
||||
const mbfl_encoding **entry = MBSTRG(current_detect_order_list);
|
||||
|
@ -1546,22 +1548,16 @@ PHP_FUNCTION(mb_detect_order)
|
|||
entry++;
|
||||
}
|
||||
} else {
|
||||
const mbfl_encoding **list = NULL;
|
||||
size_t size = 0;
|
||||
switch (Z_TYPE_P(arg1)) {
|
||||
case IS_ARRAY:
|
||||
if (FAILURE == php_mb_parse_encoding_array(Z_ARRVAL_P(arg1), &list, &size)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!try_convert_to_string(arg1)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
if (FAILURE == php_mb_parse_encoding_list(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), &list, &size, 0)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
const mbfl_encoding **list;
|
||||
size_t size;
|
||||
if (order_ht) {
|
||||
if (FAILURE == php_mb_parse_encoding_array(order_ht, &list, &size)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
if (FAILURE == php_mb_parse_encoding_list(ZSTR_VAL(order_str), ZSTR_LEN(order_str), &list, &size, 0)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
|
|
|
@ -8,7 +8,7 @@ function mb_http_input(string $type = UNKNOWN): array|string|false {}
|
|||
|
||||
function mb_http_output(string $encoding = UNKNOWN): string|bool {}
|
||||
|
||||
function mb_detect_order($encoding = UNKNOWN): array|bool {}
|
||||
function mb_detect_order(array|string $encoding = UNKNOWN): array|bool {}
|
||||
|
||||
/** @param string|int $substchar */
|
||||
function mb_substitute_character($substchar = UNKNOWN): string|int|bool {}
|
||||
|
|
|
@ -15,7 +15,7 @@ ZEND_END_ARG_INFO()
|
|||
#define arginfo_mb_http_output arginfo_mb_internal_encoding
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_detect_order, 0, 0, MAY_BE_ARRAY|MAY_BE_BOOL)
|
||||
ZEND_ARG_INFO(0, encoding)
|
||||
ZEND_ARG_TYPE_MASK(0, encoding, MAY_BE_ARRAY|MAY_BE_STRING)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_substitute_character, 0, 0, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue