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 |
||
| 17 | class CreatePdfPreviewCommand extends ContainerAwareCommand |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var EntityManager |
||
| 21 | */ |
||
| 22 | private $em; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var PdfTransformer |
||
| 26 | */ |
||
| 27 | private $pdfTransformer; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | private $rootDir; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var bool |
||
| 36 | */ |
||
| 37 | private $enablePdfPreview; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param EntityManagerInterface|null $em |
||
| 41 | * @param PdfTransformer|null $mediaManager |
||
|
|
|||
| 42 | */ |
||
| 43 | View Code Duplication | public function __construct(/* EntityManagerInterface */ $em = null, /* PdfTransformer */ $pdfTransformer = null, $rootDir = null, $enablePdfPreview = null) |
|
| 60 | |||
| 61 | protected function configure() |
||
| 72 | |||
| 73 | public function execute(InputInterface $input, OutputInterface $output) |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Checks whether the command is enabled or not in the current environment. |
||
| 108 | * |
||
| 109 | * Override this to check for x or y and return false if the command can not |
||
| 110 | * run properly under the current conditions. |
||
| 111 | * |
||
| 112 | * @return bool |
||
| 113 | */ |
||
| 114 | public function isEnabled() |
||
| 122 | } |
||
| 123 |
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.