Repository navigation
[Guzzle] Allow Guzzle 8, drop Guzzle 6 - #143
Conversation
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.
| $this->response = $previous->getResponse(); | ||
| $this->request = $previous->getRequest(); | ||
| } | ||
| if ($previous instanceof BadResponseException) { |
There was a problem hiding this comment.
same here: getResponse() returns null for a TooManyRedirectsException, where Guzzle 7 used to give us the last response
| return $response; | ||
| } | ||
|
|
||
| return $response; |
There was a problem hiding this comment.
unrelated, php-cs-fixer insisted on this one in the pre-commit hook
| message: '#^Parameter \#3 \$options of method GuzzleHttp\\ClientInterface::request\(\) expects array\{#' | ||
| identifier: argument.type | ||
| path: src/RestClient.php | ||
| reportUnmatched: false |
There was a problem hiding this comment.
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
| - [BREAKING] Drop support for Guzzle < 7.5 | ||
| - Allow Guzzle 8 | ||
|
|
||
| ## 3.0.0 |
There was a problem hiding this comment.
the 3.0.0 entries were still under Unreleased, I moved them under their own heading
| \Closure|null &$initializer = null, | ||
| array $properties = [], | ||
| ?\Closure &$initializer = null, | ||
| array &$properties = [], |
There was a problem hiding this comment.
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
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; |
There was a problem hiding this comment.
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
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.1points atmapado/rest-client-sdk v3.0.0.The only thing in Guzzle 8 that actually breaks us is
RequestException::getResponse(): it now lives onResponseException, which does not exist in Guzzle 7, so the SDK reads the response fromBadResponseException, 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.10at least), hence the 4.0.0 bump. The CI also runs aguzzle7scenario now, so both majors stay covered.Most of the noise comes from the
.scenarios.lockfiles: composer-test-scenarios regenerates them entirely on everycomposer 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$propertiesarray 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.