Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
- '8.6'
dependency-versions:
- 'lowest'
- 'default'
Expand All @@ -33,10 +32,10 @@ jobs:
tools: composer:v2

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Install composer dependencies
uses: ramsey/composer-install@v3
uses: ramsey/composer-install@v4
with:
dependency-versions: ${{ matrix.dependency-versions }}

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### Unreleased

### v2.6.0 (2026-11-??)

* Support PHP 8.5 and PHP 8.6
* Drop support for < PHP 8.4

### v2.5.0 (2025-08-05)

* Add VenueSearchIterator to make querying venues endpoint easier
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
}
],
"require": {
"guzzlehttp/guzzle": "^7.9.2",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
"guzzlehttp/guzzle": "^7.9.2 || ^8.3",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CI looks like the lowest job is still installing 8.3 - I think possibly because of the dev dependency on guzzlehttp/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-lowest to install 7.x.

Copy link
Copy Markdown
Member Author

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 Is class name issue.

Copy link
Copy Markdown
Member

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:^3 or whatever min constraint forces that to an 8.6 compatible version.

"php": ">=8.4 <8.7"
},
"require-dev": {
"guzzlehttp/promises": ">=2.0.4",
"phpunit/phpunit": "^10.5.45",
"guzzlehttp/promises": ">=3.1.0",
"phpunit/phpunit": "^13.4",
"ergebnis/phpunit-slow-test-detector": "^2.19.1"
},
"support": {
Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
failOnNotice="true"
failOnWarning="true"
failOnRisky="true"
failOnPhpunitDeprecation="true"
failOnPhpunitNotice="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.4/phpunit.xsd">
<testsuites>
<testsuite name="unit">
<directory>test/unit</directory>
Expand Down
20 changes: 13 additions & 7 deletions src/FestivalsApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 flags: JSON_THROW_ON_ERROR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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);
}
}
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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) {

}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/FestivalsApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public function test_it_correctly_url_encodes_search_query(array $query, string
}

#[TestWith([[], 0])]
#[TestWith([['x-total-results' => 1021], 1021])]
#[TestWith([['x-total-results' => 0], 0])]
#[TestWith([['x-total-results' => '1021'], 1021])]
#[TestWith([['x-total-results' => '0'], 0])]
public function test_event_search_result_holds_total_result_count_from_header(array $headers, int $expected): void
{
$this->mockGuzzleWithResponse(new Response(200, $headers, "[]"));
Expand Down
Loading