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 | ||
| 24 | class JqadmController extends AdminController | ||
| 25 | { | ||
| 26 | use AuthorizesRequests; | ||
| 27 | |||
| 28 | |||
| 29 | /** | ||
| 30 | * Returns the HTML code for a copy of a resource object | ||
| 31 | * | ||
| 32 | * @param string Resource location, e.g. "product" | ||
| 33 | * @param string $sitecode Unique site code | ||
|  | |||
| 34 | * @param integer $id Unique resource ID | ||
| 35 | * @return string Generated output | ||
| 36 | */ | ||
| 37 | View Code Duplication | public function copyAction( $site = 'default', $resource, $id ) | |
| 46 | |||
| 47 | |||
| 48 | /** | ||
| 49 | * Returns the HTML code for a new resource object | ||
| 50 | * | ||
| 51 | * @param string Resource location, e.g. "product" | ||
| 52 | * @param string $sitecode Unique site code | ||
| 53 | * @return string Generated output | ||
| 54 | */ | ||
| 55 | View Code Duplication | public function createAction( $site = 'default', $resource ) | |
| 64 | |||
| 65 | |||
| 66 | /** | ||
| 67 | * Deletes the resource object or a list of resource objects | ||
| 68 | * | ||
| 69 | * @param string Resource location, e.g. "product" | ||
| 70 | * @param string $sitecode Unique site code | ||
| 71 | * @param integer $id Unique resource ID | ||
| 72 | * @return string Generated output | ||
| 73 | */ | ||
| 74 | View Code Duplication | public function deleteAction( $site = 'default', $resource, $id ) | |
| 83 | |||
| 84 | |||
| 85 | /** | ||
| 86 | * Returns the HTML code for the requested resource object | ||
| 87 | * | ||
| 88 | * @param string Resource location, e.g. "product" | ||
| 89 | * @param string $sitecode Unique site code | ||
| 90 | * @param integer $id Unique resource ID | ||
| 91 | * @return string Generated output | ||
| 92 | */ | ||
| 93 | View Code Duplication | public function getAction( $site = 'default', $resource, $id ) | |
| 102 | |||
| 103 | |||
| 104 | /** | ||
| 105 | * Saves a new resource object | ||
| 106 | * | ||
| 107 | * @param string Resource location, e.g. "product" | ||
| 108 | * @param string $sitecode Unique site code | ||
| 109 | * @return string Generated output | ||
| 110 | */ | ||
| 111 | View Code Duplication | public function saveAction( $site = 'default', $resource ) | |
| 120 | |||
| 121 | |||
| 122 | /** | ||
| 123 | * Returns the HTML code for a list of resource objects | ||
| 124 | * | ||
| 125 | * @param string Resource location, e.g. "product" | ||
| 126 | * @param string $sitecode Unique site code | ||
| 127 | * @return string Generated output | ||
| 128 | */ | ||
| 129 | View Code Duplication | public function searchAction( $site = 'default', $resource ) | |
| 138 | |||
| 139 | |||
| 140 | /** | ||
| 141 | * Returns the resource controller | ||
| 142 | * | ||
| 143 | * @param string $sitecode Unique site code | ||
| 144 | * @return \Aimeos\MShop\Context\Item\Iface Context item | ||
| 145 | */ | ||
| 146 | View Code Duplication | protected function createClient( $sitecode, $resource ) | |
| 161 | |||
| 162 | |||
| 163 | /** | ||
| 164 | * Returns the generated HTML code | ||
| 165 | * | ||
| 166 | * @param string $site | ||
| 167 | * @param string $content | ||
| 168 | */ | ||
| 169 | protected function getHtml( $site, $content ) | ||
| 176 | } | ||
| 177 | 
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.