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 EnumMapBench |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var mixed[] |
||
| 19 | */ |
||
| 20 | private $values; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var Enum66[] |
||
| 24 | */ |
||
| 25 | private $enumerators; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var EnumMap |
||
| 29 | */ |
||
| 30 | private $emptyMap; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var EnumMap |
||
| 34 | */ |
||
| 35 | private $fullMap; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Will be called before every subject |
||
| 39 | */ |
||
| 40 | public function init() |
||
| 51 | |||
| 52 | public function benchOffsetSetEnumerator() |
||
| 58 | |||
| 59 | public function benchOffsetSetValue() |
||
| 65 | |||
| 66 | public function benchOffsetUnsetEnumerator() |
||
| 72 | |||
| 73 | public function benchOffsetUnsetValue() |
||
| 79 | |||
| 80 | public function benchOffsetExistsEnumeratorTrue() |
||
| 86 | |||
| 87 | public function benchOffsetExistsEnumeratorFalse() |
||
| 93 | |||
| 94 | public function benchOffsetExistsValueTrue() |
||
| 100 | |||
| 101 | public function benchOffsetExistsValueFalse() |
||
| 107 | |||
| 108 | public function benchIterateFull() |
||
| 114 | |||
| 115 | public function benchIterateEmpty() |
||
| 121 | |||
| 122 | public function benchCountFull() |
||
| 126 | |||
| 127 | public function benchCountEmpty() |
||
| 131 | } |
||
| 132 |
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..