Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]
Expand All @@ -43,16 +43,16 @@ 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

- name: Setup node
uses: actions/setup-node@v6
with:
node-version: '20'
node-version: '24'

- name: Install web-push-testing server
run: |
Expand Down
6 changes: 3 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
$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 <?php and declare.
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
'php_unit_construct' => true,
'php_unit_attributes' => true,
'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);
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
7 changes: 6 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<source ignoreSuppressionOfDeprecations="true"
ignoreSuppressionOfPhpDeprecations="true"
Expand Down
2 changes: 1 addition & 1 deletion src/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
8 changes: 3 additions & 5 deletions src/WebPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ public function flush(?int $batchSize = null): \Generator
/** @var ResponseInterface $response **/
return new MessageSentReport($request, $response);
})
->otherwise(function ($reason) {
return $this->createRejectedReport($reason);
});
->otherwise(fn ($reason) => $this->createRejectedReport($reason));
}

foreach ($promises as $promise) {
Expand Down Expand Up @@ -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));
},
]);
Expand Down
4 changes: 0 additions & 4 deletions tests/PushServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
}
}
3 changes: 1 addition & 2 deletions tests/WebPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -248,7 +247,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());
Expand Down