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 |
||
| 7 | class Checkbox extends MultipleSelect |
||
| 8 | { |
||
| 9 | protected $inline = true; |
||
| 10 | |||
| 11 | protected $canCheckAll = false; |
||
| 12 | |||
| 13 | protected $groups = null; |
||
| 14 | |||
| 15 | protected static $css = [ |
||
| 16 | '/vendor/laravel-admin/AdminLTE/plugins/iCheck/all.css', |
||
| 17 | ]; |
||
| 18 | |||
| 19 | protected static $js = [ |
||
| 20 | '/vendor/laravel-admin/AdminLTE/plugins/iCheck/icheck.min.js', |
||
| 21 | ]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $cascadeEvent = 'ifChanged'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set options. |
||
| 30 | * |
||
| 31 | * @param array|callable|string $options |
||
| 32 | * |
||
| 33 | * @return $this|mixed |
||
| 34 | */ |
||
| 35 | public function options($options = []) |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Add a checkbox above this component, so you can select all checkboxes by click on it. |
||
| 52 | * |
||
| 53 | * @return $this |
||
| 54 | */ |
||
| 55 | public function canCheckAll() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Set chekbox groups. |
||
| 64 | * |
||
| 65 | * @param array |
||
| 66 | * |
||
| 67 | * @return $this |
||
| 68 | */ |
||
| 69 | public function groups($groups = []) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Set checked. |
||
| 78 | * |
||
| 79 | * @param array|callable|string $checked |
||
| 80 | * |
||
| 81 | * @return $this |
||
| 82 | */ |
||
| 83 | View Code Duplication | public function checked($checked = []) |
|
| 93 | |||
| 94 | /** |
||
| 95 | * Draw inline checkboxes. |
||
| 96 | * |
||
| 97 | * @return $this |
||
| 98 | */ |
||
| 99 | public function inline() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Draw stacked checkboxes. |
||
| 108 | * |
||
| 109 | * @return $this |
||
| 110 | */ |
||
| 111 | public function stacked() |
||
| 117 | |||
| 118 | /** |
||
| 119 | * {@inheritdoc} |
||
| 120 | */ |
||
| 121 | public function render() |
||
| 149 | } |
||
| 150 |
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..