Skip to content

Commit 714105e

Browse files
[BrowserKit][HttpClient][Routing] support building query strings with stringables
1 parent 5a54b92 commit 714105e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Generator/UrlGenerator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,17 @@ protected function doGenerate(array $variables, array $defaults, array $requirem
295295
return $a == $b ? 0 : 1;
296296
});
297297

298+
array_walk_recursive($extra, $caster = static function (&$v) use (&$caster) {
299+
if (\is_object($v)) {
300+
if ($vars = get_object_vars($v)) {
301+
array_walk_recursive($vars, $caster);
302+
$v = $vars;
303+
} elseif (method_exists($v, '__toString')) {
304+
$v = (string) $v;
305+
}
306+
}
307+
});
308+
298309
// extract fragment
299310
$fragment = $defaults['_fragment'] ?? '';
300311

0 commit comments

Comments
 (0)