Skip to content

Commit

Permalink
Update AbstractController.php
Browse files Browse the repository at this point in the history
Removing `string` type-hint of $message at addFlash()

Closes #28991 and #34645

Reasons:

* `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`, see https://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.
  • Loading branch information
ThomasLandauer authored and nicolas-grekas committed Jun 4, 2020
1 parent 400ab7c commit dfb4614
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -187,7 +187,7 @@ protected function file($file, $fileName = null, $disposition = ResponseHeaderBa
* Adds a flash message to the current session for type.
*
* @param string $type The type
* @param string $message The message
* @param mixed $message The message
*
* @throws \LogicException
*
Expand Down

0 comments on commit dfb4614

Please sign in to comment.