From bd7dc5b9d712761bc511081341b1ba02c2ba4a55 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Mon, 7 Apr 2025 16:32:00 +0530 Subject: [PATCH 1/2] chore: fix php 8.4 deprecation warning --- lib/Client.php | 24 ++++++++++++------------ test/unit/MockClient.php | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Client.php b/lib/Client.php index b6bcd4a..268eec4 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -226,13 +226,13 @@ class Client * @param bool $verifySSLCerts set default verify certificates flag */ public function __construct( - $host, - $headers = null, - $version = null, - $path = null, - $curlOptions = null, - $retryOnLimit = false, - $verifySSLCerts = true + string $host, + ?array $headers = null, + ?string $version = null, + ?array $path = null, + ?array $curlOptions = null, + bool $retryOnLimit = false, + bool $verifySSLCerts = true ) { $this->host = $host; $this->headers = $headers ?: []; @@ -263,7 +263,7 @@ public function getHost() public function setHost(string $host) { $this->host = $host; - + return $this; } @@ -364,7 +364,7 @@ public function setIsConcurrentRequest($isConcurrent) * * @return string */ - private function buildUrl($queryParams = null) + private function buildUrl(?array $queryParams = null) { $path = '/' . implode('/', $this->path); if (isset($queryParams)) { @@ -385,7 +385,7 @@ private function buildUrl($queryParams = null) * * @return array */ - private function createCurlOptions($method, $body = null, $headers = null) + private function createCurlOptions($method, ?array $body = null, ?array $headers = null) { $options = [ CURLOPT_RETURNTRANSFER => true, @@ -508,7 +508,7 @@ private function retryRequest(array $responseHeaders, $method, $url, $body, $hea * * @throws InvalidRequest */ - public function makeRequest($method, $url, $body = null, $headers = null, $retryOnLimit = false) + public function makeRequest($method, $url, ?array $body = null, ?array $headers = null, $retryOnLimit = false) { $channel = curl_init($url); @@ -604,7 +604,7 @@ public function makeAllRequests(array $requests = []) * * @return Client object */ - public function _($name = null) + public function _(?string $name = null) { if (isset($name)) { $this->path[] = $name; diff --git a/test/unit/MockClient.php b/test/unit/MockClient.php index b1c897a..4b45433 100644 --- a/test/unit/MockClient.php +++ b/test/unit/MockClient.php @@ -10,7 +10,7 @@ class MockClient extends Client public $requestHeaders; public $url; - public function makeRequest($method, $url, $requestBody = null, $requestHeaders = null, $retryOnLimit = false) + public function makeRequest($method, $url, ?array $requestBody = null, ?array $requestHeaders = null, $retryOnLimit = false) { $this->requestBody = $requestBody; $this->requestHeaders = $requestHeaders; From 36e5542c9bcd5a4de71f453403bd46b32a09e6b8 Mon Sep 17 00:00:00 2001 From: Manisha Singh Date: Mon, 7 Apr 2025 16:35:13 +0530 Subject: [PATCH 2/2] chore: capitalize docstring parameter descriptions --- lib/Client.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Client.php b/lib/Client.php index 268eec4..375d059 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -217,13 +217,13 @@ class Client /** * Initialize the client. * - * @param string $host the base url (e.g. https://api.sendgrid.com) - * @param array $headers global request headers - * @param string $version api version (configurable) - this is specific to the SendGrid API - * @param array $path holds the segments of the url path - * @param array $curlOptions extra options to set during curl initialization - * @param bool $retryOnLimit set default retry on limit flag - * @param bool $verifySSLCerts set default verify certificates flag + * @param string $host The base url (e.g. https://api.sendgrid.com) + * @param array $headers Global request headers + * @param string $version Api version (configurable) - this is specific to the SendGrid API + * @param array $path Holds the segments of the url path + * @param array $curlOptions Extra options to set during curl initialization + * @param bool $retryOnLimit Set default retry on limit flag + * @param bool $verifySSLCerts Set default verify certificates flag */ public function __construct( string $host,