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 |
||
15 | class Request extends ZapheusRequest |
||
16 | { |
||
17 | /** |
||
18 | * Initializes the server request instance. |
||
19 | * |
||
20 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
21 | */ |
||
22 | 27 | public function __construct(ServerRequestInterface $request) |
|
44 | |||
45 | /** |
||
46 | * Returns a listing of globals. |
||
47 | * |
||
48 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
49 | * @return array |
||
50 | */ |
||
51 | 27 | protected function globals(ServerRequestInterface $request) |
|
69 | } |
||
70 |
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: