Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] fix type annotation on ControllerTrait::addFlash()#36913
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedMay 23, 2020
This should be considered on 3.4 first to me, agreeing on changing the annotation. Note that technically this is a BC break, but the method is |
ThomasLandauer commentedMay 23, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In 3.4 the type-hint isn't there - so everything's fine:https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php#L196 In 4.4 it is there, but the entire method still lives in |
ro0NL commentedMay 31, 2020
|
Removing `string` type-hint of $message at addFlash()Closes#28991 and#34645Reasons:* `addFlash()` is just a convenience shortcut for `FlashBagInterface::add()` which doesn't have the type hint:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php#L28 . So removing it here improves consistency.*#28991 (comment) is a valid use case for having an object as `$message`.* Twig doesn't have any rendering helpers for the `message`, seehttps://symfony.com/doc/current/controller.html#flash-messages . And since users have to take care of displaying the `message` themselves, there's no reason to force a string upon them.
nicolas-grekas left a comment
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.
(I rebased to target 3.4, the change on upper branches will be applied when merging up)
fabpot commentedJun 10, 2020
Thank you@ThomasLandauer. |
Uh oh!
There was an error while loading.Please reload this page.
Removing
stringtype-hint of $message at addFlash()Closes#28991 and#34645
Reasons:
addFlash()is just a convenience shortcut forFlashBagInterface::add()which doesn't have the type hint:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php#L28 . So removing it here improves consistency.Flash message behavior changed #28991 (comment) is a valid use case for having an object as
$message.Twig doesn't have any rendering helpers for the
message, seehttps://symfony.com/doc/current/controller.html#flash-messages . And since users have to take care of displaying themessagethemselves, there's no reason to force a string upon them.This isn't a real new feature, but it isn't a bugfix either ;-)
I didn't update
src/**/CHANGELOG.mdyet.I'm not sure if it's necessary to update the docs. Maybe a short notehttps://symfony.com/doc/current/controller.html#flash-messages ?