1 | <?php |
||
11 | abstract class AbstractApi implements ApiInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var \Http\Client\HttpClient |
||
15 | */ |
||
16 | private $httpClient; |
||
17 | |||
18 | /** |
||
19 | * @var RequestBuilderInterface |
||
20 | */ |
||
21 | private $requestBuilder; |
||
22 | |||
23 | /** |
||
24 | * @param \Http\Client\HttpClient $httpClient HTTP client to send requests. |
||
25 | * @param \IBM\Watson\Common\RequestBuilderInterface $requestBuilder Request builder to create requests. |
||
26 | */ |
||
27 | public function __construct( |
||
34 | |||
35 | /** |
||
36 | * Create and send GET request. |
||
37 | * |
||
38 | * @param string|UriInterface $uri API URI. |
||
39 | * @param array $params Query parameters. |
||
40 | * @param array $headers Query headers. |
||
41 | * |
||
42 | * @return \Psr\Http\Message\ResponseInterface |
||
43 | * |
||
44 | * @throws \Http\Client\Exception |
||
45 | */ |
||
46 | protected function get($uri, array $params = [], array $headers = []) |
||
52 | |||
53 | /** |
||
54 | * Create and send HEAD request. |
||
55 | * |
||
56 | * @param string|UriInterface $uri API URI. |
||
57 | * @param array $headers Query headers. |
||
58 | * |
||
59 | * @return \Psr\Http\Message\ResponseInterface |
||
60 | * @throws \Http\Client\Exception |
||
61 | */ |
||
62 | protected function head($uri, array $headers = []) |
||
68 | |||
69 | /** |
||
70 | * Create and send TRACE request. |
||
71 | * |
||
72 | * @param string|UriInterface $uri API URI. |
||
73 | * @param array $headers Query headers. |
||
74 | * |
||
75 | * @return \Psr\Http\Message\ResponseInterface |
||
76 | * @throws \Http\Client\Exception |
||
77 | */ |
||
78 | protected function trace($uri, array $headers = []) |
||
84 | |||
85 | /** |
||
86 | * Create and send POST request. |
||
87 | * |
||
88 | * @param string|UriInterface $uri API URI. |
||
89 | * @param array $params Query parameters. |
||
90 | * @param array $headers Query headers. |
||
91 | * |
||
92 | * @return \Psr\Http\Message\ResponseInterface |
||
93 | * |
||
94 | * @throws \Http\Client\Exception |
||
95 | */ |
||
96 | protected function post($uri, array $params = [], array $headers = []) |
||
100 | |||
101 | /** |
||
102 | * Create and send POST request. |
||
103 | * |
||
104 | * @param string|UriInterface $uri API URI. |
||
105 | * @param resource|string|StreamInterface|null $body Request body. |
||
106 | * @param array $headers Query headers. |
||
107 | * |
||
108 | * @return \Psr\Http\Message\ResponseInterface |
||
109 | * |
||
110 | * @throws \Http\Client\Exception |
||
111 | */ |
||
112 | protected function postRaw($uri, $body, array $headers = []) |
||
118 | |||
119 | /** |
||
120 | * Create and send PUT request. |
||
121 | * |
||
122 | * @param string|UriInterface $uri API URI. |
||
123 | * @param array $params Query parameters. |
||
124 | * @param array $headers Query headers. |
||
125 | * |
||
126 | * @return \Psr\Http\Message\ResponseInterface |
||
127 | * |
||
128 | * @throws \Http\Client\Exception |
||
129 | */ |
||
130 | protected function put($uri, array $params = [], array $headers = []) |
||
136 | |||
137 | /** |
||
138 | * Create and send PATCH request. |
||
139 | * |
||
140 | * @param string|UriInterface $uri API URI. |
||
141 | * @param resource|string|StreamInterface|null $body Request body. |
||
142 | * @param array $headers Query headers. |
||
143 | * |
||
144 | * @return \Psr\Http\Message\ResponseInterface |
||
145 | * @throws \Http\Client\Exception |
||
146 | */ |
||
147 | protected function patch($uri, $body, array $headers = []) |
||
153 | |||
154 | /** |
||
155 | * Create and send DELETE request. |
||
156 | * |
||
157 | * @param string|UriInterface $uri API URI. |
||
158 | * @param array $params Query parameters. |
||
159 | * @param array $headers Query headers. |
||
160 | * |
||
161 | * @return \Psr\Http\Message\ResponseInterface |
||
162 | * @throws \Http\Client\Exception |
||
163 | */ |
||
164 | protected function delete($uri, array $params = [], array $headers = []) |
||
170 | |||
171 | /** |
||
172 | * Create and send OPTIONS request. |
||
173 | * |
||
174 | * @param string|UriInterface $uri API URI. |
||
175 | * @param array $params Query parameters. |
||
176 | * @param array $headers Query headers. |
||
177 | * |
||
178 | * @return \Psr\Http\Message\ResponseInterface |
||
179 | * @throws \Http\Client\Exception |
||
180 | */ |
||
181 | protected function options($uri, array $params = [], array $headers = []) |
||
187 | } |
||
188 |
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: