-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing][TwigExtensions] Inconsistency of path dealing with boolean #21409
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
Comments
I can't reproduce the issue :/. I.E, given the following
|
First, thank you for your answer. Well, for me:
But
My route: /**
* @Route("/approve_game/{id}/{approved}", name="api.approve_game")
*/
public function approveGameAction(Request $request, Game $game, bool $approved) So what's the hell? |
|
@ogizanagi Is it truly expected behavior to treat conversion of
That seems inconsistent to me, regardless of original implementation. Is there a good reason for this or would it be possible to make the behavior consistent in a future major version release, when BC can be broken for the sake of a consistent approach. |
I agree. This looks inconsistent. Bad news is that fixing this will be a BC break. Should we:
|
Well, this is just the way casting a boolean to string works in PHP. The rule is not |
And your issue is related to the fact that route placeholders are meant to be strings. Passing booleans there is supported only because casting is supported, but then it follows the PHP casting rules. If you don't want these casting rules, pass a string directly. |
I understand why it behaves this way, I simply disagree that is should remain working this way, moving forward. |
As @stof said, those values are strings, nothing else. Passing a boolean there does not make sense in the first place. |
Given the comments above, I'm closing this as "won't fix" then. First, because this is in fact PHP's behavior, not Symfony's ... and second, because the solution is "simple": not passing boolean values as route placeholders because they are not supported (only strings and numeric values). |
Thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Hello!
In Twig, the
path
function acceptstrue
as a boolean argument and then outputs"1"
in the url, which is then consistently proccessed by the Router, while when passingfalse
it outputs"false"
in the url, which is interpreted as a string and do not matches.Is this intended, a bug or an inconsistency?
The text was updated successfully, but these errors were encountered: