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 |
||
12 | class ProfileController extends LoginController |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Get details on item to load form with. |
||
17 | * |
||
18 | * @param integer $id get details on item with id. |
||
|
|||
19 | * |
||
20 | * @return object true if okey, false if something went wrong. |
||
21 | */ |
||
22 | 2 | public function getUserDetails($name) |
|
27 | |||
28 | /** |
||
29 | * Render profile page |
||
30 | * |
||
31 | * @return void |
||
32 | */ |
||
33 | 1 | public function renderProfile() |
|
57 | |||
58 | /** |
||
59 | * Description. |
||
60 | * |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | 1 | View Code Duplication | public function getPostEditUser() |
82 | |||
83 | /** |
||
84 | * Description. |
||
85 | * |
||
86 | * |
||
87 | * @return void |
||
88 | */ |
||
89 | View Code Duplication | public function getPostEditSecurity() |
|
106 | } |
||
107 |
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.