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 |
||
| 18 | class OverviewController implements |
||
| 19 | ConfigureInterface, |
||
| 20 | InjectionAwareInterface |
||
| 21 | { |
||
| 22 | use ConfigureTrait, |
||
| 23 | InjectionAwareTrait; |
||
| 24 | |||
| 25 | |||
| 26 | /** |
||
| 27 | * @var $data description |
||
| 28 | */ |
||
| 29 | //private $data; |
||
| 30 | |||
| 31 | |||
| 32 | /** |
||
| 33 | * Description. |
||
| 34 | * |
||
| 35 | * @param datatype $variable Description |
||
|
|
|||
| 36 | * |
||
| 37 | * @throws Exception |
||
| 38 | * |
||
| 39 | * @return void |
||
| 40 | */ |
||
| 41 | View Code Duplication | public function getIndex() |
|
| 62 | |||
| 63 | public function overview() |
||
| 87 | |||
| 88 | View Code Duplication | public function getUsers() |
|
| 96 | |||
| 97 | public function getPosts() |
||
| 105 | |||
| 106 | View Code Duplication | public function getTags($id) |
|
| 114 | |||
| 115 | public function getPopularTags() |
||
| 123 | |||
| 124 | View Code Duplication | public function getCatName($id) |
|
| 131 | } |
||
| 132 |
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.