diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 148cc9d..3ea1b25 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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' @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index aad4ec9..317e8a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/composer.json b/composer.json index a1b26b8..f108438 100644 --- a/composer.json +++ b/composer.json @@ -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", + "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": { diff --git a/phpunit.xml b/phpunit.xml index e411109..f6e52ca 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -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"> test/unit diff --git a/src/FestivalsApiClient.php b/src/FestivalsApiClient.php index 652f043..6b79668 100644 --- a/src/FestivalsApiClient.php +++ b/src/FestivalsApiClient.php @@ -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); + 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); if (isset($decoded['error'])) { $msg = $decoded['error']; } - } catch (InvalidArgumentException $e) { + } catch (JsonException) { } diff --git a/test/unit/FestivalsApiClientTest.php b/test/unit/FestivalsApiClientTest.php index 9d2765a..0e37543 100644 --- a/test/unit/FestivalsApiClientTest.php +++ b/test/unit/FestivalsApiClientTest.php @@ -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, "[]"));