From af11728372bdd3ec1cc11d783b7bccdaa2a6a4fe Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Fri, 4 Apr 2025 12:27:20 +0530 Subject: [PATCH 1/4] chore: update licence year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 3154774..126ceb1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (C) 2023, Twilio SendGrid, Inc. +Copyright (C) 2025, Twilio SendGrid, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 919b8e127939d53a5ddb30b6cfd0f93af24f47dc Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Fri, 4 Apr 2025 12:41:33 +0530 Subject: [PATCH 2/4] chore: fix php 8.4 deprecation warning --- .github/workflows/test-and-deploy.yml | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- lib/Client.php | 52 +++++++++++++-------------- lib/Exception/InvalidRequest.php | 2 +- test/unit/MockClient.php | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 1f903e5..489b143 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - php: [ '7.3', '7.4', '8.0', '8.1' ] + php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] dependencies: - "lowest" - "highest" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b183415..4218850 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ We welcome direct contributions to the php-http-client code base. Thank you! ##### Prerequisites ##### -- PHP version 7.3, 7.4, 8.0, or 8.1 +- PHP version 7.3+ - [Composer](https://getcomposer.org/) ##### Initial setup: ##### diff --git a/README.md b/README.md index 7aea5d1..1880490 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md). ## Prerequisites -- PHP version 7.3, 7.4, 8.0, or 8.1 +- PHP version 7.3+ ## Install with Composer diff --git a/lib/Client.php b/lib/Client.php index b6bcd4a..1e72d26 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -217,22 +217,22 @@ 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|null $headers global request headers + * @param string|null $version api version (configurable) - this is specific to the SendGrid API + * @param array|null $path holds the segments of the url path + * @param array|null $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( $host, - $headers = null, - $version = null, - $path = null, - $curlOptions = null, - $retryOnLimit = false, - $verifySSLCerts = true + ?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; } @@ -358,13 +358,13 @@ public function setIsConcurrentRequest($isConcurrent) /** * Build the final URL to be passed. * - * @param array $queryParams an array of all the query parameters + * @param array|null $queryParams an array of all the query parameters * * Nested arrays will resolve to multiple instances of the same parameter * * @return string */ - private function buildUrl($queryParams = null) + private function buildUrl(?array $queryParams = null) { $path = '/' . implode('/', $this->path); if (isset($queryParams)) { @@ -380,12 +380,12 @@ private function buildUrl($queryParams = null) * this function does not mutate any private variables. * * @param string $method - * @param array $body - * @param array $headers + * @param array|null $body + * @param array|null $headers * * @return array */ - private function createCurlOptions($method, $body = null, $headers = null) + private function createCurlOptions($method, ?array $body = null, ?array $headers = null) { $options = [ CURLOPT_RETURNTRANSFER => true, @@ -498,17 +498,17 @@ private function retryRequest(array $responseHeaders, $method, $url, $body, $hea * Make the API call and return the response. * This is separated into it's own function, so we can mock it easily for testing. * - * @param string $method the HTTP verb - * @param string $url the final url to call - * @param array $body request body - * @param array $headers any additional request headers - * @param bool $retryOnLimit should retry if rate limit is reach? + * @param string $method the HTTP verb + * @param string $url the final url to call + * @param array|null $body request body + * @param array|null $headers any additional request headers + * @param bool $retryOnLimit should retry if rate limit is reach? * * @return Response object * * @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/lib/Exception/InvalidRequest.php b/lib/Exception/InvalidRequest.php index 21ae2ac..819172d 100644 --- a/lib/Exception/InvalidRequest.php +++ b/lib/Exception/InvalidRequest.php @@ -12,7 +12,7 @@ class InvalidRequest extends \Exception public function __construct( $message = '', $code = 0, - \Exception $previous = null + ?\Exception $previous = null ) { $message = 'Could not send request to server. ' . 'CURL error ' . $code . ': ' . $message; 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 4d152f3f4c6682289bfd643f66d16e644b4fc9d8 Mon Sep 17 00:00:00 2001 From: Shubham Date: Mon, 7 Apr 2025 11:55:44 +0530 Subject: [PATCH 3/4] Update lib/Client.php Co-authored-by: Manisha Singh --- lib/Client.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Client.php b/lib/Client.php index 1e72d26..71e7220 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -217,7 +217,15 @@ class Client /** * Initialize the client. * - * @param string $host the base url (e.g. https://api.sendgrid.com) + /** + * @param string $host The base URL (e.g., https://api.sendgrid.com). + * @param array|null $headers Global request headers. If provided, these headers will be included in every request. + * @param string|null $version API version (configurable). This is specific to the SendGrid API. + * @param array|null $path Holds the segments of the URL path. + * @param array|null $curlOptions Extra options to set during cURL initialization. + * @param bool $retryOnLimit Set default retry on limit flag. + * @param bool $verifySSLCerts Set default verify SSL certificates flag. + */ * @param array|null $headers global request headers * @param string|null $version api version (configurable) - this is specific to the SendGrid API * @param array|null $path holds the segments of the url path From bc4eaa0b8c3429c90e28d74e1fbf1491e07c5ba1 Mon Sep 17 00:00:00 2001 From: Shubham Date: Mon, 7 Apr 2025 11:55:51 +0530 Subject: [PATCH 4/4] Update lib/Client.php Co-authored-by: Manisha Singh --- lib/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.php b/lib/Client.php index 71e7220..9473f22 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -366,7 +366,7 @@ public function setIsConcurrentRequest($isConcurrent) /** * Build the final URL to be passed. * - * @param array|null $queryParams an array of all the query parameters + * @param array|null \$queryParams An array of all the query parameters. * * Nested arrays will resolve to multiple instances of the same parameter *