Skip to content

Commit 3bd4e60

Browse files
committed
[TwigBridge] Remove duck typing from AppVariable::getFlashes()
1 parent ba0a723 commit 3bd4e60

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/Symfony/Bridge/Twig/AppVariable.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\RequestStack;
16+
use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
1617
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1718
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1819
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -152,16 +153,12 @@ public function getLocale(): string
152153
public function getFlashes(string|array $types = null): array
153154
{
154155
try {
155-
if (null === $session = $this->getSession()) {
156-
return [];
157-
}
156+
$session = $this->getSession();
158157
} catch (\RuntimeException) {
159158
return [];
160159
}
161160

162-
// In 7.0 (when symfony/http-foundation: 6.4 is required) this can be updated to
163-
// check if the session is an instance of FlashBagAwareSessionInterface
164-
if (!method_exists($session, 'getFlashBag')) {
161+
if (!$session instanceof FlashBagAwareSessionInterface) {
165162
return [];
166163
}
167164

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy