@@ -217,22 +217,22 @@ class Client
217
217
/**
218
218
* Initialize the client.
219
219
*
220
- * @param string $host the base url (e.g. https://api.sendgrid.com)
221
- * @param array $headers global request headers
222
- * @param string $version api version (configurable) - this is specific to the SendGrid API
223
- * @param array $path holds the segments of the url path
224
- * @param array $curlOptions extra options to set during curl initialization
225
- * @param bool $retryOnLimit set default retry on limit flag
226
- * @param bool $verifySSLCerts set default verify certificates flag
220
+ * @param string $host the base url (e.g. https://api.sendgrid.com)
221
+ * @param array|null $headers global request headers
222
+ * @param string|null $version api version (configurable) - this is specific to the SendGrid API
223
+ * @param array|null $path holds the segments of the url path
224
+ * @param array|null $curlOptions extra options to set during curl initialization
225
+ * @param bool $retryOnLimit set default retry on limit flag
226
+ * @param bool $verifySSLCerts set default verify certificates flag
227
227
*/
228
228
public function __construct (
229
229
$ host ,
230
- $ headers = null ,
231
- $ version = null ,
232
- $ path = null ,
233
- $ curlOptions = null ,
234
- $ retryOnLimit = false ,
235
- $ verifySSLCerts = true
230
+ ? array $ headers = null ,
231
+ ? string $ version = null ,
232
+ ? array $ path = null ,
233
+ ? array $ curlOptions = null ,
234
+ bool $ retryOnLimit = false ,
235
+ bool $ verifySSLCerts = true
236
236
) {
237
237
$ this ->host = $ host ;
238
238
$ this ->headers = $ headers ?: [];
@@ -263,7 +263,7 @@ public function getHost()
263
263
public function setHost (string $ host )
264
264
{
265
265
$ this ->host = $ host ;
266
-
266
+
267
267
return $ this ;
268
268
}
269
269
@@ -358,13 +358,13 @@ public function setIsConcurrentRequest($isConcurrent)
358
358
/**
359
359
* Build the final URL to be passed.
360
360
*
361
- * @param array $queryParams an array of all the query parameters
361
+ * @param array|null $queryParams an array of all the query parameters
362
362
*
363
363
* Nested arrays will resolve to multiple instances of the same parameter
364
364
*
365
365
* @return string
366
366
*/
367
- private function buildUrl ($ queryParams = null )
367
+ private function buildUrl (? array $ queryParams = null )
368
368
{
369
369
$ path = '/ ' . implode ('/ ' , $ this ->path );
370
370
if (isset ($ queryParams )) {
@@ -380,12 +380,12 @@ private function buildUrl($queryParams = null)
380
380
* this function does not mutate any private variables.
381
381
*
382
382
* @param string $method
383
- * @param array $body
384
- * @param array $headers
383
+ * @param array|null $body
384
+ * @param array|null $headers
385
385
*
386
386
* @return array
387
387
*/
388
- private function createCurlOptions ($ method , $ body = null , $ headers = null )
388
+ private function createCurlOptions ($ method , ? array $ body = null , ? array $ headers = null )
389
389
{
390
390
$ options = [
391
391
CURLOPT_RETURNTRANSFER => true ,
@@ -498,17 +498,17 @@ private function retryRequest(array $responseHeaders, $method, $url, $body, $hea
498
498
* Make the API call and return the response.
499
499
* This is separated into it's own function, so we can mock it easily for testing.
500
500
*
501
- * @param string $method the HTTP verb
502
- * @param string $url the final url to call
503
- * @param array $body request body
504
- * @param array $headers any additional request headers
505
- * @param bool $retryOnLimit should retry if rate limit is reach?
501
+ * @param string $method the HTTP verb
502
+ * @param string $url the final url to call
503
+ * @param array|null $body request body
504
+ * @param array|null $headers any additional request headers
505
+ * @param bool $retryOnLimit should retry if rate limit is reach?
506
506
*
507
507
* @return Response object
508
508
*
509
509
* @throws InvalidRequest
510
510
*/
511
- public function makeRequest ($ method , $ url , $ body = null , $ headers = null , $ retryOnLimit = false )
511
+ public function makeRequest ($ method , $ url , ? array $ body = null , ? array $ headers = null , $ retryOnLimit = false )
512
512
{
513
513
$ channel = curl_init ($ url );
514
514
@@ -604,7 +604,7 @@ public function makeAllRequests(array $requests = [])
604
604
*
605
605
* @return Client object
606
606
*/
607
- public function _ ($ name = null )
607
+ public function _ (? string $ name = null )
608
608
{
609
609
if (isset ($ name )) {
610
610
$ this ->path [] = $ name ;
0 commit comments