Skip to content

[Guzzle] Allow Guzzle 8, drop Guzzle 6 - #143

Merged
nikophil merged 4 commits into
mainfrom
np--guzzle-8
Oct 30, 2026
Merged

nikophil merged 4 commits into
mainfrom
np--guzzle-8

Conversation

@nikophil

@nikophil nikophil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Guzzle 8 is out (8.3.1) and this SDK is what blocks our apps from upgrading: on oauth-server, composer why-not guzzlehttp/guzzle 8.3.1 points at mapado/rest-client-sdk v3.0.0.

The only thing in Guzzle 8 that actually breaks us is RequestException::getResponse(): it now lives on ResponseException, which does not exist in Guzzle 7, so the SDK reads the response from BadResponseException, the common subclass that carries one in both versions. Everything else we touch (ClientInterface::request(), ClientException, TransferException) is unchanged.

I took the opportunity to drop Guzzle 6: none of our projects uses it anymore (they all require ^7.10 at least), hence the 4.0.0 bump. The CI also runs a guzzle7 scenario now, so both majors stay covered.

Most of the noise comes from the .scenarios.lock files: composer-test-scenarios regenerates them entirely on every composer update, so they also move Symfony, PHPStan and friends.

The regenerated locks also move PHPStan from 2.1 to 2.3, which flags one pre-existing spot in SdkClient.php: the ghost proxy initializer took its $properties array by value where ProxyManager documents it by reference. Fixed in its own commit.

Not done here: the apps themselves, they will follow once this is released.

Guzzle 8 removes getResponse() from RequestException and keeps it on
ResponseException, which does not exist in Guzzle 7: the SDK now reads the
response from BadResponseException, present in both versions.
A guzzle7 scenario keeps Guzzle 7 covered in CI.
Comment thread src/RestClient.php Resolved
Comment thread src/Exception/RestException.php Outdated
$this->response = $previous->getResponse();
$this->request = $previous->getRequest();
}
if ($previous instanceof BadResponseException) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: getResponse() returns null for a TooManyRedirectsException, where Guzzle 7 used to give us the last response

Comment thread src/RestClient.php
return $response;
}

return $response;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated, php-cs-fixer insisted on this one in the pre-commit hook

Comment thread phpstan.neon
message: '#^Parameter \#3 \$options of method GuzzleHttp\\ClientInterface::request\(\) expects array\{#'
identifier: argument.type
path: src/RestClient.php
reportUnmatched: false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reportUnmatched: false because Guzzle 7 does not type its options at all: the error only exists with Guzzle 8, and PHPStan would otherwise complain about an unused ignore in the guzzle7 scenario

Comment thread CHANGELOG.md
- [BREAKING] Drop support for Guzzle < 7.5
- Allow Guzzle 8

## 3.0.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 3.0.0 entries were still under Unreleased, I moved them under their own heading

@nikophil
nikophil requested a review from jdeniau October 29, 2026 15:33
Comment thread src/SdkClient.php
\Closure|null &$initializer = null,
array $properties = [],
?\Closure &$initializer = null,
array &$properties = [],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPStan 2.3 (pulled in by the regenerated scenario locks) flags the write into $properties as dead when the array comes by value. It worked anyway because the array ProxyManager hands over holds references to the object's properties, but array &$properties is the signature its docs give for a ghost initializer, so I'd rather match it

@nikophil
nikophil requested a review from badaz October 29, 2026 15:48
@nikophil
nikophil marked this pull request as ready for review October 29, 2026 15:48
@nikophil
nikophil requested review from a team, JulianosDeLaMancha, LedruRomane, amaurypc-mapado, bjulien, celestialaly and lnahiro and removed request for a team October 29, 2026 16:18
Guzzle 7 exposes it on RequestException, Guzzle 8 on ResponseException:
RestException::responseOf() reads it in both versions.
return null;
}

$response = method_exists($e, 'getResponse') ? $e->getResponse() : null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method_exists() rather than instanceof ResponseException: that class only exists in Guzzle 8, and PHPStan would need an ignore in either case. This way the Guzzle 7 behaviour (any RequestException may carry a response) is kept as is, and a redirect loop test covers it in both majors

@nikophil
nikophil merged commit 3312576 into main Oct 30, 2026
4 checks passed
@nikophil
nikophil deleted the np--guzzle-8 branch October 30, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants