Skip to content

Commit 43998e6

Browse files
[BrowserKit][HttpClient][Routing] support building query strings with stringables
1 parent 97749d5 commit 43998e6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

HttpClientTrait.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,18 @@ private static function normalizeHeaders(array $headers): array
291291
private static function normalizeBody($body)
292292
{
293293
if (\is_array($body)) {
294-
return http_build_query($body, '', '&', \PHP_QUERY_RFC1738);
294+
array_walk_recursive($body, $caster = static function (&$v) use (&$caster) {
295+
if (\is_object($v)) {
296+
if ($vars = get_object_vars($v)) {
297+
array_walk_recursive($vars, $caster);
298+
$v = $vars;
299+
} elseif (method_exists($v, '__toString')) {
300+
$v = (string) $v;
301+
}
302+
}
303+
});
304+
305+
return http_build_query($body, '', '&');
295306
}
296307

297308
if (\is_string($body)) {

0 commit comments

Comments
 (0)