1 | <?php declare(strict_types=1); |
||
23 | final class ConnectionManager { |
||
24 | |||
25 | /** |
||
26 | * Map of named database connections |
||
27 | * @var array |
||
28 | */ |
||
29 | private $connections = []; |
||
30 | |||
31 | /** |
||
32 | * Class instance variable |
||
33 | * @var ConnectionManager|null |
||
34 | */ |
||
35 | private static $instance; |
||
36 | |||
37 | /** |
||
38 | * Private constructor to prevent multiple instances |
||
39 | * @codeCoverageIgnore |
||
40 | */ |
||
41 | private function __construct() |
||
44 | |||
45 | /** |
||
46 | * Private clone method to prevent cloning |
||
47 | * |
||
48 | * @throws DomainException |
||
49 | * @return void |
||
50 | */ |
||
51 | public function __clone() |
||
55 | |||
56 | /** |
||
57 | * Prevent serialization of this object |
||
58 | * |
||
59 | * @throws DomainException |
||
60 | * @return void |
||
61 | */ |
||
62 | public function __sleep() |
||
66 | |||
67 | /** |
||
68 | * Make sure serialize/deserialize doesn't work |
||
69 | * |
||
70 | * @throws DomainException |
||
71 | * @return void |
||
72 | */ |
||
73 | public function __wakeup() |
||
77 | |||
78 | /** |
||
79 | * Return a connection manager instance |
||
80 | * |
||
81 | * @staticvar null $instance |
||
82 | * @return ConnectionManager |
||
83 | */ |
||
84 | public static function getInstance(): ConnectionManager |
||
93 | |||
94 | /** |
||
95 | * Returns the connection specified by the name given |
||
96 | * |
||
97 | * @param string|array|object $name |
||
98 | * @return QueryBuilderInterface |
||
99 | * @throws Exception\NonExistentConnectionException |
||
100 | */ |
||
101 | public function getConnection($name = ''): QueryBuilderInterface |
||
116 | |||
117 | /** |
||
118 | * Parse the passed parameters and return a connection |
||
119 | * |
||
120 | * @param object|array $params |
||
121 | * @throws Exception\BadDBDriverException |
||
122 | * @return QueryBuilderInterface |
||
123 | */ |
||
124 | public function connect($params): QueryBuilderInterface |
||
158 | |||
159 | /** |
||
160 | * Parses params into a dsn and option array |
||
161 | * |
||
162 | * @param \stdClass $params |
||
163 | * @return object|array |
||
164 | * @throws Exception\BadDBDriverException |
||
165 | */ |
||
166 | public function parseParams($params): array |
||
200 | |||
201 | /** |
||
202 | * Create the dsn from the db type and params |
||
203 | * |
||
204 | * @codeCoverageIgnore |
||
205 | * @param string $dbtype |
||
206 | * @param array|object $params |
||
207 | * @return string |
||
208 | */ |
||
209 | private function createDsn(string $dbtype, $params): string |
||
239 | } |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.