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 |
||
| 2 | class AreasAPI extends Http\Rest\DataTableAPI |
||
| 3 | { |
||
| 4 | public function __construct() |
||
| 8 | |||
| 9 | public function setup($app) |
||
| 14 | |||
| 15 | View Code Duplication | protected function validateIsAdmin($request) |
|
| 27 | |||
| 28 | protected function canCreate($request) |
||
| 33 | |||
| 34 | protected function canUpdate($request, $entity) |
||
| 39 | |||
| 40 | public function getLeads($request, $response, $args) |
||
| 53 | } |
||
| 54 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
| 55 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: