1 | <?php |
||
12 | class Http |
||
13 | { |
||
14 | const HTTP_DELETE = 'DELETE'; |
||
15 | const HTTP_GET = 'GET'; |
||
16 | const HTTP_POST = 'POST'; |
||
17 | const HTTP_PUT = 'PUT'; |
||
18 | |||
19 | /** |
||
20 | * Multipart resources to include in next request. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $multipartResources = []; |
||
25 | |||
26 | /** |
||
27 | * Http client |
||
28 | * |
||
29 | * @var ClientInterface |
||
30 | */ |
||
31 | protected $httpClient; |
||
32 | |||
33 | /** |
||
34 | * Http request factory |
||
35 | * |
||
36 | * @var RequestFactoryInterface |
||
37 | */ |
||
38 | protected $httpRequestFactory; |
||
39 | |||
40 | /** |
||
41 | * Http stream factory |
||
42 | * |
||
43 | * @var StreamFactoryInterface |
||
44 | */ |
||
45 | protected $httpStreamFactory; |
||
46 | |||
47 | /** |
||
48 | * Creates a new http broker. |
||
49 | */ |
||
50 | public function __construct() |
||
54 | |||
55 | /** |
||
56 | * Adds authentication credentials to given request. |
||
57 | * |
||
58 | * @param RequestInterface $request |
||
59 | * |
||
60 | * @return RequestInterface |
||
61 | */ |
||
62 | protected function authenticateRequest(RequestInterface $request) |
||
74 | |||
75 | /** |
||
76 | * Creates a request. |
||
77 | * |
||
78 | * @param string $verb |
||
79 | * @param string $path |
||
80 | * @param array $parameters |
||
81 | * |
||
82 | * @return RequestInterface |
||
83 | */ |
||
84 | protected function createRequest($verb, $path, $parameters = []) |
||
111 | |||
112 | /** |
||
113 | * Retrieves http response for a request with the delete method. |
||
114 | * |
||
115 | * @param string $path |
||
116 | * @param array $parameters |
||
117 | * |
||
118 | * @return object |
||
119 | */ |
||
120 | public function delete($path, $parameters = []) |
||
126 | |||
127 | /** |
||
128 | * Retrieves http response for a request with the get method. |
||
129 | * |
||
130 | * @param string $path |
||
131 | * @param array $parameters |
||
132 | * |
||
133 | * @return object |
||
134 | */ |
||
135 | public function get($path, $parameters = []) |
||
141 | |||
142 | /** |
||
143 | * Creates and returns a request. |
||
144 | * |
||
145 | * @param string $method |
||
146 | * @param string $path |
||
147 | * @param array $parameters |
||
148 | * |
||
149 | * @return RequestInterface |
||
150 | */ |
||
151 | public function getRequest($method, $path, $parameters = [], $authenticated = true) |
||
161 | |||
162 | /** |
||
163 | * Retrieves default headers. |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | protected function getHeaders() |
||
171 | |||
172 | /** |
||
173 | * Creates an array of request options based on the current status of the |
||
174 | * http client. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | protected function getRequestOptions() |
||
190 | |||
191 | /** |
||
192 | * Creates fully qualified domain from given path. |
||
193 | * |
||
194 | * @param string $path |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getUrlFromPath($path = '/') |
||
202 | |||
203 | /** |
||
204 | * Retrieves http response for a request with the post method. |
||
205 | * |
||
206 | * @param string $path |
||
207 | * @param array $parameters |
||
208 | * |
||
209 | * @return object |
||
210 | */ |
||
211 | public function post($path, $parameters) |
||
217 | |||
218 | /** |
||
219 | * Retrieves http response for a request with the put method. |
||
220 | * |
||
221 | * @param string $path |
||
222 | * @param array $parameters |
||
223 | * |
||
224 | * @return object |
||
225 | */ |
||
226 | public function put($path, $parameters) |
||
232 | |||
233 | /** |
||
234 | * Retrieves http response for a request with the put method, |
||
235 | * ensuring parameters are passed as body. |
||
236 | * |
||
237 | * @param string $path |
||
238 | * @param array $parameters |
||
239 | * |
||
240 | * @return object |
||
241 | */ |
||
242 | public function putAsBody($path, $parameters) |
||
250 | |||
251 | /** |
||
252 | * Adds a given resource to multipart stream collection, to be processed by next request. |
||
253 | * |
||
254 | * @param string $name |
||
255 | * @param Psr\Http\Message\StreamInterface $resource |
||
256 | * |
||
257 | * @return void |
||
258 | */ |
||
259 | protected function queueResourceAs($name, $resource) |
||
266 | |||
267 | /** |
||
268 | * Retrieves http response for a given request. |
||
269 | * |
||
270 | * @param RequestInterface $request |
||
271 | * |
||
272 | * @return object |
||
273 | * @throws Exceptions\Exception |
||
274 | */ |
||
275 | protected function sendRequest(RequestInterface $request) |
||
288 | |||
289 | /** |
||
290 | * Updates the http client. |
||
291 | * |
||
292 | * @param ClientInterface $httpClient |
||
293 | * |
||
294 | * @return Http |
||
295 | */ |
||
296 | public function setClient(ClientInterface $httpClient) |
||
302 | |||
303 | /** |
||
304 | * Updates the http request factory. |
||
305 | * |
||
306 | * @param RequestFactoryInterface $httpRequestFactory |
||
307 | * |
||
308 | * @return Http |
||
309 | */ |
||
310 | public function setRequestFactory(RequestFactoryInterface $httpRequestFactory) |
||
316 | |||
317 | /** |
||
318 | * Updates the http stream factory. |
||
319 | * |
||
320 | * @param StreamFactoryInterface $httpStreamFactory |
||
321 | * |
||
322 | * @return Http |
||
323 | */ |
||
324 | public function setStreamFactory(StreamFactoryInterface $httpStreamFactory) |
||
330 | } |
||
331 |
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: