1 | <?php |
||
26 | trait HasHttpRequests |
||
27 | { |
||
28 | /** |
||
29 | * @var \GuzzleHttp\Client |
||
30 | */ |
||
31 | protected $httpClient; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $middlewares = []; |
||
37 | |||
38 | /** |
||
39 | * @var \GuzzleHttp\HandlerStack |
||
40 | */ |
||
41 | protected $handlerStack; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected static $defaults = [ |
||
47 | 'curl' => [ |
||
48 | CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, |
||
49 | ], |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * Set guzzle default settings. |
||
54 | * |
||
55 | * @param array $defaults |
||
56 | */ |
||
57 | public static function setDefaultOptions($defaults = []) |
||
61 | |||
62 | /** |
||
63 | * Return current guzzle default settings. |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | public static function getDefaultOptions(): array |
||
71 | |||
72 | /** |
||
73 | * Set GuzzleHttp\Client. |
||
74 | * |
||
75 | * @param \GuzzleHttp\ClientInterface $httpClient |
||
76 | * |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function setHttpClient(ClientInterface $httpClient) |
||
85 | |||
86 | /** |
||
87 | * Return GuzzleHttp\Client instance. |
||
88 | * |
||
89 | * @return \GuzzleHttp\Client |
||
90 | */ |
||
91 | public function getHttpClient(): Client |
||
99 | |||
100 | /** |
||
101 | * Add a middleware. |
||
102 | * |
||
103 | * @param callable $middleware |
||
104 | * @param null|string $name |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function pushMiddleware(callable $middleware, string $name = null) |
||
118 | |||
119 | /** |
||
120 | * Return all middlewares. |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | public function getMiddlewares(): array |
||
128 | |||
129 | /** |
||
130 | * Make a request. |
||
131 | * |
||
132 | * @param string $url |
||
133 | * @param string $method |
||
134 | * @param array $options |
||
135 | * |
||
136 | * @return \Psr\Http\Message\ResponseInterface |
||
137 | */ |
||
138 | public function request($url, $method = 'GET', $options = []): ResponseInterface |
||
155 | |||
156 | /** |
||
157 | * @param \GuzzleHttp\HandlerStack $handlerStack |
||
158 | * |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function setHandlerStack(HandlerStack $handlerStack) |
||
167 | |||
168 | /** |
||
169 | * Build a handler stack. |
||
170 | * |
||
171 | * @return \GuzzleHttp\HandlerStack |
||
172 | */ |
||
173 | public function getHandlerStack(): HandlerStack |
||
187 | |||
188 | /** |
||
189 | * @param \Psr\Http\Message\ResponseInterface $response |
||
190 | * @param string $type |
||
191 | * |
||
192 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|string |
||
193 | */ |
||
194 | protected function resolveResponse(ResponseInterface $response, string $type) |
||
215 | |||
216 | /** |
||
217 | * @param mixed $response |
||
218 | * @param string $type |
||
219 | * |
||
220 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|string |
||
221 | */ |
||
222 | protected function transformResponseToType($response, string $type) |
||
232 | |||
233 | /** |
||
234 | * @param array $options |
||
235 | * |
||
236 | * @return array |
||
237 | */ |
||
238 | protected function fixJsonIssue(array $options): array |
||
248 | } |
||
249 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.