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 |
||
| 21 | class AdminShuffleCommand extends AbstractAdminChatCommand |
||
| 22 | { |
||
| 23 | /** @var ChatNotification */ |
||
| 24 | private $chatNotification; |
||
| 25 | |||
| 26 | /** @var PlayerStorage */ |
||
| 27 | private $playerStorage; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var MapStorage |
||
| 31 | */ |
||
| 32 | private $mapStorage; |
||
| 33 | /** |
||
| 34 | * @var Connection |
||
| 35 | */ |
||
| 36 | private $connection; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * AdminCommand constructor. |
||
| 40 | * |
||
| 41 | * @param $command |
||
| 42 | * @param string $permission |
||
| 43 | * @param array $aliases |
||
| 44 | * @param ChatNotification $functionName |
||
|
|
|||
| 45 | * @param AdminGroups $adminGroupsHelper |
||
| 46 | * @param Connection $connection |
||
| 47 | * @param ChatNotification $chatNotification |
||
| 48 | * @param PlayerStorage $playerStorage |
||
| 49 | * @param LoggerInterface $logger |
||
| 50 | * @param Time $timeHelper |
||
| 51 | * @param MapStorage $mapStorage |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function __construct( |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @inheritdoc |
||
| 80 | */ |
||
| 81 | public function execute($login, InputInterface $input) |
||
| 116 | } |
||
| 117 |
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.