Category
stdlib
Problem
Zend http_build_query() accepts:
$arg_separator = null — use & (PHP 7.4+)
$encoding_type — PHP_QUERY_RFC1738 (default) or PHP_QUERY_RFC3986 (spaces → %20, not +)
- Named parameters — e.g.
http_build_query($data, arg_separator: '&', encoding_type: PHP_QUERY_RFC3986)
This compiler rejects null separators, named-arg calls, and RFC3986 encoding:
| Call |
Zend |
VM today |
http_build_query(['a'=>'b c'], '', null, PHP_QUERY_RFC3986) |
a=b%20c |
LogicException: argument #3 must be a string |
http_build_query(['a'=>'b c'], arg_separator: '&', encoding_type: PHP_QUERY_RFC3986) |
a=b%20c |
compile error: Too many arguments |
http_build_query(['a'=>'b c'], encoding_type: PHP_QUERY_RFC3986) |
a=b%20c |
not supported |
Distinct from #4272 (object/bool value encoding) and #5654 (backed enum case values).
php-src reference
- php/php-src
ext/standard/http.c — PHP_FUNCTION(http_build_query), php_url_encode_hash_ex
PHP_QUERY_RFC1738 / PHP_QUERY_RFC3986 constants in ext/standard/basic_functions.c
Repro
<?php
echo http_build_query(['a' => 'b c'], '', null, PHP_QUERY_RFC3986), "\n";
echo http_build_query(['a' => 'b c'], arg_separator: '&', encoding_type: PHP_QUERY_RFC3986), "\n";
./script/docker-exec.sh -- bash -lc '
php /tmp/repro/hbq.php
php bin/vm.php /tmp/repro/hbq.php
'
(Write /tmp/repro/hbq.php with the snippet above.)
Scope (PHP-in-PHP first)
| Path |
Work |
ext/standard/http_build_query.php |
Accept null arg #3 → default &; honor arg #4 / named encoding_type |
ext/standard/VmHttpBuildQuery.php |
RFC3986 vs RFC1738 space encoding (%20 vs +) |
ext/standard/Module.php |
Register PHP_QUERY_RFC1738 / PHP_QUERY_RFC3986 if missing |
lib/JIT/Builtin/ |
Mirror encoding flag in JitHttpBuildQuery / __compiler_http_build_query |
test/compliance/cases/stdlib/http_build_query_encoding.phpt |
null separator + RFC3986 + named args |
Current VM code throws when arg #3 is not TYPE_STRING (ext/standard/http_build_query.php).
Done when
php-src-strict: enum case operands in data array covered by #5654; this issue is separator/encoding signature parity only.
Category
stdlibProblem
Zend
http_build_query()accepts:$arg_separator = null— use&(PHP 7.4+)$encoding_type—PHP_QUERY_RFC1738(default) orPHP_QUERY_RFC3986(spaces →%20, not+)http_build_query($data, arg_separator: '&', encoding_type: PHP_QUERY_RFC3986)This compiler rejects null separators, named-arg calls, and RFC3986 encoding:
http_build_query(['a'=>'b c'], '', null, PHP_QUERY_RFC3986)a=b%20cLogicException: argument #3 must be a stringhttp_build_query(['a'=>'b c'], arg_separator: '&', encoding_type: PHP_QUERY_RFC3986)a=b%20chttp_build_query(['a'=>'b c'], encoding_type: PHP_QUERY_RFC3986)a=b%20cDistinct from #4272 (object/bool value encoding) and #5654 (backed enum case values).
php-src reference
ext/standard/http.c—PHP_FUNCTION(http_build_query),php_url_encode_hash_exPHP_QUERY_RFC1738/PHP_QUERY_RFC3986constants inext/standard/basic_functions.cRepro
(Write
/tmp/repro/hbq.phpwith the snippet above.)Scope (PHP-in-PHP first)
ext/standard/http_build_query.phpnullarg #3 → default&; honor arg #4 / namedencoding_typeext/standard/VmHttpBuildQuery.php%20vs+)ext/standard/Module.phpPHP_QUERY_RFC1738/PHP_QUERY_RFC3986if missinglib/JIT/Builtin/JitHttpBuildQuery/__compiler_http_build_querytest/compliance/cases/stdlib/http_build_query_encoding.phptCurrent VM code throws when arg #3 is not
TYPE_STRING(ext/standard/http_build_query.php).Done when
a=b%20con VM (match Zend)null$arg_separatorcoerces to&encoding_type→ValueErrorlike Zend./script/ci-fast.sh --filter http_build_query_encodinggreenphp-src-strict: enum case operands in data array covered by #5654; this issue is separator/encoding signature parity only.