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 |
||
13 | trait AliasesLoaderTrait |
||
14 | { |
||
15 | |||
16 | |||
17 | /** |
||
18 | * @param array $aliases |
||
|
|||
19 | */ |
||
20 | View Code Duplication | public function loadShipInternalAliases() |
|
29 | |||
30 | /** |
||
31 | * loadContainersInternalAliases |
||
32 | */ |
||
33 | View Code Duplication | public function loadContainersInternalAliases() |
|
42 | |||
43 | /** |
||
44 | * @param $aliasKey |
||
45 | * @param $aliasValue |
||
46 | */ |
||
47 | private function loadAlias($aliasKey, $aliasValue) |
||
51 | } |
||
52 |
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
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.