Skip to content

Commit 6e8ca8b

Browse files
authored
chore: drop php8.1; add php8.5 (#435)
* 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 * chore: migrations for php8.5 * remove deprecated `curl_close` * remove deprecated param `key_length` for `openssl_pkey_derive`
1 parent f979f40 commit 6e8ca8b

File tree

9 files changed

+24
-26
lines changed

9 files changed

+24
-26
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php: [ '8.1', '8.2', '8.3', '8.4' ]
20+
php: [ '8.2', '8.3', '8.4', '8.5' ]
2121
ext_base: [ 'none, dom, tokenizer, xml, xmlwriter,' ]
2222
ext_lib: [ 'curl, mbstring, openssl,' ]
2323
ext_optional: [ '', 'bcmath', 'gmp' ]
@@ -43,16 +43,16 @@ jobs:
4343
uses: actions/cache@v4
4444
with:
4545
path: ${{ steps.composer-cache.outputs.dir }}
46-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
47-
restore-keys: ${{ runner.os }}-composer-
46+
key: ${{ runner.os }}-composer-php${{ matrix.php }}-${{ matrix.ext_optional }}-${{ hashFiles('**/composer.json') }}
47+
restore-keys: ${{ runner.os }}-composer-php${{ matrix.php }}-${{ matrix.ext_optional }}
4848

4949
- name: Install dependencies
5050
run: composer install --prefer-dist
5151

5252
- name: Setup node
5353
uses: actions/setup-node@v6
5454
with:
55-
node-version: '20'
55+
node-version: '24'
5656

5757
- name: Install web-push-testing server
5858
run: |

.php-cs-fixer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
$config = new PhpCsFixer\Config();
55
$rules = [
66
'@PSR12' => true, // The default rule.
7-
'@PHP81Migration' => true, // Must be the same as the min PHP version.
7+
'@autoPHPMigration' => true, // Uses min PHP version for regular migrations.
88
'blank_line_after_opening_tag' => false, // Do not waste space between <?php and declare.
99
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
1010
'php_unit_construct' => true,
1111
'php_unit_attributes' => true,
1212
'php_unit_method_casing' => true,
1313
'php_unit_test_class_requires_covers' => true,
1414
// Do not enable by default. These rules require review!! (but they are useful)
15-
// '@PHP80Migration:risky' => true,
16-
// '@PHPUnit100Migration:risky' => true,
15+
// '@autoPHPMigration:risky' => true,
16+
// '@autoPHPUnitMigration:risky' => true,
1717
];
1818

1919
$config->setRules($rules);

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This push message is then received by the browser, which can then create a notif
1010

1111
## Requirements
1212

13-
PHP 8.1+ and the following extensions:
13+
PHP 8.2+ and the following extensions:
1414

1515
- bcmath and/or gmp (optional but better for performance)
1616
- mbstring
@@ -25,6 +25,7 @@ There is no support and maintenance for older PHP versions, however you are free
2525
- PHP 7.2: `v6.x`
2626
- PHP 7.3 7.4: `v7.x`
2727
- PHP 8.0 / Openssl without elliptic curve support: `v8.x`
28+
- PHP 8.1: `v9.x`
2829

2930
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.
3031

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,22 @@
2828
"test:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --dry-run --stop-on-violation --using-cache=no"
2929
},
3030
"require": {
31-
"php": ">=8.1",
31+
"php": ">=8.2",
3232
"ext-curl": "*",
3333
"ext-json": "*",
3434
"ext-mbstring": "*",
3535
"ext-openssl": "*",
3636
"guzzlehttp/guzzle": "^7.9.2",
3737
"spomky-labs/base64url": "^2.0.4",
38-
"symfony/polyfill-php82": "^v1.31.0",
39-
"web-token/jwt-library": "^3.3.0|^4.0.0"
38+
"web-token/jwt-library": "^3.4.9|^4.0.6"
4039
},
4140
"suggest": {
4241
"ext-bcmath": "Optional for performance.",
4342
"ext-gmp": "Optional for performance."
4443
},
4544
"require-dev": {
46-
"phpunit/phpunit": "^10.5.44|^11.5.6",
47-
"phpstan/phpstan": "^2.1.2",
45+
"phpunit/phpunit": "^11.5.46|^12.5.2",
46+
"phpstan/phpstan": "^2.1.33",
4847
"friendsofphp/php-cs-fixer": "^v3.91.3",
4948
"symfony/polyfill-iconv": "^1.33"
5049
},

phpunit.xml.dist

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
bootstrap="vendor/autoload.php"
55
cacheDirectory=".phpunit.cache"
66
colors="true"
7+
displayDetailsOnPhpunitDeprecations="true"
8+
displayDetailsOnTestsThatTriggerDeprecations="true"
9+
displayDetailsOnTestsThatTriggerErrors="true"
10+
displayDetailsOnTestsThatTriggerNotices="true"
11+
displayDetailsOnTestsThatTriggerWarnings="true"
712
processIsolation="false"
813
stopOnFailure="false"
914
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
15+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
1116
>
1217
<source ignoreSuppressionOfDeprecations="true"
1318
ignoreSuppressionOfPhpDeprecations="true"

src/Encryption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private static function calculateAgreementKey(JWK $private_key, JWK $public_key)
296296
$publicPem = ECKey::convertPublicKeyToPEM($public_key);
297297
$privatePem = ECKey::convertPrivateKeyToPEM($private_key);
298298

299-
$result = openssl_pkey_derive($publicPem, $privatePem, 256);
299+
$result = openssl_pkey_derive($publicPem, $privatePem);
300300
if ($result === false) {
301301
throw new \RuntimeException('Unable to compute the agreement key.');
302302
}

src/WebPush.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ public function flush(?int $batchSize = null): \Generator
157157
/** @var ResponseInterface $response **/
158158
return new MessageSentReport($request, $response);
159159
})
160-
->otherwise(function ($reason) {
161-
return $this->createRejectedReport($reason);
162-
});
160+
->otherwise(fn ($reason) => $this->createRejectedReport($reason));
163161
}
164162

165163
foreach ($promises as $promise) {
@@ -200,12 +198,12 @@ public function flushPooled($callback, ?int $batchSize = null, ?int $requestConc
200198
$batch = $this->prepare($batch);
201199
$pool = new Pool($this->client, $batch, [
202200
'concurrency' => $requestConcurrency,
203-
'fulfilled' => function (ResponseInterface $response, int $index) use ($callback, $batch) {
201+
'fulfilled' => function (ResponseInterface $response, int $index) use ($callback, $batch): void {
204202
/** @var RequestInterface $request **/
205203
$request = $batch[$index];
206204
$callback(new MessageSentReport($request, $response));
207205
},
208-
'rejected' => function ($reason) use ($callback) {
206+
'rejected' => function ($reason) use ($callback): void {
209207
$callback($this->createRejectedReport($reason));
210208
},
211209
]);

tests/PushServiceTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ private function getResponse($ch)
166166

167167
if (!$resp) {
168168
$error = 'Curl error: n'.curl_errno($ch).' - '.curl_error($ch);
169-
curl_close($ch);
170169
throw new RuntimeException($error);
171170
}
172171

@@ -176,9 +175,6 @@ private function getResponse($ch)
176175
throw new RuntimeException('web-push-testing-service error: '.$resp);
177176
}
178177

179-
// Close request to clear up some resources
180-
curl_close($ch);
181-
182178
return $parsedResp;
183179
}
184180
}

tests/WebPushTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ private static function setCiEnvironment(): void
107107

108108
if (!$response) {
109109
$error = 'Curl error: n'.curl_errno($getSubscriptionCurl).' - '.curl_error($getSubscriptionCurl);
110-
curl_close($getSubscriptionCurl);
111110
throw new RuntimeException($error);
112111
}
113112

@@ -248,7 +247,7 @@ public function testFlushPooled(): void
248247
$this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 2], JSON_THROW_ON_ERROR));
249248
$this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 3], JSON_THROW_ON_ERROR));
250249

251-
$callback = function ($report) {
250+
$callback = function ($report): void {
252251
$this->assertFalse($report->isSuccess());
253252
$this->assertTrue($report->isSubscriptionExpired());
254253
$this->assertEquals(410, $report->getResponse()->getStatusCode());

0 commit comments

Comments
 (0)