Skip to content

Commit 919b8e1

Browse files
chore: fix php 8.4 deprecation warning
1 parent af11728 commit 919b8e1

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

.github/workflows/test-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
timeout-minutes: 20
1818
strategy:
1919
matrix:
20-
php: [ '7.3', '7.4', '8.0', '8.1' ]
20+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
2121
dependencies:
2222
- "lowest"
2323
- "highest"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ We welcome direct contributions to the php-http-client code base. Thank you!
1818

1919
##### Prerequisites #####
2020

21-
- PHP version 7.3, 7.4, 8.0, or 8.1
21+
- PHP version 7.3+
2222
- [Composer](https://getcomposer.org/)
2323

2424
##### Initial setup: #####

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md).
2828

2929
## Prerequisites
3030

31-
- PHP version 7.3, 7.4, 8.0, or 8.1
31+
- PHP version 7.3+
3232

3333
## Install with Composer
3434

lib/Client.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,22 @@ class Client
217217
/**
218218
* Initialize the client.
219219
*
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
227227
*/
228228
public function __construct(
229229
$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
236236
) {
237237
$this->host = $host;
238238
$this->headers = $headers ?: [];
@@ -263,7 +263,7 @@ public function getHost()
263263
public function setHost(string $host)
264264
{
265265
$this->host = $host;
266-
266+
267267
return $this;
268268
}
269269

@@ -358,13 +358,13 @@ public function setIsConcurrentRequest($isConcurrent)
358358
/**
359359
* Build the final URL to be passed.
360360
*
361-
* @param array $queryParams an array of all the query parameters
361+
* @param array|null $queryParams an array of all the query parameters
362362
*
363363
* Nested arrays will resolve to multiple instances of the same parameter
364364
*
365365
* @return string
366366
*/
367-
private function buildUrl($queryParams = null)
367+
private function buildUrl(?array $queryParams = null)
368368
{
369369
$path = '/' . implode('/', $this->path);
370370
if (isset($queryParams)) {
@@ -380,12 +380,12 @@ private function buildUrl($queryParams = null)
380380
* this function does not mutate any private variables.
381381
*
382382
* @param string $method
383-
* @param array $body
384-
* @param array $headers
383+
* @param array|null $body
384+
* @param array|null $headers
385385
*
386386
* @return array
387387
*/
388-
private function createCurlOptions($method, $body = null, $headers = null)
388+
private function createCurlOptions($method, ?array $body = null, ?array $headers = null)
389389
{
390390
$options = [
391391
CURLOPT_RETURNTRANSFER => true,
@@ -498,17 +498,17 @@ private function retryRequest(array $responseHeaders, $method, $url, $body, $hea
498498
* Make the API call and return the response.
499499
* This is separated into it's own function, so we can mock it easily for testing.
500500
*
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?
506506
*
507507
* @return Response object
508508
*
509509
* @throws InvalidRequest
510510
*/
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)
512512
{
513513
$channel = curl_init($url);
514514

@@ -604,7 +604,7 @@ public function makeAllRequests(array $requests = [])
604604
*
605605
* @return Client object
606606
*/
607-
public function _($name = null)
607+
public function _(?string $name = null)
608608
{
609609
if (isset($name)) {
610610
$this->path[] = $name;

lib/Exception/InvalidRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class InvalidRequest extends \Exception
1212
public function __construct(
1313
$message = '',
1414
$code = 0,
15-
\Exception $previous = null
15+
?\Exception $previous = null
1616
) {
1717
$message = 'Could not send request to server. ' .
1818
'CURL error ' . $code . ': ' . $message;

test/unit/MockClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MockClient extends Client
1010
public $requestHeaders;
1111
public $url;
1212

13-
public function makeRequest($method, $url, $requestBody = null, $requestHeaders = null, $retryOnLimit = false)
13+
public function makeRequest($method, $url, ?array $requestBody = null, ?array $requestHeaders = null, $retryOnLimit = false)
1414
{
1515
$this->requestBody = $requestBody;
1616
$this->requestHeaders = $requestHeaders;

0 commit comments

Comments
 (0)