Skip to content

Commit d5bb5d6

Browse files
authored
Merge pull request #468 from markwalet/php-84-deprecations
Fix | Resolve PHP 8.4 deprecation warnings
2 parents ca726dc + 86f5206 commit d5bb5d6

File tree

14 files changed

+22
-22
lines changed

14 files changed

+22
-22
lines changed

src/Exceptions/InvalidResponseClassException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class InvalidResponseClassException extends SaloonException
1111
/**
1212
* Constructor
1313
*/
14-
public function __construct(string $message = null)
14+
public function __construct(?string $message = null)
1515
{
1616
parent::__construct($message ?? sprintf('The provided response must exist and implement the %s contract.', Response::class));
1717
}

src/Exceptions/InvalidStateException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvalidStateException extends SaloonException
1010
{
11-
public function __construct(string $message = null, int $code = 0, ?Throwable $previous = null)
11+
public function __construct(?string $message = null, int $code = 0, ?Throwable $previous = null)
1212
{
1313
parent::__construct($message ?? 'Invalid state.', $code, $previous);
1414
}

src/Helpers/RequestExceptionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RequestExceptionHelper
2626
/**
2727
* Create the request exception from a response
2828
*/
29-
public static function create(Response $response, Throwable $previous = null): RequestException
29+
public static function create(Response $response, ?Throwable $previous = null): RequestException
3030
{
3131
$status = $response->status();
3232

src/Http/Faking/Fixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Fixture
3131
/**
3232
* Constructor
3333
*/
34-
public function __construct(string $name = '', Storage $storage = null)
34+
public function __construct(string $name = '', ?Storage $storage = null)
3535
{
3636
$this->name = $name;
3737
$this->storage = $storage ?? new Storage(MockConfig::getFixturePath(), true);

src/Http/Faking/MockClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function assertNothingSent(): void
300300
/**
301301
* Assert a request count has been met.
302302
*/
303-
public function assertSentCount(int $count, string $requestClass = null): void
303+
public function assertSentCount(int $count, ?string $requestClass = null): void
304304
{
305305
if (is_string($requestClass)) {
306306
$actualCount = $this->getRequestSentCount()[$requestClass] ?? 0;

src/Http/PendingRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class PendingRequest
7777
/**
7878
* Build up the request payload.
7979
*/
80-
public function __construct(Connector $connector, Request $request, MockClient $mockClient = null)
80+
public function __construct(Connector $connector, Request $request, ?MockClient $mockClient = null)
8181
{
8282
// Let's start by getting our PSR factory collection. This object contains all the
8383
// relevant factories for creating PSR-7 requests as well as URIs and streams.

src/Http/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Response
8282
/**
8383
* Create a new response instance.
8484
*/
85-
public function __construct(ResponseInterface $psrResponse, PendingRequest $pendingRequest, RequestInterface $psrRequest, Throwable $senderException = null)
85+
public function __construct(ResponseInterface $psrResponse, PendingRequest $pendingRequest, RequestInterface $psrRequest, ?Throwable $senderException = null)
8686
{
8787
$this->psrRequest = $psrRequest;
8888
$this->psrResponse = $psrResponse;

src/Http/Senders/GuzzleSender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function (TransferException $guzzleException) use ($pendingRequest, $psrRequest)
180180
/**
181181
* Create a response.
182182
*/
183-
protected function createResponse(ResponseInterface $psrResponse, PendingRequest $pendingRequest, RequestInterface $psrRequest, Exception $exception = null): Response
183+
protected function createResponse(ResponseInterface $psrResponse, PendingRequest $pendingRequest, RequestInterface $psrRequest, ?Exception $exception = null): Response
184184
{
185185
/** @var class-string<\Saloon\Http\Response> $responseClass */
186186
$responseClass = $pendingRequest->getResponseClass();

src/Repositories/Body/MultipartBodyRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MultipartBodyRepository implements BodyRepository, MergeableBody
4040
* @param array<\Saloon\Data\MultipartValue> $value
4141
* @throws \Exception
4242
*/
43-
public function __construct(array $value = [], string $boundary = null)
43+
public function __construct(array $value = [], ?string $boundary = null)
4444
{
4545
$this->data = new ArrayBodyRepository;
4646
$this->boundary = is_null($boundary) ? StringHelpers::random(40) : $boundary;
@@ -90,7 +90,7 @@ public function merge(array ...$arrays): static
9090
* @param array<string, mixed> $headers
9191
* @return $this
9292
*/
93-
public function add(string $name, mixed $contents, string $filename = null, array $headers = []): static
93+
public function add(string $name, mixed $contents, ?string $filename = null, array $headers = []): static
9494
{
9595
$this->attach(new MultipartValue($name, $contents, $filename, $headers));
9696

src/Traits/Connector/SendsRequests.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait SendsRequests
2626
*
2727
* @param callable(\Throwable, \Saloon\Http\Request): (bool)|null $handleRetry
2828
*/
29-
public function send(Request $request, MockClient $mockClient = null, callable $handleRetry = null): Response
29+
public function send(Request $request, ?MockClient $mockClient = null, ?callable $handleRetry = null): Response
3030
{
3131
if (is_null($handleRetry)) {
3232
$handleRetry = static fn (): bool => true;
@@ -126,7 +126,7 @@ public function send(Request $request, MockClient $mockClient = null, callable $
126126
/**
127127
* Send a request asynchronously
128128
*/
129-
public function sendAsync(Request $request, MockClient $mockClient = null): PromiseInterface
129+
public function sendAsync(Request $request, ?MockClient $mockClient = null): PromiseInterface
130130
{
131131
$sender = $this->sender();
132132

@@ -163,7 +163,7 @@ public function sendAsync(Request $request, MockClient $mockClient = null): Prom
163163
*
164164
* @param callable(\Throwable, \Saloon\Http\Request): (bool)|null $handleRetry
165165
*/
166-
public function sendAndRetry(Request $request, int $tries, int $interval = 0, callable $handleRetry = null, bool $throw = true, MockClient $mockClient = null, bool $useExponentialBackoff = false): Response
166+
public function sendAndRetry(Request $request, int $tries, int $interval = 0, ?callable $handleRetry = null, bool $throw = true, ?MockClient $mockClient = null, bool $useExponentialBackoff = false): Response
167167
{
168168
$request->tries = $tries;
169169
$request->retryInterval = $interval;
@@ -176,7 +176,7 @@ public function sendAndRetry(Request $request, int $tries, int $interval = 0, ca
176176
/**
177177
* Create a new PendingRequest
178178
*/
179-
public function createPendingRequest(Request $request, MockClient $mockClient = null): PendingRequest
179+
public function createPendingRequest(Request $request, ?MockClient $mockClient = null): PendingRequest
180180
{
181181
return new PendingRequest($this, $request, $mockClient);
182182
}

0 commit comments

Comments
 (0)