1 | <?php |
||
12 | class RedisDriver |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $dsn; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $host; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $port; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $user; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $password; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $database; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $socket; |
||
48 | |||
49 | /** |
||
50 | * @var |
||
51 | */ |
||
52 | protected $client; |
||
53 | |||
54 | /** |
||
55 | * RedisDriver constructor. |
||
56 | */ |
||
57 | public function __construct(string $dsn = 'redis://localhost:6379') |
||
62 | |||
63 | /** |
||
64 | * Get redis client. |
||
65 | */ |
||
66 | public function getClient(bool $reset = false): Client |
||
81 | |||
82 | public function getHost(): string |
||
86 | |||
87 | public function getPort(): int |
||
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | */ |
||
95 | public function getUser(): ?string |
||
99 | |||
100 | /** |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getPassword(): ?string |
||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getDatabase(): ?string |
||
115 | |||
116 | /** |
||
117 | * @return string |
||
118 | */ |
||
119 | public function getSocket(): ?string |
||
123 | |||
124 | /** |
||
125 | * Parse dsn and get all needed attributes. |
||
126 | * |
||
127 | * @param string $dsn |
||
128 | */ |
||
129 | protected function parseDsn($dsn) |
||
162 | |||
163 | /** |
||
164 | * @param array $matches |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | protected function parseParameters($matches) |
||
187 | } |
||
188 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.