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 |
||
| 9 | final class Update implements QueryInterface |
||
| 10 | { |
||
| 11 | use Traits\Common; |
||
| 12 | use Traits\HasRelatedWith; |
||
| 13 | |||
| 14 | private $allowedMethods = [ |
||
| 15 | 'set', |
||
| 16 | 'setFlag', |
||
| 17 | 'where', |
||
| 18 | 'orWhere', |
||
| 19 | 'catWhere', |
||
| 20 | 'orderBy', |
||
| 21 | 'limit', |
||
| 22 | 'offset', |
||
| 23 | ]; |
||
| 24 | |||
| 25 | View Code Duplication | public function __construct(Table $table, array $data = []) |
|
| 43 | } |
||
| 44 |
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: