From 802e7ef53182fd0fdfeb0b4cb618ab7e4a067549 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 22 Jul 2026 10:56:49 +0200 Subject: [PATCH 1/2] tests: Add missing response to exception With Guzzle 8, `TooManyRedirectsException` extends `ResponseException`, which expects a third `$response` parameter, making PHPStan fail with: Class GuzzleHttp\Exception\TooManyRedirectsException constructor invoked with 2 parameters, 3-4 required. This also matches what Guzzle 7 itself does: https://github.com/guzzle/guzzle/blob/7.10.0/src/RedirectMiddleware.php#L155 --- tests/PromiseExceptionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PromiseExceptionTest.php b/tests/PromiseExceptionTest.php index a80083e..6f978f9 100644 --- a/tests/PromiseExceptionTest.php +++ b/tests/PromiseExceptionTest.php @@ -45,7 +45,7 @@ public static function exceptionThatIsThrownForGuzzleExceptionProvider(): array return [ [$request, new GuzzleExceptions\ConnectException('foo', $request), NetworkException::class], - [$request, new GuzzleExceptions\TooManyRedirectsException('foo', $request), RequestException::class], + [$request, new GuzzleExceptions\TooManyRedirectsException('foo', $request, $response), RequestException::class], [$request, new GuzzleExceptions\RequestException('foo', $request, $response), HttpException::class], [$request, new GuzzleExceptions\BadResponseException('foo', $request, $response), HttpException::class], [$request, new GuzzleExceptions\ClientException('foo', $request, $response), HttpException::class], From 70abff23a4e8fe031025a7ba5e07d8e07daa2652 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 22 Jul 2026 10:49:39 +0200 Subject: [PATCH 2/2] Add support for Guzzle 8 This is a bit stricter but mostly compatible. Changes affecting us involve improved type annotations and splitting out `ResponseException`. https://github.com/guzzle/guzzle/releases/8.0.0 --- src/Promise.php | 2 +- tests/PromiseExceptionTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Promise.php b/src/Promise.php index 14a8812..49cf84a 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -109,7 +109,7 @@ private function handleException(GuzzleExceptions\GuzzleException $exception) if ($exception instanceof GuzzleExceptions\RequestException) { // Make sure we have a response for the HttpException - if ($exception->hasResponse()) { + if ($exception instanceof GuzzleExceptions\ResponseException) { return new HttplugException\HttpException( $exception->getMessage(), $exception->getRequest(), diff --git a/tests/PromiseExceptionTest.php b/tests/PromiseExceptionTest.php index 6f978f9..2285bf6 100644 --- a/tests/PromiseExceptionTest.php +++ b/tests/PromiseExceptionTest.php @@ -46,11 +46,11 @@ public static function exceptionThatIsThrownForGuzzleExceptionProvider(): array return [ [$request, new GuzzleExceptions\ConnectException('foo', $request), NetworkException::class], [$request, new GuzzleExceptions\TooManyRedirectsException('foo', $request, $response), RequestException::class], - [$request, new GuzzleExceptions\RequestException('foo', $request, $response), HttpException::class], + [$request, new GuzzleExceptions\ResponseException('foo', $request, $response), HttpException::class], [$request, new GuzzleExceptions\BadResponseException('foo', $request, $response), HttpException::class], [$request, new GuzzleExceptions\ClientException('foo', $request, $response), HttpException::class], [$request, new GuzzleExceptions\ServerException('foo', $request, $response), HttpException::class], - [$request, new GuzzleExceptions\TransferException('foo'), TransferException::class], + [$request, new GuzzleExceptions\TransferException('foo', $request), TransferException::class], // check cases without response [$request, new GuzzleExceptions\RequestException('foo', $request), RequestException::class], [$request, new GuzzleExceptions\BadResponseException('foo', $request, $response), RequestException::class],