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 |
||
| 18 | class Localize |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Array of languages Gitamin can use. |
||
| 22 | * |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $langs; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Config repository. |
||
| 29 | * |
||
| 30 | * @var \Illuminate\Config\Repository |
||
| 31 | */ |
||
| 32 | protected $config; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Constructs a new localize instance. |
||
| 36 | * |
||
| 37 | * @param \Illuminate\Config\Repository $config |
||
| 38 | */ |
||
| 39 | public function __construct(Repository $config) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Handle an incoming request. |
||
| 47 | * |
||
| 48 | * @param \Illuminate\Http\Request $request |
||
| 49 | * @param \Closure $next |
||
| 50 | * |
||
| 51 | * @return mixed |
||
| 52 | */ |
||
| 53 | public function handle($request, Closure $next) |
||
| 72 | } |
||
| 73 |
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..