1 | <?php |
||
28 | class Database extends BaseEventEmitter implements DatabaseInterface |
||
29 | { |
||
30 | use LoopAwareTrait; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | const STATE_INIT = 0; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | const STATE_CONNECT_PENDING = 4; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | const STATE_CONNECT_FAILED = 2; |
||
46 | |||
47 | /** |
||
48 | * @var int |
||
49 | */ |
||
50 | const STATE_CONNECT_SUCCEEDED = 6; |
||
51 | |||
52 | /** |
||
53 | * @var int |
||
54 | */ |
||
55 | const STATE_AUTH_PENDING = 5; |
||
56 | |||
57 | /** |
||
58 | * @var int |
||
59 | */ |
||
60 | const STATE_AUTH_FAILED = 3; |
||
61 | |||
62 | /** |
||
63 | * @var int |
||
64 | */ |
||
65 | const STATE_AUTH_SUCCEEDED = 7; |
||
66 | |||
67 | /** |
||
68 | * @var int |
||
69 | */ |
||
70 | const STATE_DISCONNECT_PENDING = 8; |
||
71 | |||
72 | /** |
||
73 | * @var int |
||
74 | */ |
||
75 | const STATE_DISCONNECT_SUCCEEDED = 1; |
||
76 | |||
77 | /** |
||
78 | * @var mixed[] |
||
79 | */ |
||
80 | protected $config; |
||
81 | |||
82 | /** |
||
83 | * @var mixed[] |
||
84 | */ |
||
85 | protected $serverInfo; |
||
86 | |||
87 | /** |
||
88 | * @var int |
||
89 | */ |
||
90 | protected $state; |
||
91 | |||
92 | /** |
||
93 | * @var Queue|QueueInterface |
||
94 | */ |
||
95 | protected $queue; |
||
96 | |||
97 | protected $parser; |
||
98 | |||
99 | protected $stream; |
||
100 | |||
101 | protected $trans; |
||
102 | |||
103 | /** |
||
104 | * @param LoopInterface $loop |
||
105 | * @param mixed[] $config |
||
106 | */ |
||
107 | public function __construct(LoopInterface $loop, $config = []) |
||
118 | |||
119 | /** |
||
120 | * @override |
||
121 | * @inheritDoc |
||
122 | */ |
||
123 | public function isPaused() |
||
128 | |||
129 | /** |
||
130 | * @override |
||
131 | * @inheritDoc |
||
132 | */ |
||
133 | public function pause() |
||
137 | |||
138 | /** |
||
139 | * @override |
||
140 | * @inheritDoc |
||
141 | */ |
||
142 | public function resume() |
||
146 | |||
147 | /** |
||
148 | * @override |
||
149 | * @inheritDoc |
||
150 | */ |
||
151 | public function isStarted() |
||
155 | |||
156 | /** |
||
157 | * @override |
||
158 | * @inheritDoc |
||
159 | */ |
||
160 | public function start() |
||
205 | |||
206 | /** |
||
207 | * @override |
||
208 | * @inheritDoc |
||
209 | */ |
||
210 | public function stop() |
||
227 | |||
228 | /** |
||
229 | * @override |
||
230 | * @inheritDoc |
||
231 | */ |
||
232 | public function getState() |
||
236 | |||
237 | /** |
||
238 | * @override |
||
239 | * @inheritDoc |
||
240 | */ |
||
241 | public function getInfo() |
||
245 | |||
246 | /** |
||
247 | * @override |
||
248 | * @inheritDoc |
||
249 | */ |
||
250 | public function setDatabase($dbname) |
||
254 | |||
255 | /** |
||
256 | * @override |
||
257 | * @inheritDoc |
||
258 | */ |
||
259 | public function getDatabase() |
||
263 | |||
264 | /** |
||
265 | * @override |
||
266 | * @inheritDoc |
||
267 | */ |
||
268 | public function query($sql, $sqlParams = []) |
||
285 | |||
286 | /** |
||
287 | * @override |
||
288 | * @inheritDoc |
||
289 | */ |
||
290 | public function execute($sql, $sqlParams = []) |
||
296 | |||
297 | /** |
||
298 | * @override |
||
299 | * @inheritDoc |
||
300 | */ |
||
301 | public function ping() |
||
315 | |||
316 | /** |
||
317 | * @override |
||
318 | * @inheritDoc |
||
319 | */ |
||
320 | public function beginTransaction() |
||
324 | |||
325 | /** |
||
326 | * @override |
||
327 | * @inheritDoc |
||
328 | */ |
||
329 | public function endTransaction(TransactionInterface $trans) |
||
333 | |||
334 | /** |
||
335 | * @override |
||
336 | * @inheritDoc |
||
337 | */ |
||
338 | public function inTransaction() |
||
342 | |||
343 | /** |
||
344 | * @internal |
||
345 | */ |
||
346 | public function handleError($err) |
||
350 | |||
351 | /** |
||
352 | * @internal |
||
353 | */ |
||
354 | public function handleSocketError($socket, $err) |
||
358 | |||
359 | /** |
||
360 | * @internal |
||
361 | */ |
||
362 | public function handleSocketClose() |
||
370 | |||
371 | /** |
||
372 | * Do auth command. |
||
373 | * |
||
374 | * @param CommandInterface $command |
||
375 | * @return CommandInterface |
||
376 | * @throws ExecutionException |
||
377 | */ |
||
378 | protected function doAuth(CommandInterface $command) |
||
386 | |||
387 | /** |
||
388 | * Do command. |
||
389 | * |
||
390 | * @param CommandInterface $command |
||
391 | * @return CommandInterface |
||
392 | * @throws ExecutionException |
||
393 | */ |
||
394 | protected function doCommand(CommandInterface $command) |
||
402 | |||
403 | /** |
||
404 | * Connect to the database endpoint. |
||
405 | * |
||
406 | * @return PromiseInterface |
||
407 | */ |
||
408 | protected function connect() |
||
414 | |||
415 | /** |
||
416 | * Create Queue. |
||
417 | * |
||
418 | * @return Queue|QueueInterface |
||
419 | */ |
||
420 | protected function createQueue() |
||
424 | |||
425 | /** |
||
426 | * Create transaction box. |
||
427 | * |
||
428 | * @return TransactionBoxInterface |
||
429 | */ |
||
430 | protected function createTransactionBox() |
||
434 | |||
435 | /** |
||
436 | * Create configuration file. |
||
437 | * |
||
438 | * @param mixed[] $config |
||
439 | * @return mixed[] |
||
440 | */ |
||
441 | protected function createConfig($config = []) |
||
451 | } |
||
452 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.