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 |
||
| 15 | class ModuleVersion implements ModuleInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var Module |
||
| 19 | */ |
||
| 20 | private $module; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var ModuleResource |
||
| 24 | */ |
||
| 25 | private $resource; |
||
| 26 | |||
| 27 | public function __construct(Module $module, ModuleResourceInterface $resource) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * {@inheritdoc} |
||
| 35 | */ |
||
| 36 | public function getName() |
||
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | public function getVersion() |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | View Code Duplication | public function getDataVersion() |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | View Code Duplication | public function getDbVersion() |
|
| 74 | |||
| 75 | /** |
||
| 76 | * @param string $version |
||
| 77 | */ |
||
| 78 | public function setDataVersion($version) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param string $version |
||
| 85 | */ |
||
| 86 | public function setDbVersion($version) |
||
| 90 | } |
||
| 91 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..