22
33namespace Bigcommerce \Api ;
44
5+ use CurlHandle ;
6+
57/**
68 * HTTP connection.
79 */
@@ -21,17 +23,17 @@ class Connection
2123 const MEDIA_TYPE_WWW = 'application/x-www-form-urlencoded ' ;
2224
2325 /**
24- * @var resource cURL resource
26+ * @var CurlHandle cURL resource
2527 */
2628 private $ curl ;
2729
2830 /**
29- * @var array Hash of HTTP request headers.
31+ * @var array<string, string> Hash of HTTP request headers.
3032 */
3133 private $ headers = [];
3234
3335 /**
34- * @var array Hash of headers from HTTP response
36+ * @var array<string, string> Hash of headers from HTTP response
3537 */
3638 private $ responseHeaders = [];
3739
@@ -78,11 +80,13 @@ class Connection
7880
7981 /**
8082 * Determines whether the response body should be returned as a raw string.
83+ * @var bool
8184 */
8285 private $ rawResponse = false ;
8386
8487 /**
8588 * Determines the default content type to use with requests and responses.
89+ * @var string
8690 */
8791 private $ contentType ;
8892
@@ -134,6 +138,7 @@ public function useXml($option = true)
134138 * as urlencoded form data.
135139 *
136140 * @param bool $option the new state of this feature
141+ * @return void
137142 */
138143 public function useUrlEncoded ($ option = true )
139144 {
@@ -156,6 +161,7 @@ public function useUrlEncoded($option = true)
156161 * as this fails fast, making the HTTP body and headers inaccessible.</em></p>
157162 *
158163 * @param bool $option the new state of this feature
164+ * @return void
159165 */
160166 public function failOnError ($ option = true )
161167 {
@@ -167,6 +173,7 @@ public function failOnError($option = true)
167173 *
168174 * @param string $username
169175 * @param string $password
176+ * @return void
170177 */
171178 public function authenticateBasic ($ username , $ password )
172179 {
@@ -178,6 +185,7 @@ public function authenticateBasic($username, $password)
178185 *
179186 * @param string $clientId
180187 * @param string $authToken
188+ * @return void
181189 */
182190 public function authenticateOauth ($ clientId , $ authToken )
183191 {
@@ -190,6 +198,7 @@ public function authenticateOauth($clientId, $authToken)
190198 * request takes longer than this to respond.
191199 *
192200 * @param int $timeout number of seconds to wait on a response
201+ * @return void
193202 */
194203 public function setTimeout ($ timeout )
195204 {
@@ -202,6 +211,7 @@ public function setTimeout($timeout)
202211 *
203212 * @param string $server
204213 * @param int|bool $port optional port number
214+ * @return void
205215 */
206216 public function useProxy ($ server , $ port = false )
207217 {
@@ -214,7 +224,8 @@ public function useProxy($server, $port = false)
214224
215225 /**
216226 * @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
218229 */
219230 public function verifyPeer ($ option = false )
220231 {
@@ -226,6 +237,7 @@ public function verifyPeer($option = false)
226237 *
227238 * @param string $header
228239 * @param string $value
240+ * @return void
229241 */
230242 public function addHeader ($ header , $ value )
231243 {
@@ -236,6 +248,7 @@ public function addHeader($header, $value)
236248 * Remove a header from the request.
237249 *
238250 * @param string $header
251+ * @return void
239252 */
240253 public function removeHeader ($ header )
241254 {
@@ -245,7 +258,7 @@ public function removeHeader($header)
245258 /**
246259 * Return the request headers
247260 *
248- * @return array
261+ * @return array<string, string>
249262 */
250263 public function getRequestHeaders ()
251264 {
@@ -256,6 +269,7 @@ public function getRequestHeaders()
256269 * Get the MIME type that should be used for this request.
257270 *
258271 * Defaults to application/json
272+ * @return string
259273 */
260274 private function getContentType ()
261275 {
@@ -265,6 +279,7 @@ private function getContentType()
265279 /**
266280 * Clear previously cached request data and prepare for
267281 * making a fresh request.
282+ * @return void
268283 */
269284 private function initializeRequest ()
270285 {
@@ -324,6 +339,7 @@ private function handleResponse()
324339 /**
325340 * Return an representation of an error returned by the last request, or false
326341 * if the last request was not an error.
342+ * @return false|string
327343 */
328344 public function getLastError ()
329345 {
@@ -336,6 +352,7 @@ public function getLastError()
336352 *
337353 * Only 301 and 302 redirects are handled. Redirects from POST and PUT requests will
338354 * be converted into GET requests, as per the HTTP spec.
355+ * @return void
339356 */
340357 private function followRedirectPath ()
341358 {
@@ -367,7 +384,7 @@ private function followRedirectPath()
367384 * Make an HTTP GET request to the specified endpoint.
368385 *
369386 * @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
371388 *
372389 * @return mixed
373390 */
@@ -498,7 +515,7 @@ public function delete($url)
498515 /**
499516 * Method that appears unused, but is in fact called by curl
500517 *
501- * @param resource $curl
518+ * @param CurlHandle $curl
502519 * @param string $body
503520 * @return int
504521 */
@@ -511,7 +528,7 @@ private function parseBody($curl, $body)
511528 /**
512529 * Method that appears unused, but is in fact called by curl
513530 *
514- * @param resource $curl
531+ * @param CurlHandle $curl
515532 * @param string $headers
516533 * @return int
517534 */
@@ -580,6 +597,7 @@ public function getHeader($header)
580597
581598 /**
582599 * Return the full list of response headers
600+ * @return array<string, string>
583601 */
584602 public function getHeaders ()
585603 {
0 commit comments