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 static $css = [ |
||
| 14 | '/vendor/laravel-admin/AdminLTE/plugins/iCheck/all.css', |
||
| 15 | ]; |
||
| 16 | |||
| 17 | protected static $js = [ |
||
| 18 | '/vendor/laravel-admin/AdminLTE/plugins/iCheck/icheck.min.js', |
||
| 19 | ]; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Set options. |
||
| 23 | * |
||
| 24 | * @param array|callable|string $options |
||
| 25 | * |
||
| 26 | * @return $this|mixed |
||
| 27 | */ |
||
| 28 | public function options($options = []) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Add a checkbox above this component, so you can select all checkboxes by click on it. |
||
| 45 | * |
||
| 46 | * @return $this |
||
| 47 | */ |
||
| 48 | public function canCheckAll() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Set checked. |
||
| 57 | * |
||
| 58 | * @param array|callable|string $checked |
||
| 59 | * |
||
| 60 | * @return $this |
||
| 61 | */ |
||
| 62 | View Code Duplication | public function checked($checked = []) |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Draw inline checkboxes. |
||
| 75 | * |
||
| 76 | * @return $this |
||
| 77 | */ |
||
| 78 | public function inline() |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Draw stacked checkboxes. |
||
| 87 | * |
||
| 88 | * @return $this |
||
| 89 | */ |
||
| 90 | public function stacked() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * {@inheritdoc} |
||
| 99 | */ |
||
| 100 | public function render() |
||
| 128 | } |
||
| 129 |
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..