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 |
||
| 27 | class ConstructorInspector extends Base |
||
| 28 | { |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @readwrite |
||
| 32 | * @var ObjectDefinition |
||
| 33 | */ |
||
| 34 | protected $definition; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @read |
||
| 38 | * @var Parameter[] |
||
| 39 | */ |
||
| 40 | protected $arguments; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @read |
||
| 44 | * @var bool |
||
| 45 | */ |
||
| 46 | protected $satisfiable = true; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param ObjectDefinition $definition |
||
| 50 | * @return $this|self|ConstructorInspector |
||
| 51 | */ |
||
| 52 | 14 | public function setDefinition(ObjectDefinition $definition) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Set definition constructor arguments |
||
| 63 | */ |
||
| 64 | 14 | protected function updateDefinition() |
|
| 84 | |||
| 85 | /** |
||
| 86 | * Gets constructor arguments |
||
| 87 | * |
||
| 88 | * @return Parameter[] |
||
| 89 | */ |
||
| 90 | 14 | protected function getArguments() |
|
| 103 | } |
||
| 104 |
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..