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 |
||
| 10 | class Reporter |
||
| 11 | { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var Config |
||
| 15 | */ |
||
| 16 | private $config; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var OutputInterface |
||
| 20 | */ |
||
| 21 | private $output; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Reporter constructor. |
||
| 25 | * @param Config $config |
||
| 26 | * @param OutputInterface $output |
||
| 27 | */ |
||
| 28 | public function __construct(Config $config, Output $output) |
||
| 33 | |||
| 34 | |||
| 35 | public function generate(Metrics $metrics) |
||
| 74 | } |
||
| 75 |
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..