2
2
3
3
namespace Bigcommerce \Api ;
4
4
5
+ use CurlHandle ;
6
+
5
7
/**
6
8
* HTTP connection.
7
9
*/
@@ -21,17 +23,17 @@ class Connection
21
23
const MEDIA_TYPE_WWW = 'application/x-www-form-urlencoded ' ;
22
24
23
25
/**
24
- * @var resource cURL resource
26
+ * @var CurlHandle cURL resource
25
27
*/
26
28
private $ curl ;
27
29
28
30
/**
29
- * @var array Hash of HTTP request headers.
31
+ * @var array<string, string> Hash of HTTP request headers.
30
32
*/
31
33
private $ headers = [];
32
34
33
35
/**
34
- * @var array Hash of headers from HTTP response
36
+ * @var array<string, string> Hash of headers from HTTP response
35
37
*/
36
38
private $ responseHeaders = [];
37
39
@@ -78,11 +80,13 @@ class Connection
78
80
79
81
/**
80
82
* Determines whether the response body should be returned as a raw string.
83
+ * @var bool
81
84
*/
82
85
private $ rawResponse = false ;
83
86
84
87
/**
85
88
* Determines the default content type to use with requests and responses.
89
+ * @var string
86
90
*/
87
91
private $ contentType ;
88
92
@@ -134,6 +138,7 @@ public function useXml($option = true)
134
138
* as urlencoded form data.
135
139
*
136
140
* @param bool $option the new state of this feature
141
+ * @return void
137
142
*/
138
143
public function useUrlEncoded ($ option = true )
139
144
{
@@ -156,6 +161,7 @@ public function useUrlEncoded($option = true)
156
161
* as this fails fast, making the HTTP body and headers inaccessible.</em></p>
157
162
*
158
163
* @param bool $option the new state of this feature
164
+ * @return void
159
165
*/
160
166
public function failOnError ($ option = true )
161
167
{
@@ -167,6 +173,7 @@ public function failOnError($option = true)
167
173
*
168
174
* @param string $username
169
175
* @param string $password
176
+ * @return void
170
177
*/
171
178
public function authenticateBasic ($ username , $ password )
172
179
{
@@ -178,6 +185,7 @@ public function authenticateBasic($username, $password)
178
185
*
179
186
* @param string $clientId
180
187
* @param string $authToken
188
+ * @return void
181
189
*/
182
190
public function authenticateOauth ($ clientId , $ authToken )
183
191
{
@@ -190,6 +198,7 @@ public function authenticateOauth($clientId, $authToken)
190
198
* request takes longer than this to respond.
191
199
*
192
200
* @param int $timeout number of seconds to wait on a response
201
+ * @return void
193
202
*/
194
203
public function setTimeout ($ timeout )
195
204
{
@@ -202,6 +211,7 @@ public function setTimeout($timeout)
202
211
*
203
212
* @param string $server
204
213
* @param int|bool $port optional port number
214
+ * @return void
205
215
*/
206
216
public function useProxy ($ server , $ port = false )
207
217
{
@@ -214,7 +224,8 @@ public function useProxy($server, $port = false)
214
224
215
225
/**
216
226
* @todo may need to handle CURLOPT_SSL_VERIFYHOST and CURLOPT_CAINFO as well
217
- * @param boolean
227
+ * @param bool $option Whether to verify the peer's SSL certificate
228
+ * @return void
218
229
*/
219
230
public function verifyPeer ($ option = false )
220
231
{
@@ -226,6 +237,7 @@ public function verifyPeer($option = false)
226
237
*
227
238
* @param string $header
228
239
* @param string $value
240
+ * @return void
229
241
*/
230
242
public function addHeader ($ header , $ value )
231
243
{
@@ -236,6 +248,7 @@ public function addHeader($header, $value)
236
248
* Remove a header from the request.
237
249
*
238
250
* @param string $header
251
+ * @return void
239
252
*/
240
253
public function removeHeader ($ header )
241
254
{
@@ -245,7 +258,7 @@ public function removeHeader($header)
245
258
/**
246
259
* Return the request headers
247
260
*
248
- * @return array
261
+ * @return array<string, string>
249
262
*/
250
263
public function getRequestHeaders ()
251
264
{
@@ -256,6 +269,7 @@ public function getRequestHeaders()
256
269
* Get the MIME type that should be used for this request.
257
270
*
258
271
* Defaults to application/json
272
+ * @return string
259
273
*/
260
274
private function getContentType ()
261
275
{
@@ -265,6 +279,7 @@ private function getContentType()
265
279
/**
266
280
* Clear previously cached request data and prepare for
267
281
* making a fresh request.
282
+ * @return void
268
283
*/
269
284
private function initializeRequest ()
270
285
{
@@ -324,6 +339,7 @@ private function handleResponse()
324
339
/**
325
340
* Return an representation of an error returned by the last request, or false
326
341
* if the last request was not an error.
342
+ * @return false|string
327
343
*/
328
344
public function getLastError ()
329
345
{
@@ -336,6 +352,7 @@ public function getLastError()
336
352
*
337
353
* Only 301 and 302 redirects are handled. Redirects from POST and PUT requests will
338
354
* be converted into GET requests, as per the HTTP spec.
355
+ * @return void
339
356
*/
340
357
private function followRedirectPath ()
341
358
{
@@ -367,7 +384,7 @@ private function followRedirectPath()
367
384
* Make an HTTP GET request to the specified endpoint.
368
385
*
369
386
* @param string $url URL to retrieve
370
- * @param array|bool $query Optional array of query string parameters
387
+ * @param array<string, string> |bool $query Optional array of query string parameters
371
388
*
372
389
* @return mixed
373
390
*/
@@ -498,7 +515,7 @@ public function delete($url)
498
515
/**
499
516
* Method that appears unused, but is in fact called by curl
500
517
*
501
- * @param resource $curl
518
+ * @param CurlHandle $curl
502
519
* @param string $body
503
520
* @return int
504
521
*/
@@ -511,7 +528,7 @@ private function parseBody($curl, $body)
511
528
/**
512
529
* Method that appears unused, but is in fact called by curl
513
530
*
514
- * @param resource $curl
531
+ * @param CurlHandle $curl
515
532
* @param string $headers
516
533
* @return int
517
534
*/
@@ -580,6 +597,7 @@ public function getHeader($header)
580
597
581
598
/**
582
599
* Return the full list of response headers
600
+ * @return array<string, string>
583
601
*/
584
602
public function getHeaders ()
585
603
{
0 commit comments