diff --git a/composer.json b/composer.json index f12f10b..a14977c 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/phpstan.neon b/phpstan.neon index 2e9b252..c4e4b17 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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 diff --git a/tests/PushServiceTest.php b/tests/PushServiceTest.php index e2a24cb..e441047 100644 --- a/tests/PushServiceTest.php +++ b/tests/PushServiceTest.php @@ -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++) { @@ -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); @@ -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([ @@ -160,7 +159,7 @@ protected function createClosureTest($browserId, $options): callable }; } - private function getResponse($ch) + private function getResponse(CurlHandle $ch): mixed { $resp = curl_exec($ch); diff --git a/tests/WebPushTest.php b/tests/WebPushTest.php index b943fdb..f59f545 100644 --- a/tests/WebPushTest.php +++ b/tests/WebPushTest.php @@ -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"}', + ], ]; }