diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-30 16:06:41 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-30 16:15:12 +0200 |
commit | 50d07ff28c9e91f310bf6145b657fccd17b09bec (patch) | |
tree | c212faee882b2fd805db7c36736fca7b67ea5ff9 /Zend/zend_API.h | |
parent | 47ddd95836142a5bea28abab26999e72d5f85493 (diff) | |
download | php-git-50d07ff28c9e91f310bf6145b657fccd17b09bec.tar.gz |
mb_detect_encoding(): Use proper array|string parameter
Needed to add support for nullabiltiy in some places.
Diffstat (limited to 'Zend/zend_API.h')
-rw-r--r-- | Zend/zend_API.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index fe5694940c..a925651b83 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1548,14 +1548,20 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num #define Z_PARAM_VARIADIC(spec, dest, dest_num) \ Z_PARAM_VARIADIC_EX(spec, dest, dest_num, 0) -#define Z_PARAM_STR_OR_ARRAY_HT(dest_str, dest_ht) \ +#define Z_PARAM_STR_OR_ARRAY_HT_EX(dest_str, dest_ht, allow_null) \ Z_PARAM_PROLOGUE(0, 0); \ - if (UNEXPECTED(!zend_parse_arg_str_or_array_ht(_arg, &dest_str, &dest_ht))) { \ + if (UNEXPECTED(!zend_parse_arg_str_or_array_ht(_arg, &dest_str, &dest_ht, allow_null))) { \ _expected_type = Z_EXPECTED_STRING_OR_ARRAY; \ _error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_STR_OR_ARRAY_HT(dest_str, dest_ht) \ + Z_PARAM_STR_OR_ARRAY_HT_EX(dest_str, dest_ht, 0); + +#define Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(dest_str, dest_ht) \ + Z_PARAM_STR_OR_ARRAY_HT_EX(dest_str, dest_ht, 1); + /* End of new parameter parsing API */ /* Inlined implementations shared by new and old parameter parsing APIs */ @@ -1775,7 +1781,7 @@ static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, } static zend_always_inline int zend_parse_arg_str_or_array_ht( - zval *arg, zend_string **dest_str, HashTable **dest_ht) + zval *arg, zend_string **dest_str, HashTable **dest_ht, int allow_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *dest_str = Z_STR_P(arg); @@ -1783,6 +1789,9 @@ static zend_always_inline int zend_parse_arg_str_or_array_ht( } else if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { *dest_ht = Z_ARRVAL_P(arg); *dest_str = NULL; + } else if (allow_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) { + *dest_ht = NULL; + *dest_str = NULL; } else { *dest_ht = NULL; return zend_parse_arg_str_slow(arg, dest_str); |