Skip to content

Commit f89579d

Browse files
committed
Make exception params nullable and update test
Allow nullable types for several exception constructors and update a test helper signature. Changes: - NotFoundException: make $message nullable (?string) and allow nullable $previous. - RemoteAuthentication: make $message nullable (?string). - UpstreamException: import Throwable and make $previous nullable (?Throwable). - MocksGuzzleInstance: allow $count to be nullable (?int) in assertTapperRequestLike. These changes prevent strict type errors when null values are passed and align signatures across exceptions and tests.
1 parent 8e3313b commit f89579d

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

app/Exceptions/NotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class NotFoundException extends HttpException
1717
* It is highly suggested that you customize the message with the name of the resource that isn't found.
1818
* @param string $message
1919
*/
20-
public function __construct(string $message = null, ?Throwable $previous = null)
20+
public function __construct(?string $message = null, ?Throwable $previous = null)
2121
{
2222
parent::__construct(Response::HTTP_NOT_FOUND, $message ?: 'Not found', $previous);
2323
}

app/Exceptions/RemoteAuthentication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RemoteAuthentication extends HttpException
1515
* Optional message is a good way to elaborate what, if anything, you can do to troubleshoot this. (e.g., change value X in integration Y)
1616
* @param string $message
1717
*/
18-
public function __construct(string $message = null)
18+
public function __construct(?string $message = null)
1919
{
2020
parent::__construct(
2121
Response::HTTP_UNAUTHORIZED,

app/Exceptions/UpstreamException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Symfony\Component\HttpFoundation\Response;
1313
use Symfony\Component\HttpKernel\Exception\HttpException;
14+
use Throwable;
1415

1516
class UpstreamException extends HttpException
1617
{
@@ -21,7 +22,7 @@ class UpstreamException extends HttpException
2122
* @param array $headers
2223
* @param int|null $code
2324
*/
24-
public function __construct(string $message, \Throwable $previous = null, array $headers = [], ?int $code = 0)
25+
public function __construct(string $message, ?Throwable $previous = null, array $headers = [], ?int $code = 0)
2526
{
2627
parent::__construct(Response::HTTP_BAD_GATEWAY, $message, $previous, $headers, $code);
2728
}

app/Testing/MocksGuzzleInstance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function expectTotalRequestCount(int $expectedRequestCount): void
8484
self::assertSame($expectedRequestCount, $this->tapper->getCountAll());
8585
}
8686

87-
protected function assertTapperRequestLike(string $method, string $urlPattern, int $count = null): void
87+
protected function assertTapperRequestLike(string $method, string $urlPattern, ?int $count = null): void
8888
{
8989
if (is_int($count)) {
9090
self::assertSame(

0 commit comments

Comments
 (0)