1 | <?php |
||
2 | /** |
||
3 | * @link https://www.yiiframework.com/ |
||
4 | * @copyright Copyright (c) 2008 Yii Software LLC |
||
5 | * @license https://www.yiiframework.com/license/ |
||
6 | */ |
||
7 | |||
8 | namespace yii\web; |
||
9 | |||
10 | use SessionHandlerInterface; |
||
11 | |||
12 | /** |
||
13 | * SessionHandler implements an [[\SessionHandlerInterface]] for handling [[Session]] with custom session storage. |
||
14 | * |
||
15 | * @author Viktor Khokhryakov <[email protected]> |
||
16 | * @since 2.0.52 |
||
17 | */ |
||
18 | class SessionHandler implements SessionHandlerInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var Session |
||
22 | */ |
||
23 | private $_session; |
||
24 | |||
25 | |||
26 | 2 | public function __construct(Session $session) |
|
27 | { |
||
28 | 2 | $this->_session = $session; |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * @inheritDoc |
||
33 | */ |
||
34 | 2 | public function close(): bool |
|
35 | { |
||
36 | 2 | return $this->_session->closeSession(); |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * @inheritDoc |
||
41 | */ |
||
42 | public function destroy($id): bool |
||
43 | { |
||
44 | return $this->_session->destroySession($id); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @inheritDoc |
||
49 | */ |
||
50 | #[\ReturnTypeWillChange] |
||
51 | public function gc($max_lifetime) |
||
52 | { |
||
53 | return $this->_session->gcSession($max_lifetime); |
||
0 ignored issues
–
show
|
|||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritDoc |
||
58 | */ |
||
59 | 3 | public function open($path, $name): bool |
|
60 | { |
||
61 | 3 | return $this->_session->openSession($path, $name); |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @inheritDoc |
||
66 | */ |
||
67 | 3 | #[\ReturnTypeWillChange] |
|
68 | public function read($id) |
||
69 | { |
||
70 | 3 | return $this->_session->readSession($id); |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * @inheritDoc |
||
75 | */ |
||
76 | 2 | public function write($id, $data): bool |
|
77 | { |
||
78 | 2 | return $this->_session->writeSession($id, $data); |
|
79 | } |
||
80 | } |
||
81 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: