1 | <?php |
||
35 | class HttpDispatcher |
||
36 | { |
||
37 | /** |
||
38 | * @var HttpAsyncClient |
||
39 | */ |
||
40 | private $httpClient; |
||
41 | |||
42 | /** |
||
43 | * @var UriFactory |
||
44 | */ |
||
45 | private $uriFactory; |
||
46 | |||
47 | /** |
||
48 | * Queued requests. |
||
49 | * |
||
50 | * @var RequestInterface[] |
||
51 | */ |
||
52 | private $queue = []; |
||
53 | |||
54 | /** |
||
55 | * Caching proxy server host names or IP addresses. |
||
56 | * |
||
57 | * @var UriInterface[] |
||
58 | */ |
||
59 | private $servers; |
||
60 | |||
61 | /** |
||
62 | * Application host name and optional base URL. |
||
63 | * |
||
64 | * @var UriInterface |
||
65 | */ |
||
66 | private $baseUri; |
||
67 | |||
68 | /** |
||
69 | * @param string[] $servers Caching proxy server hostnames or IP |
||
70 | * addresses, including port if not port 80. |
||
71 | * E.g. ['127.0.0.1:6081'] |
||
72 | * @param string $baseUri Default application hostname, optionally |
||
73 | * including base URL, for purge and refresh |
||
74 | * requests (optional). This is required if |
||
75 | * you purge and refresh paths instead of |
||
76 | * absolute URLs |
||
77 | * @param HttpAsyncClient|null $httpClient Client capable of sending HTTP requests. If no |
||
78 | * client is supplied, a default one is created |
||
79 | * @param UriFactory|null $uriFactory Factory for PSR-7 URIs. If not specified, a |
||
80 | * default one is created |
||
81 | */ |
||
82 | 33 | public function __construct( |
|
94 | |||
95 | /** |
||
96 | * Queue invalidation request. |
||
97 | * |
||
98 | * @param RequestInterface $invalidationRequest |
||
99 | */ |
||
100 | 28 | public function invalidate(RequestInterface $invalidationRequest) |
|
117 | |||
118 | /** |
||
119 | * Send all pending invalidation requests and make sure the requests have terminated and gather exceptions. |
||
120 | * |
||
121 | * @return int The number of cache invalidations performed per caching server |
||
122 | * |
||
123 | * @throws ExceptionCollection If any errors occurred during flush |
||
124 | */ |
||
125 | 28 | public function flush() |
|
162 | |||
163 | /** |
||
164 | * Duplicate a request for each caching server. |
||
165 | * |
||
166 | * @param RequestInterface $request The request to duplicate for each configured server |
||
167 | * |
||
168 | * @return RequestInterface[] |
||
169 | */ |
||
170 | 27 | private function fanOut(RequestInterface $request) |
|
219 | |||
220 | /** |
||
221 | * Set caching proxy server URI objects, validating them. |
||
222 | * |
||
223 | * @param string[] $servers Caching proxy proxy server hostnames or IP |
||
224 | * addresses, including port if not port 80. |
||
225 | * E.g. ['127.0.0.1:6081'] |
||
226 | * |
||
227 | * @throws InvalidUrlException If server is invalid or contains URL |
||
228 | * parts other than scheme, host, port |
||
229 | */ |
||
230 | 33 | private function setServers(array $servers) |
|
237 | |||
238 | /** |
||
239 | * Set application base URI that will be prefixed to relative purge and |
||
240 | * refresh requests, and validate it. |
||
241 | * |
||
242 | * @param string $uriString Your application’s base URI |
||
243 | * |
||
244 | * @throws InvalidUrlException If the base URI is not a valid URI |
||
245 | */ |
||
246 | 30 | private function setBaseUri($uriString = null) |
|
256 | |||
257 | /** |
||
258 | * Filter a URL. |
||
259 | * |
||
260 | * Prefix the URL with "http://" if it has no scheme, then check the URL |
||
261 | * for validity. You can specify what parts of the URL are allowed. |
||
262 | * |
||
263 | * @param string $uriString |
||
264 | * @param string[] $allowedParts Array of allowed URL parts (optional) |
||
265 | * |
||
266 | * @return UriInterface Filtered URI (with default scheme if there was no scheme) |
||
267 | * |
||
268 | * @throws InvalidUrlException If URL is invalid, the scheme is not http or |
||
269 | * contains parts that are not expected |
||
270 | */ |
||
271 | 33 | private function filterUri($uriString, array $allowedParts = []) |
|
307 | |||
308 | /** |
||
309 | * Build a request signature based on the request data. Unique for every different request, identical |
||
310 | * for the same requests. |
||
311 | * |
||
312 | * This signature is used to avoid sending the same invalidation request twice. |
||
313 | * |
||
314 | * @param RequestInterface $request An invalidation request |
||
315 | * |
||
316 | * @return string A signature for this request |
||
317 | */ |
||
318 | 27 | private function getRequestSignature(RequestInterface $request) |
|
325 | } |
||
326 |
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: