Repository navigation
Support PHP 8.5 and PHP 8.6 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.0.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,11 @@ | |
| use GuzzleHttp\Exception\BadResponseException; | ||
| use GuzzleHttp\Exception\GuzzleException; | ||
| use GuzzleHttp\Psr7\Request; | ||
| use GuzzleHttp\Utils; | ||
| use InvalidArgumentException; | ||
| use JsonException; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use function http_build_query; | ||
| use function json_decode; | ||
| use const JSON_THROW_ON_ERROR; | ||
|
|
||
| class FestivalsApiClient | ||
| { | ||
|
|
@@ -124,8 +125,13 @@ protected function createRequest(string $url): Request | |
| protected function decodeJsonResponse(ResponseInterface $response): array | ||
| { | ||
| try { | ||
| return Utils::jsonDecode((string) $response->getBody(), TRUE); | ||
| } catch (InvalidArgumentException $e) { | ||
| $data = json_decode((string) $response->getBody(), TRUE, 512, JSON_THROW_ON_ERROR); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest not specifying the depth: param as it's the default, and just specifying
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I thought the same, I'll do that |
||
| if (!is_array($data)) { | ||
| throw new JsonException('Decoded JSON is not an array'); | ||
| } | ||
|
|
||
| return $data; | ||
| } catch (JsonException $e) { | ||
| throw FestivalsApiClientException::invalidJsonResponse($response->getStatusCode(), $e); | ||
| } | ||
| } | ||
|
|
@@ -156,16 +162,16 @@ protected function getSignedUrl(string $url): string | |
| */ | ||
| protected function handleApiError(BadResponseException $e): void | ||
| { | ||
| $msg = $e->getResponse()->getBody(); | ||
| $msg = (string) $e->getResponse()->getBody(); | ||
| $code = $e->getResponse()->getStatusCode(); | ||
| $url = (string) $e->getRequest()->getUri(); | ||
|
|
||
| try { | ||
| $decoded = Utils::jsonDecode($e->getResponse()->getBody(), TRUE); | ||
| $decoded = json_decode((string) $e->getResponse()->getBody(), TRUE, 512, JSON_THROW_ON_ERROR); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment on json_decode args here |
||
| if (isset($decoded['error'])) { | ||
| $msg = $decoded['error']; | ||
| } | ||
| } catch (InvalidArgumentException $e) { | ||
| } catch (JsonException) { | ||
|
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI looks like the
lowestjob is still installing 8.3 - I think possibly because of the dev dependency onguzzlehttp/promises >= 3.1.0?If we're still going to advertise support for 7.x I think we need a CI job that proves that.
I think loosening the promises dependency should be enough to allow the
--prefer-lowestto install 7.x.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh ok, I'll need to take a closer look, I think we just drop support for guzzle 7. Loosening the promises dependency then fails on 8.6 lowest because of the
Isclass name issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might just need to check the ecosystem - there may be other packages we/people use that are tied to guzzle 8.
If the issue is the 8.6 lowest build, I'd maybe look at the CI matrix/composer install step so that the 8.6 lowest build runs
composer update --with=guzzlehttp/promises:^3or whatever min constraint forces that to an 8.6 compatible version.