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 |
||
| 14 | class ModuleVersion implements ModuleInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var Module |
||
| 18 | */ |
||
| 19 | private $module; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var ModuleResource |
||
| 23 | */ |
||
| 24 | private $resource; |
||
| 25 | |||
| 26 | public function __construct(Module $module, ModuleResourceInterface $resource) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | public function getName() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | public function getVersion() |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | View Code Duplication | public function getDataVersion() |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | View Code Duplication | public function getDbVersion() |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param string $version |
||
| 76 | */ |
||
| 77 | public function setDataVersion($version) |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param string $version |
||
| 84 | */ |
||
| 85 | public function setDbVersion($version) |
||
| 89 | } |
||
| 90 |
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..