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
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
"ext-gmp": "Optional for performance."
},
"require-dev": {
"phpunit/phpunit": "^11.5.46|^12.5.2",
"phpstan/phpstan": "^2.1.33",
"friendsofphp/php-cs-fixer": "^v3.92.2",
"symfony/polyfill-iconv": "^1.33",
"phpstan/phpstan-strict-rules": "^2.0"
"phpstan/phpstan": "^2.1.33",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5.46|^12.5.2",
"symfony/polyfill-iconv": "^1.33"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 20 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,32 @@ parameters:
level: 7
paths:
- src
- tests
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- identifier: missingType.iterableValue
paths:
- src/Encryption.php
- src/MessageSentReport.php
- src/Notification.php
- src/Subscription.php
- src/Utils.php
- src/VAPID.php
- src/WebPush.php
- path: tests/
identifiers:
- argument.type
- closure.unusedUse
- foreach.valueOverwrite
- missingType.iterableValue
- property.dynamicName
- staticMethod.dynamicCall
strictRules:
booleansInConditions: false
disallowedEmpty: false

includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
9 changes: 4 additions & 5 deletions tests/PushServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function browserProvider(): array
/**
* Selenium tests are flakey so add retries.
*/
public function retryTest($retryCount, $test): void
public function retryTest(int $retryCount, callable $test): void
{
// just like above without checking the annotation
for ($i = 0; $i < $retryCount; $i++) {
Expand All @@ -76,12 +76,12 @@ public function retryTest($retryCount, $test): void
* Run integration tests with browsers
*/
#[dataProvider('browserProvider')]
public function testBrowsers($browserId, $options): void
public function testBrowsers(string $browserId, array $options): void
{
$this->retryTest(2, $this->createClosureTest($browserId, $options));
}

protected function createClosureTest($browserId, $options): callable
protected function createClosureTest(string $browserId, array $options): callable
{
return function () use ($browserId, $options): void {
$this->webPush = new WebPush($options);
Expand Down Expand Up @@ -128,7 +128,6 @@ protected function createClosureTest($browserId, $options): callable

$subscription = new Subscription($endpoint, $p256dh, $auth, $contentEncoding);
$report = $this->webPush->sendOneNotification($subscription, $payload);
$this->assertInstanceOf(MessageSentReport::class, $report);
$this->assertTrue($report->isSuccess());

$dataString = json_encode([
Expand Down Expand Up @@ -160,7 +159,7 @@ protected function createClosureTest($browserId, $options): callable
};
}

private function getResponse($ch)
private function getResponse(CurlHandle $ch): mixed
{
$resp = curl_exec($ch);

Expand Down
8 changes: 4 additions & 4 deletions tests/WebPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ private static function setCiEnvironment(): void
self::$keys['standard'] = $keys->{'p256dh'};
}

/**
* @throws ErrorException
*/
public static function notificationProvider(): array
{
self::setUpBeforeClass(); // dirty hack of PHPUnit limitation

return [
[new Subscription(self::$endpoints['standard'] ?: '', self::$keys['standard'] ?: '', self::$tokens['standard'] ?: ''), '{"message":"Comment ça va ?","tag":"general"}'],
[
new Subscription(self::$endpoints['standard'] ?? '', self::$keys['standard'] ?? '', self::$tokens['standard'] ?? ''),
'{"message":"Comment ça va ?","tag":"general"}',
],
];
}

Expand Down