Skip to content

Commit 1208aba

Browse files
Adding that you cannot access a session inside a constructor
Please double-check! The info is taken from PhpStorm's Symfony Plugin: https://espend.de/phpstorm/plugin/symfony#inspections: > A Session must not be used inside a constructor I think this should be explained here, since doing `$this->session = $requestStack->getSession();` right in the constructor looked like a nice idea...
1 parent 312e259 commit 1208aba

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

session.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ if you type-hint an argument with :class:`Symfony\\Component\\HttpFoundation\\Re
149149
public function __construct(RequestStack $requestStack)
150150
{
151151
$this->requestStack = $requestStack;
152+
153+
// This does *not* work, since you cannot access the session inside a constructor
154+
// $this->session = $requestStack->getSession();
152155
}
153156

154157
public function someMethod()

0 commit comments

Comments
 (0)