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 |
||
| 19 | class Key extends HttpApi |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Create a new key. |
||
| 23 | * |
||
| 24 | * @param string $projectKey |
||
| 25 | * @param string $localeId |
||
|
|
|||
| 26 | * @param array $params |
||
| 27 | * |
||
| 28 | * @return mixed|ResponseInterface |
||
| 29 | */ |
||
| 30 | View Code Duplication | public function create(string $projectKey, string $name, array $params = []) |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Search keys. |
||
| 49 | * |
||
| 50 | * @param string $projectKey |
||
| 51 | * @param string $localeId |
||
| 52 | * @param array $params |
||
| 53 | * |
||
| 54 | * @return mixed|ResponseInterface |
||
| 55 | */ |
||
| 56 | public function search(string $projectKey, string $localeId, array $params = []) |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Delete a key. |
||
| 95 | * |
||
| 96 | * @param string $projectKey |
||
| 97 | * @param string $keyId |
||
| 98 | * |
||
| 99 | * @return bool|ResponseInterface |
||
| 100 | */ |
||
| 101 | public function delete(string $projectKey, string $keyId) |
||
| 111 | } |
||
| 112 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.