1 | <?php |
||
20 | final class PluginClient implements HttpClient, HttpAsyncClient |
||
21 | { |
||
22 | /** |
||
23 | * An HTTP async client. |
||
24 | * |
||
25 | * @var HttpAsyncClient |
||
26 | */ |
||
27 | private $client; |
||
28 | |||
29 | /** |
||
30 | * The plugin chain. |
||
31 | * |
||
32 | * @var Plugin[] |
||
33 | */ |
||
34 | private $plugins; |
||
35 | |||
36 | /** |
||
37 | * A list of options. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | private $options; |
||
42 | |||
43 | /** |
||
44 | * @param HttpClient|HttpAsyncClient $client |
||
45 | * @param Plugin[] $plugins |
||
46 | * @param array $options |
||
47 | * |
||
48 | * @throws \RuntimeException if client is not an instance of HttpClient or HttpAsyncClient |
||
49 | */ |
||
50 | 10 | public function __construct($client, array $plugins = [], array $options = []) |
|
63 | |||
64 | /** |
||
65 | * Adds a plugin to the client. |
||
66 | * |
||
67 | * @param Plugin $plugin |
||
68 | */ |
||
69 | 1 | public function addPlugin(Plugin $plugin) |
|
73 | |||
74 | /** |
||
75 | * Get all active plugins. |
||
76 | * |
||
77 | * @return Plugin[] |
||
78 | */ |
||
79 | 2 | public function getPlugins() |
|
83 | |||
84 | /** |
||
85 | * Assign plugins to the client. |
||
86 | * |
||
87 | * @param Plugin[] $plugins |
||
88 | */ |
||
89 | 1 | public function setPlugins(array $plugins = []) |
|
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 4 | public function sendRequest(RequestInterface $request) |
|
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | 2 | public function sendAsyncRequest(RequestInterface $request) |
|
128 | |||
129 | /** |
||
130 | * Configure the plugin client. |
||
131 | * |
||
132 | * @param array $options |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 10 | private function configure(array $options = []) |
|
145 | |||
146 | /** |
||
147 | * Create the plugin chain. |
||
148 | * |
||
149 | * @param Plugin[] $pluginList A list of plugins |
||
150 | * @param callable $clientCallable Callable making the HTTP call |
||
151 | * |
||
152 | * @return callable |
||
153 | */ |
||
154 | 5 | private function createPluginChain($pluginList, callable $clientCallable) |
|
179 | } |
||
180 |
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: