From 1e11cbf2706e7ab08abf44b52d6651cf56d072b1 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Thu, 11 Dec 2025 14:46:42 +0100 Subject: [PATCH 1/2] chore!: drop php8.1; add php8.5 * increase required `web-token/jwt-library` to "^3.4.9|^4.0.6" * drop phpunit10; add phpunit12; show notices and deprecations * migrate php-cs-fixer config; apply auto migrations * update Github Actions --- .github/workflows/tests.yml | 8 ++++---- .php-cs-fixer.php | 6 +++--- README.md | 3 ++- composer.json | 9 ++++----- phpunit.xml.dist | 7 ++++++- src/WebPush.php | 8 +++----- tests/WebPushTest.php | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3041b9..20a58b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2', '8.3', '8.4' ] + php: [ '8.2', '8.3', '8.4', '8.5' ] ext_base: [ 'none, dom, tokenizer, xml, xmlwriter,' ] ext_lib: [ 'curl, mbstring, openssl,' ] ext_optional: [ '', 'bcmath', 'gmp' ] @@ -43,8 +43,8 @@ jobs: uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-php${{ matrix.php }}-${{ matrix.ext_optional }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-php${{ matrix.php }}-${{ matrix.ext_optional }} - name: Install dependencies run: composer install --prefer-dist @@ -52,7 +52,7 @@ jobs: - name: Setup node uses: actions/setup-node@v6 with: - node-version: '20' + node-version: '24' - name: Install web-push-testing server run: | diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index e041068..e68ada2 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -4,7 +4,7 @@ $config = new PhpCsFixer\Config(); $rules = [ '@PSR12' => true, // The default rule. - '@PHP81Migration' => true, // Must be the same as the min PHP version. + '@autoPHPMigration' => true, // Uses min PHP version for regular migrations. 'blank_line_after_opening_tag' => false, // Do not waste space between ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], 'php_unit_construct' => true, @@ -12,8 +12,8 @@ 'php_unit_method_casing' => true, 'php_unit_test_class_requires_covers' => true, // Do not enable by default. These rules require review!! (but they are useful) - // '@PHP80Migration:risky' => true, - // '@PHPUnit100Migration:risky' => true, + // '@autoPHPMigration:risky' => true, + // '@autoPHPUnitMigration:risky' => true, ]; $config->setRules($rules); diff --git a/README.md b/README.md index c849a1e..162f280 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This push message is then received by the browser, which can then create a notif ## Requirements -PHP 8.1+ and the following extensions: +PHP 8.2+ and the following extensions: - bcmath and/or gmp (optional but better for performance) - mbstring @@ -25,6 +25,7 @@ There is no support and maintenance for older PHP versions, however you are free - PHP 7.2: `v6.x` - PHP 7.3 7.4: `v7.x` - PHP 8.0 / Openssl without elliptic curve support: `v8.x` +- PHP 8.1: `v9.x` This README is only compatible with the latest version. Each version of the library has a git tag where the corresponding README can be read. diff --git a/composer.json b/composer.json index 5d85c39..9d99abb 100644 --- a/composer.json +++ b/composer.json @@ -28,23 +28,22 @@ "test:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --dry-run --stop-on-violation --using-cache=no" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", "guzzlehttp/guzzle": "^7.9.2", "spomky-labs/base64url": "^2.0.4", - "symfony/polyfill-php82": "^v1.31.0", - "web-token/jwt-library": "^3.3.0|^4.0.0" + "web-token/jwt-library": "^3.4.9|^4.0.6" }, "suggest": { "ext-bcmath": "Optional for performance.", "ext-gmp": "Optional for performance." }, "require-dev": { - "phpunit/phpunit": "^10.5.44|^11.5.6", - "phpstan/phpstan": "^2.1.2", + "phpunit/phpunit": "^11.5.46|^12.5.2", + "phpstan/phpstan": "^2.1.33", "friendsofphp/php-cs-fixer": "^v3.91.3", "symfony/polyfill-iconv": "^1.33" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bcff581..b6195bf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,10 +4,15 @@ bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache" colors="true" + displayDetailsOnPhpunitDeprecations="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" processIsolation="false" stopOnFailure="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" > otherwise(function ($reason) { - return $this->createRejectedReport($reason); - }); + ->otherwise(fn ($reason) => $this->createRejectedReport($reason)); } foreach ($promises as $promise) { @@ -200,12 +198,12 @@ public function flushPooled($callback, ?int $batchSize = null, ?int $requestConc $batch = $this->prepare($batch); $pool = new Pool($this->client, $batch, [ 'concurrency' => $requestConcurrency, - 'fulfilled' => function (ResponseInterface $response, int $index) use ($callback, $batch) { + 'fulfilled' => function (ResponseInterface $response, int $index) use ($callback, $batch): void { /** @var RequestInterface $request **/ $request = $batch[$index]; $callback(new MessageSentReport($request, $response)); }, - 'rejected' => function ($reason) use ($callback) { + 'rejected' => function ($reason) use ($callback): void { $callback($this->createRejectedReport($reason)); }, ]); diff --git a/tests/WebPushTest.php b/tests/WebPushTest.php index 0f9f461..7c133e1 100644 --- a/tests/WebPushTest.php +++ b/tests/WebPushTest.php @@ -248,7 +248,7 @@ public function testFlushPooled(): void $this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 2], JSON_THROW_ON_ERROR)); $this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 3], JSON_THROW_ON_ERROR)); - $callback = function ($report) { + $callback = function ($report): void { $this->assertFalse($report->isSuccess()); $this->assertTrue($report->isSubscriptionExpired()); $this->assertEquals(410, $report->getResponse()->getStatusCode()); From 96f94baaa8c08825622eba90e4fe71a904b293d7 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Thu, 11 Dec 2025 14:46:42 +0100 Subject: [PATCH 2/2] chore: migrations for php8.5 * remove deprecated `curl_close` * remove deprecated param `key_length` for `openssl_pkey_derive` --- src/Encryption.php | 2 +- tests/PushServiceTest.php | 4 ---- tests/WebPushTest.php | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Encryption.php b/src/Encryption.php index 0f58e6e..5e7366b 100644 --- a/src/Encryption.php +++ b/src/Encryption.php @@ -296,7 +296,7 @@ private static function calculateAgreementKey(JWK $private_key, JWK $public_key) $publicPem = ECKey::convertPublicKeyToPEM($public_key); $privatePem = ECKey::convertPrivateKeyToPEM($private_key); - $result = openssl_pkey_derive($publicPem, $privatePem, 256); + $result = openssl_pkey_derive($publicPem, $privatePem); if ($result === false) { throw new \RuntimeException('Unable to compute the agreement key.'); } diff --git a/tests/PushServiceTest.php b/tests/PushServiceTest.php index 805f4c4..b3be757 100644 --- a/tests/PushServiceTest.php +++ b/tests/PushServiceTest.php @@ -166,7 +166,6 @@ private function getResponse($ch) if (!$resp) { $error = 'Curl error: n'.curl_errno($ch).' - '.curl_error($ch); - curl_close($ch); throw new RuntimeException($error); } @@ -176,9 +175,6 @@ private function getResponse($ch) throw new RuntimeException('web-push-testing-service error: '.$resp); } - // Close request to clear up some resources - curl_close($ch); - return $parsedResp; } } diff --git a/tests/WebPushTest.php b/tests/WebPushTest.php index 7c133e1..aed4b3c 100644 --- a/tests/WebPushTest.php +++ b/tests/WebPushTest.php @@ -107,7 +107,6 @@ private static function setCiEnvironment(): void if (!$response) { $error = 'Curl error: n'.curl_errno($getSubscriptionCurl).' - '.curl_error($getSubscriptionCurl); - curl_close($getSubscriptionCurl); throw new RuntimeException($error); }