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 |
||
10 | class Oci8Connection extends AbstractOci8Base implements Oci8ConnectionInterface |
||
11 | { |
||
12 | /** |
||
13 | * Connection constructor. |
||
14 | * @param $username |
||
15 | * @param $password |
||
16 | * @param null $connectionString |
||
17 | * @param null $characterSet |
||
18 | * @param null $sessionMode |
||
19 | * @throws \Jpina\Oci8\Oci8Exception |
||
20 | */ |
||
21 | 8 | public function __construct( |
|
30 | |||
31 | 3 | View Code Duplication | public function changePassword($username, $oldPassword, $newPassword) |
38 | |||
39 | 2 | View Code Duplication | public function close() |
54 | |||
55 | 2 | public function commit() |
|
62 | |||
63 | /** |
||
64 | * Connect to the Oracle server using a unique connection |
||
65 | * |
||
66 | * @param string $username |
||
67 | * @param string $password |
||
68 | * @param string $connectionString |
||
69 | * @param string $characterSet |
||
70 | * @param int $sessionMode |
||
71 | * @return resource |
||
72 | * @throws \Jpina\Oci8\Oci8Exception |
||
73 | * @see http://php.net/manual/en/function.oci-new-connect.php |
||
74 | */ |
||
75 | 4 | protected function connect( |
|
87 | |||
88 | 1 | public function copyLob($lobTo, $lobFrom, $length = 0) |
|
95 | |||
96 | 2 | public function freeDescriptor($descriptor) |
|
103 | |||
104 | 1 | public function getClientMayorVersion() |
|
109 | |||
110 | 2 | public function getClientVersion() |
|
114 | |||
115 | 2 | View Code Duplication | public function getNewCollection($tdo, $schema = null) |
122 | |||
123 | 2 | public function getNewCursor() |
|
130 | |||
131 | 3 | public function getNewDescriptor($type = OCI_DTYPE_LOB) |
|
138 | |||
139 | 2 | public function getServerMayorVersion() |
|
144 | |||
145 | 4 | public function getServerVersion() |
|
152 | |||
153 | 3 | public function isLobEqual($lob1, $lob2) |
|
160 | |||
161 | 52 | public function parse($sqlText) |
|
168 | |||
169 | 2 | public function setAction($actionName) |
|
176 | |||
177 | 2 | public function setClientIdentifier($clientIdentifier) |
|
184 | |||
185 | 2 | public function setClientInfo($clientInfo) |
|
192 | |||
193 | 2 | public static function setEdition($edition) |
|
194 | { |
||
195 | 2 | set_error_handler(static::getErrorHandler()); |
|
196 | 2 | $isSuccess = oci_set_edition($edition); |
|
197 | 2 | restore_error_handler(); |
|
198 | 2 | return $isSuccess; |
|
199 | } |
||
200 | |||
201 | 1 | public function setInternalDebug($onOff) |
|
205 | |||
206 | 2 | public function setModuleName($moduleName) |
|
213 | |||
214 | 2 | public function rollback() |
|
221 | } |
||
222 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.