1 | <?php declare(strict_types=1); |
||
15 | final class SessionMiddleware |
||
16 | { |
||
17 | const ATTRIBUTE_NAME = 'wyrihaximus.react.http.middleware.session'; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $cookieName = ''; |
||
23 | |||
24 | /** |
||
25 | * @var CacheInterface |
||
26 | */ |
||
27 | private $cache; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $cookieParams = []; |
||
33 | |||
34 | /** |
||
35 | * @var SessionIdInterface |
||
36 | */ |
||
37 | private $sessionId; |
||
38 | |||
39 | /** |
||
40 | * @param string $cookieName |
||
41 | * @param CacheInterface $cache |
||
42 | * @param array $cookieParams |
||
43 | */ |
||
44 | 12 | public function __construct( |
|
45 | string $cookieName, |
||
46 | CacheInterface $cache, |
||
47 | array $cookieParams = [], |
||
48 | SessionIdInterface $sessionId = null |
||
49 | ) { |
||
50 | 12 | $this->cookieName = $cookieName; |
|
51 | 12 | $this->cache = $cache; |
|
52 | 12 | $this->cookieParams = $cookieParams; |
|
53 | |||
54 | 12 | if ($sessionId === null) { |
|
55 | 12 | $sessionId = new RandomBytes(); |
|
56 | } |
||
57 | 12 | $this->sessionId = $sessionId; |
|
58 | 12 | } |
|
59 | |||
60 | public function __invoke(ServerRequestInterface $request, callable $next) |
||
78 | |||
79 | 12 | private function fetchSessionFromRequest(ServerRequestInterface $request): PromiseInterface |
|
100 | |||
101 | private function fetchSessionDataFromCache(string $id): PromiseInterface |
||
107 | |||
108 | 12 | private function updateCache(string $currentSessionId, string $requestSessionId, array $contents) |
|
118 | } |
||
119 |
It seems like you are assigning to a variable which was imported through a
use
statement which was not imported by reference.For clarity, we suggest to use a different name or import by reference depending on whether you would like to have the change visibile in outer-scope.
Change not visible in outer-scope
Change visible in outer-scope