Conditions | 3 |
Paths | 3 |
Total Lines | 31 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
38 | public function handle(GuzzleClient $client, RequestInterface $request) |
||
39 | { |
||
40 | try { |
||
41 | $response = $client->send( |
||
42 | new HttpRequest( |
||
43 | $request->getMethod(), |
||
44 | $request->getUri(), |
||
45 | $request->getHeaders(), |
||
46 | \GuzzleHttp\json_encode($request->getBody()) |
||
|
|||
47 | ) |
||
48 | ); |
||
49 | } catch (\Exception $e) { |
||
50 | $this->logger->debug( |
||
51 | sprintf('Exception thrown during Guzzle request'), |
||
52 | [ |
||
53 | 'message' => $e->getMessage(), |
||
54 | 'line' => $e->getLine(), |
||
55 | 'file' => $e->getFile(), |
||
56 | 'trace' => $e->getTraceAsString() |
||
57 | ] |
||
58 | ); |
||
59 | |||
60 | $response = new Response(500); |
||
61 | |||
62 | if ($e instanceof ClientException) { |
||
63 | $response = new Response(401); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | return $request->getResponseFactory()->create($response); |
||
68 | } |
||
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: