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 |
||
11 | class LeaderboardOutfitEndpointController extends AbstractLeaderboardEndpointController |
||
12 | { |
||
13 | protected $repository; |
||
14 | |||
15 | /** |
||
16 | * Construct |
||
17 | * |
||
18 | * @param League\Fractal\Manager $fractal |
||
|
|||
19 | */ |
||
20 | public function __construct( |
||
25 | |||
26 | /** |
||
27 | * Get Outfit Leaderboard |
||
28 | * |
||
29 | * @return ResponseInterface |
||
30 | */ |
||
31 | public function outfits() |
||
80 | |||
81 | /** |
||
82 | * Gets the appropiate field for the table and handles some table naming oddities |
||
83 | * @param string $input Field to look at |
||
84 | * @return string |
||
85 | */ |
||
86 | View Code Duplication | public function getField($input) { |
|
108 | } |
||
109 |
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.