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 UserController |
||
| 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) |
|
| 29 | |||
| 30 | /** |
||
| 31 | * Render profile page |
||
| 32 | * |
||
| 33 | * @return void |
||
| 34 | */ |
||
| 35 | 1 | public function renderProfile() |
|
| 59 | |||
| 60 | /** |
||
| 61 | * Description. |
||
| 62 | * |
||
| 63 | * @param datatype $variable Description |
||
| 64 | * |
||
| 65 | * @throws Exception |
||
| 66 | * |
||
| 67 | * @return void |
||
| 68 | */ |
||
| 69 | 1 | View Code Duplication | public function getPostEditUser() |
| 86 | |||
| 87 | /** |
||
| 88 | * Description. |
||
| 89 | * |
||
| 90 | * @param datatype $variable Description |
||
| 91 | * |
||
| 92 | * @throws Exception |
||
| 93 | * |
||
| 94 | * @return void |
||
| 95 | */ |
||
| 96 | View Code Duplication | public function getPostEditSecurity() |
|
| 113 | } |
||
| 114 |
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.