Skip to content

Commit 9dafdc1

Browse files
Dirkhuethorstfabpot
authored andcommitted
[TwigBridge] Change return type of Symfony\Bridge\Twig\AppVariable::getSession()
1 parent b857ae4 commit 9dafdc1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Bridge/Twig/AppVariable.php

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

1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\RequestStack;
16-
use Symfony\Component\HttpFoundation\Session\Session;
16+
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1717
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1818
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1919
use Symfony\Component\Security\Core\User\UserInterface;
@@ -112,7 +112,7 @@ public function getRequest(): ?Request
112112
/**
113113
* Returns the current session.
114114
*/
115-
public function getSession(): ?Session
115+
public function getSession(): ?SessionInterface
116116
{
117117
if (!isset($this->requestStack)) {
118118
throw new \RuntimeException('The "app.session" variable is not available.');
@@ -171,6 +171,12 @@ public function getFlashes(string|array $types = null): array
171171
return [];
172172
}
173173

174+
// In 7.0 (when symfony/http-foundation: 6.4 is required) this can be updated to
175+
// check if the session is an instance of FlashBagAwareSessionInterface
176+
if (!method_exists($session, 'getFlashBag')) {
177+
return [];
178+
}
179+
174180
if (null === $types || '' === $types || [] === $types) {
175181
return $session->getFlashBag()->all();
176182
}

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