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 |
||
| 10 | class GuzzleHttpAdater implements HttpInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Client |
||
| 14 | */ |
||
| 15 | protected $client; |
||
| 16 | |||
| 17 | public function __construct($baseUrl) |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $uri |
||
| 24 | * @param array $params |
||
| 25 | * @param null $headers |
||
| 26 | * @return array|null |
||
| 27 | */ |
||
| 28 | public function get($uri, $params = [], $headers = null) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $uri |
||
| 45 | * @param array $params |
||
| 46 | * @param null $headers |
||
| 47 | * @return array|null |
||
| 48 | */ |
||
| 49 | View Code Duplication | public function post($uri, $params = [], $headers = null) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * @param string $uri |
||
| 62 | * @param null $headers |
||
| 63 | * @return array|null |
||
| 64 | */ |
||
| 65 | View Code Duplication | public function delete($uri, $headers = null) |
|
| 75 | |||
| 76 | /** |
||
| 77 | * @param Response $response |
||
| 78 | * @return array|null |
||
| 79 | */ |
||
| 80 | private function parseResponse(Response $response) |
||
| 84 | |||
| 85 | } |
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: