1 | <?php |
||
14 | class GuzzleClient implements ClientInterface, LoggerAwareInterface |
||
15 | { |
||
16 | use LoggerAwareTrait; |
||
17 | |||
18 | /** |
||
19 | * @var GuzzleClientInterface |
||
20 | */ |
||
21 | protected $guzzle; |
||
22 | |||
23 | /** |
||
24 | * @var string[] |
||
25 | */ |
||
26 | protected $effectiveUrls = []; |
||
27 | |||
28 | /** |
||
29 | * @param GuzzleClientInterface $guzzle |
||
30 | */ |
||
31 | 2 | public function __construct(GuzzleClientInterface $guzzle) |
|
35 | |||
36 | /** |
||
37 | * @inheritdoc |
||
38 | */ |
||
39 | 2 | public function fetch($uri, $userAgent = null) |
|
40 | { |
||
41 | 2 | $this->setEffectiveUri($uri, $uri); |
|
42 | |||
43 | try { |
||
44 | 2 | $response = $this->guzzle->request('GET', $uri, $this->getRequestOptions($userAgent)); |
|
45 | |||
46 | 2 | return $this->transformResponse($uri, $response); |
|
47 | } catch (RequestException $e) { |
||
48 | $this->logger->error( |
||
49 | sprintf('Error crawling: %s', $e->getMessage()), |
||
50 | ['url' => (string) $e->getRequest()->getUri()] |
||
51 | ); |
||
52 | |||
53 | if ($response = $e->getResponse()) { |
||
54 | return $this->transformResponse($uri, $response); |
||
55 | } |
||
56 | |||
57 | throw new CrawlException($uri, sprintf('Error crawling url: %s', $e->getMessage()), $e->getCode(), $e); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param string $uri |
||
63 | * @param string $effectiveUri |
||
64 | */ |
||
65 | 2 | public function setEffectiveUri($uri, $effectiveUri) |
|
69 | |||
70 | /** |
||
71 | * @param string $userAgent |
||
72 | * |
||
73 | * @return array |
||
74 | */ |
||
75 | protected function getRequestOptions($userAgent = null) |
||
89 | |||
90 | /** |
||
91 | * @param string $uri |
||
92 | * @param ResponseInterface $response |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | 2 | protected function transformResponse($uri, ResponseInterface $response) |
|
103 | } |
||
104 |
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: