Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 30 | class MysqliConnection implements Connection, PingableConnection, ServerInfoAwareConnection |
||
| 31 | { |
||
| 32 | /** |
||
| 33 | * Name of the option to set connection flags |
||
| 34 | */ |
||
| 35 | const OPTION_FLAGS = 'flags'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var \mysqli |
||
| 39 | */ |
||
| 40 | private $_conn; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param array $params |
||
| 44 | * @param string $username |
||
| 45 | * @param string $password |
||
| 46 | * @param array $driverOptions |
||
| 47 | * |
||
| 48 | * @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException |
||
| 49 | */ |
||
| 50 | 1 | public function __construct(array $params, $username, $password, array $driverOptions = []) |
|
| 82 | |||
| 83 | /** |
||
| 84 | * Retrieves mysqli native resource handle. |
||
| 85 | * |
||
| 86 | * Could be used if part of your application is not using DBAL. |
||
| 87 | * |
||
| 88 | * @return \mysqli |
||
| 89 | */ |
||
| 90 | public function getWrappedResourceHandle() |
||
| 94 | |||
| 95 | /** |
||
| 96 | * {@inheritdoc} |
||
| 97 | */ |
||
| 98 | public function getServerVersion() |
||
| 106 | |||
| 107 | /** |
||
| 108 | * {@inheritdoc} |
||
| 109 | */ |
||
| 110 | 1 | public function requiresQueryForServerVersion() |
|
| 114 | |||
| 115 | /** |
||
| 116 | * {@inheritdoc} |
||
| 117 | */ |
||
| 118 | public function prepare($prepareString) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * {@inheritdoc} |
||
| 125 | */ |
||
| 126 | View Code Duplication | public function query() |
|
| 135 | |||
| 136 | /** |
||
| 137 | * {@inheritdoc} |
||
| 138 | */ |
||
| 139 | public function quote($input, $type=\PDO::PARAM_STR) |
||
| 143 | |||
| 144 | /** |
||
| 145 | * {@inheritdoc} |
||
| 146 | */ |
||
| 147 | public function exec($statement) |
||
| 155 | |||
| 156 | /** |
||
| 157 | * {@inheritdoc} |
||
| 158 | */ |
||
| 159 | public function lastInsertId($name = null) |
||
| 163 | |||
| 164 | /** |
||
| 165 | * {@inheritdoc} |
||
| 166 | */ |
||
| 167 | public function beginTransaction() |
||
| 173 | |||
| 174 | /** |
||
| 175 | * {@inheritdoc} |
||
| 176 | */ |
||
| 177 | public function commit() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * {@inheritdoc}non-PHPdoc) |
||
| 184 | */ |
||
| 185 | public function rollBack() |
||
| 189 | |||
| 190 | /** |
||
| 191 | * {@inheritdoc} |
||
| 192 | */ |
||
| 193 | public function errorCode() |
||
| 197 | |||
| 198 | /** |
||
| 199 | * {@inheritdoc} |
||
| 200 | */ |
||
| 201 | public function errorInfo() |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Apply the driver options to the connection. |
||
| 208 | * |
||
| 209 | * @param array $driverOptions |
||
| 210 | * |
||
| 211 | * @throws MysqliException When one of of the options is not supported. |
||
| 212 | * @throws MysqliException When applying doesn't work - e.g. due to incorrect value. |
||
| 213 | */ |
||
| 214 | 1 | private function setDriverOptions(array $driverOptions = []) |
|
| 256 | |||
| 257 | /** |
||
| 258 | * Pings the server and re-connects when `mysqli.reconnect = 1` |
||
| 259 | * |
||
| 260 | * @return bool |
||
| 261 | */ |
||
| 262 | public function ping() |
||
| 266 | |||
| 267 | /** |
||
| 268 | * Establish a secure connection |
||
| 269 | * |
||
| 270 | * @param array $params |
||
| 271 | * @throws MysqliException |
||
| 272 | */ |
||
| 273 | 1 | private function setSecureConnection(array $params) |
|
| 292 | } |
||
| 293 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..