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 |
||
| 16 | abstract class AbstractEnumType extends AbstractType |
||
| 17 | { |
||
| 18 | use AutoNameTrait; |
||
| 19 | /** |
||
| 20 | * ObjectType constructor. |
||
| 21 | * @param $config |
||
| 22 | */ |
||
| 23 | 9 | public function __construct($config = []) |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @return String predefined type kind |
||
| 35 | */ |
||
| 36 | 6 | public function getKind() |
|
| 40 | |||
| 41 | /** |
||
| 42 | * @param $value mixed |
||
| 43 | * |
||
| 44 | * @return bool |
||
| 45 | */ |
||
| 46 | public function isValidValue($value) |
||
| 50 | |||
| 51 | abstract public function getValues(); |
||
| 52 | |||
| 53 | public function build($config) {} |
||
| 54 | |||
| 55 | 1 | View Code Duplication | public function serialize($value) |
| 63 | |||
| 64 | 1 | View Code Duplication | public function resolve($value) |
| 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..