-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Routing] Fix support for stringable parameters #42057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
http_build_query
does not cast
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,6 +294,15 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa | |
return $a == $b ? 0 : 1; | ||
}); | ||
|
||
array_walk_recursive($extra, $caster = static function (&$v) use (&$caster) { | ||
if ($v instanceof \stdClass) { | ||
$v = (array) $v; | ||
array_walk_recursive($v, $caster); | ||
} elseif (null !== $v) { | ||
OskarStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$v = (string) $v; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about array-like objects here? I'd guess that Iterators/ArrayAccess implementations would want to behave similar to Would it be an idea to give users control over how the parameters should be rendered, perhaps through an interface or custom parameter object that can deal with this? There was a problem hiding this comment. 8000 Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For those, we should mimik what http_build_query does, nothing more. A test case would help know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the object does not implement __toString this would throw an exception which is a bc break. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I added a test case and check for __toString() in 31d6937
We could check if some public properties exists and do nothing instead of using toString() |
||
} | ||
}); | ||
|
||
// extract fragment | ||
$fragment = $defaults['_fragment'] ?? ''; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is breaking for classes that extend stdClass, https://3v4l.org/6e5Vj