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 GenerateConfigCommand extends KunstmaanGenerateCommand |
||
12 | { |
||
13 | /** @var bool */ |
||
14 | private $overwriteSecurity; |
||
15 | |||
16 | /** @var bool */ |
||
17 | private $overwriteLiipImagine; |
||
18 | |||
19 | /** |
||
20 | * @param string $rootDir |
||
|
|||
21 | */ |
||
22 | public function __construct(string $projectDir) |
||
28 | |||
29 | /** |
||
30 | * @see Command |
||
31 | */ |
||
32 | protected function configure() |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | protected function getWelcomeText() |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | protected function doExecute() |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | protected function doInteract() |
||
77 | |||
78 | /** |
||
79 | * @return ConfigGenerator |
||
80 | */ |
||
81 | View Code Duplication | protected function createGenerator() |
|
88 | } |
||
89 |
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.