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 namespace Comodojo\Extender\Tasks; |
||
| 30 | abstract class AbstractTask implements TaskInterface { |
||
| 31 | |||
| 32 | use DataAccessTrait; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Task constructor. |
||
| 36 | * |
||
| 37 | * @param array $parameters Array of parameters (if any) |
||
| 38 | * @param \Monolog\Logger $logger |
||
| 39 | * @param int $pid Task PID (if any) |
||
|
|
|||
| 40 | * @param string $name Task Name |
||
| 41 | * @param int $timestamp Start timestamp (if null will be retrieved directly) |
||
| 42 | * @param bool $multithread Multithread switch |
||
| 43 | * |
||
| 44 | * @return Object $this |
||
| 45 | */ |
||
| 46 | final public function __construct( |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The run method; SHOULD be implemented by each task |
||
| 62 | */ |
||
| 63 | abstract public function run(); |
||
| 64 | |||
| 65 | } |
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.