Use ARRAY_OR_OBJECT arg in http_build_query

Instead of checking the type manually. Peculiarily the zpp
message does not use "array or object", but that's a general issue.
And I guess it's good that object support is not being advertised.
This commit is contained in:
Nikita Popov 2018-10-11 12:56:12 +02:00
parent 900ee5705f
commit 4ca5b35771
2 changed files with 2 additions and 7 deletions

View File

@ -232,18 +232,13 @@ PHP_FUNCTION(http_build_query)
zend_long enc_type = PHP_QUERY_RFC1738;
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_ZVAL(formdata)
Z_PARAM_ARRAY_OR_OBJECT(formdata)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(prefix, prefix_len)
Z_PARAM_STRING(arg_sep, arg_sep_len)
Z_PARAM_LONG(enc_type)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given");
RETURN_FALSE;
}
if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep, (int)enc_type) == FAILURE) {
if (formstr.s) {
smart_str_free(&formstr);

View File

@ -10,4 +10,4 @@ $result = http_build_query(null);
?>
--EXPECTF--
Warning: http_build_query(): Parameter 1 expected to be Array or Object. %s value given in %s on line %d
Warning: http_build_query() expects parameter 1 to be array, null given in %s on line %d