From 94a0b912b706e22c102ca6f901694a2150eac220 Mon Sep 17 00:00:00 2001 From: sunaoka Date: Fri, 12 Jul 2024 11:18:15 +0900 Subject: [PATCH] PHPStan Improvements --- phpstan.neon | 16 +----- src/Drivers/Driver.php | 2 +- src/Drivers/DriverOption.php | 1 + src/Drivers/FCM/V1.php | 1 + src/Exceptions/OptionTypeError.php | 5 +- tests/Assert.php | 4 +- tests/Drivers/APNs/CertificateTest.php | 51 ++++++++++++++++- tests/Drivers/APNs/TokenTest.php | 65 +++++++++++++++++++-- tests/Drivers/FCM/JsonTest.php | 61 ++++++++++++++++++-- tests/Drivers/FCM/PlainTextTest.php | 51 ++++++++++++++++- tests/Drivers/FCM/V1Test.php | 79 ++++++++++++++++++++++---- tests/Drivers/FeedbackTest.php | 3 + tests/Fake/FakeDriver.php | 12 ++++ tests/PusherTest.php | 5 ++ tests/TestCase.php | 5 ++ 15 files changed, 319 insertions(+), 42 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 4f21c4f..2211037 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,21 +2,9 @@ parameters: paths: - src + - tests level: 9 - checkMissingIterableValueType: false - ignoreErrors: - - - message: '!Property Sunaoka\\PushNotifications\\Drivers\\FCM\\V1::\$httpClient!' - path: src/Drivers/FCM/V1.php - - - message: '!Parameter #1 \$errors of class!' - path: src/Drivers/DriverOption.php - - - message: '!Else branch is unreachable because previous condition is always true!' - path: src/Drivers/Driver.php - - - message: "!Offset 'class' does not exist on array{function: string, line\\?: int, file\\?: string, class\\?: class-string, type\\?: '->'\\|'::', args\\?: array, object\\?: object}!" - path: src/Exceptions/OptionTypeError.php + - identifier: missingType.iterableValue diff --git a/src/Drivers/Driver.php b/src/Drivers/Driver.php index 4cdda82..e294663 100644 --- a/src/Drivers/Driver.php +++ b/src/Drivers/Driver.php @@ -127,7 +127,7 @@ protected function parseErrorResponse($e) if ($response !== null) { $message = $response->getReasonPhrase(); $contents = $response->getBody()->getContents(); - } else { + } else { // @phpstan-ignore else.unreachable $message = $e->getMessage(); } } else { diff --git a/src/Drivers/DriverOption.php b/src/Drivers/DriverOption.php index 019c583..e48813e 100644 --- a/src/Drivers/DriverOption.php +++ b/src/Drivers/DriverOption.php @@ -53,6 +53,7 @@ public function validate() $validator = new Validator((array)$this); $validator->mapFieldsRules(array_merge($this->defaultValidationRules, $this->validationRules)); if (!$validator->validate()) { + // @phpstan-ignore argument.type throw new ValidationException($validator->errors()); } diff --git a/src/Drivers/FCM/V1.php b/src/Drivers/FCM/V1.php index e358979..75d4627 100644 --- a/src/Drivers/FCM/V1.php +++ b/src/Drivers/FCM/V1.php @@ -59,6 +59,7 @@ public function send() 'scopes' => 'https://www.googleapis.com/auth/firebase.messaging', ]); + // @phpstan-ignore assign.propertyType $this->httpClient = $client->authorize($this->getHttpClient($this->options->httpOptions)); foreach ($this->devices as $device) { diff --git a/src/Exceptions/OptionTypeError.php b/src/Exceptions/OptionTypeError.php index e2319dc..8fe4d0c 100644 --- a/src/Exceptions/OptionTypeError.php +++ b/src/Exceptions/OptionTypeError.php @@ -13,6 +13,7 @@ public function __construct($expected, $actual) $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); if (isset($trace[1])) { + // @phpstan-ignore offsetAccess.notFound $method = sprintf('%s::%s()', $trace[1]['class'], $trace[1]['function']); } else { $method = 'Unknown'; // @codeCoverageIgnore @@ -20,7 +21,9 @@ public function __construct($expected, $actual) $message = sprintf( '%s: Argument #1 ($options) must be of type %s, %s given, called', - $method, $expected, is_object($actual) ? get_class($actual) : gettype($actual) + $method, + $expected, + is_object($actual) ? get_class($actual) : gettype($actual) ); parent::__construct($message); diff --git a/tests/Assert.php b/tests/Assert.php index 03edd8e..14419f3 100644 --- a/tests/Assert.php +++ b/tests/Assert.php @@ -8,7 +8,9 @@ trait Assert { /** - * @param string $exception + * @param class-string<\Throwable> $exception + * + * @return void */ public function expectExceptionCompat($exception) { diff --git a/tests/Drivers/APNs/CertificateTest.php b/tests/Drivers/APNs/CertificateTest.php index 350b3d4..b26af4f 100644 --- a/tests/Drivers/APNs/CertificateTest.php +++ b/tests/Drivers/APNs/CertificateTest.php @@ -16,6 +16,12 @@ class CertificateTest extends TestCase { + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleToken() { $payload = [ @@ -45,6 +51,12 @@ public function testSingleToken() self::assertSame('01234567-0123-0123-0123-01234567890A', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleToken() { $payload = [ @@ -80,6 +92,12 @@ public function testMultipleToken() self::assertSame('01234567-0123-0123-0123-01234567890B', $feedback->success('abcdefghij')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleFailure() { $payload = [ @@ -109,6 +127,12 @@ public function testSingleFailure() self::assertSame('BadDeviceToken', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleFailure() { $payload = [ @@ -144,6 +168,9 @@ public function testMultipleFailure() self::assertSame('BadDeviceToken', $feedback->failure('abcdefghij')); } + /** + * @return void + */ public function testMakeOption() { $payload = [ @@ -165,6 +192,11 @@ public function testMakeOption() self::assertSame('com.example.app', $options->topic); } + /** + * @return void + * + * @throws ValidationException + */ public function testValidateOption() { $this->expectExceptionCompat(ValidationException::class); @@ -173,13 +205,24 @@ public function testValidateOption() $options->validate(); } + /** + * @return void + * + * @throws OptionTypeError + */ public function testInvalidOption() { $this->expectExceptionCompat(OptionTypeError::class); - new APNs\Certificate(new FakeOption()); + new APNs\Certificate(new FakeOption()); // @phpstan-ignore argument.type } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestFailure() { $payload = [ @@ -209,6 +252,12 @@ public function testRequestFailure() self::assertSame('Internal Server Error', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestException() { $payload = [ diff --git a/tests/Drivers/APNs/TokenTest.php b/tests/Drivers/APNs/TokenTest.php index b6137fd..1c88344 100644 --- a/tests/Drivers/APNs/TokenTest.php +++ b/tests/Drivers/APNs/TokenTest.php @@ -16,6 +16,12 @@ class TokenTest extends TestCase { + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleToken() { $payload = [ @@ -26,7 +32,7 @@ public function testSingleToken() $options = new APNs\Token\Option(); $options->payload = $payload; - $options->authKey = file_get_contents($this->certs('/fake.p8')); + $options->authKey = (string)file_get_contents($this->certs('/fake.p8')); $options->keyId = 'ABCDE12345'; $options->teamId = 'ABCDE12345'; $options->topic = 'com.example.app'; @@ -46,6 +52,12 @@ public function testSingleToken() self::assertSame('01234567-0123-0123-0123-01234567890A', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleToken() { $payload = [ @@ -56,7 +68,7 @@ public function testMultipleToken() $options = new APNs\Token\Option(); $options->payload = $payload; - $options->authKey = file_get_contents($this->certs('/fake.p8')); + $options->authKey = (string)file_get_contents($this->certs('/fake.p8')); $options->keyId = 'ABCDE12345'; $options->teamId = 'ABCDE12345'; $options->topic = 'com.example.app'; @@ -82,6 +94,12 @@ public function testMultipleToken() self::assertSame('01234567-0123-0123-0123-01234567890B', $feedback->success('abcdefghij')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testAuthKeyIsFile() { $payload = [ @@ -112,6 +130,12 @@ public function testAuthKeyIsFile() self::assertSame('01234567-0123-0123-0123-01234567890A', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleFailure() { $payload = [ @@ -142,6 +166,12 @@ public function testSingleFailure() self::assertSame('BadDeviceToken', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleFailure() { $payload = [ @@ -178,6 +208,9 @@ public function testMultipleFailure() self::assertSame('BadDeviceToken', $feedback->failure('abcdefghij')); } + /** + * @return void + */ public function testMakeOption() { $payload = [ @@ -201,6 +234,11 @@ public function testMakeOption() self::assertSame('com.example.app', $options->topic); } + /** + * @return void + * + * @throws ValidationException + */ public function testValidateOption() { $this->expectExceptionCompat(ValidationException::class); @@ -209,13 +247,24 @@ public function testValidateOption() $options->validate(); } + /** + * @return void + * + * @throws OptionTypeError + */ public function testInvalidOption() { $this->expectExceptionCompat(OptionTypeError::class); - new APNs\Token(new FakeOption()); + new APNs\Token(new FakeOption()); // @phpstan-ignore argument.type } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestFailure() { $payload = [ @@ -226,7 +275,7 @@ public function testRequestFailure() $options = new APNs\Token\Option(); $options->payload = $payload; - $options->authKey = file_get_contents($this->certs('/fake.p8')); + $options->authKey = (string)file_get_contents($this->certs('/fake.p8')); $options->keyId = 'ABCDE12345'; $options->teamId = 'ABCDE12345'; $options->topic = 'com.example.app'; @@ -246,6 +295,12 @@ public function testRequestFailure() self::assertSame('Internal Server Error', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestException() { $payload = [ @@ -256,7 +311,7 @@ public function testRequestException() $options = new APNs\Token\Option(); $options->payload = $payload; - $options->authKey = file_get_contents($this->certs('/fake.p8')); + $options->authKey = (string)file_get_contents($this->certs('/fake.p8')); $options->keyId = 'ABCDE12345'; $options->teamId = 'ABCDE12345'; $options->topic = 'com.example.app'; diff --git a/tests/Drivers/FCM/JsonTest.php b/tests/Drivers/FCM/JsonTest.php index c09c801..45125e0 100644 --- a/tests/Drivers/FCM/JsonTest.php +++ b/tests/Drivers/FCM/JsonTest.php @@ -16,6 +16,12 @@ class JsonTest extends TestCase { + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleToken() { $payload = [ @@ -31,7 +37,7 @@ public function testSingleToken() $driver = new FCM\Json($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'multicast_id' => 1234567890123456789, 'success' => 1, 'failure' => 0, @@ -51,6 +57,12 @@ public function testSingleToken() self::assertSame('0:1632441600000000%d00000000000000a', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleToken() { $payload = [ @@ -66,7 +78,7 @@ public function testMultipleToken() $driver = new FCM\Json($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'multicast_id' => 1234567890123456789, 'success' => 2, 'failure' => 0, @@ -92,6 +104,12 @@ public function testMultipleToken() self::assertSame('0:1632441600000000%d00000000000000b', $feedback->success('abcdefghij')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleFailure() { $payload = [ @@ -107,7 +125,7 @@ public function testSingleFailure() $driver = new FCM\Json($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'multicast_id' => 1234567890123456789, 'success' => 0, 'failure' => 1, @@ -127,6 +145,12 @@ public function testSingleFailure() self::assertSame('InvalidRegistration', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleFailure() { $payload = [ @@ -142,7 +166,7 @@ public function testMultipleFailure() $driver = new FCM\Json($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'multicast_id' => 1234567890123456789, 'success' => 0, 'failure' => 1, @@ -152,7 +176,7 @@ public function testMultipleFailure() ['error' => 'InvalidRegistration'], ], ])), - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'multicast_id' => 1234567890123456789, 'success' => 0, 'failure' => 1, @@ -178,6 +202,9 @@ public function testMultipleFailure() self::assertSame('InvalidRegistration', $feedback->failure('abcdefghij')); } + /** + * @return void + */ public function testMakeOption() { $payload = [ @@ -195,6 +222,11 @@ public function testMakeOption() self::assertSame('fake-api-key', $options->apiKey); } + /** + * @return void + * + * @throws ValidationException + */ public function testValidateOption() { $this->expectExceptionCompat(ValidationException::class); @@ -203,13 +235,24 @@ public function testValidateOption() $options->validate(); } + /** + * @return void + * + * @throws OptionTypeError + */ public function testInvalidOption() { $this->expectExceptionCompat(OptionTypeError::class); - new FCM\Json(new FakeOption()); + new FCM\Json(new FakeOption()); // @phpstan-ignore argument.type } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestFailure() { $payload = [ @@ -237,6 +280,12 @@ public function testRequestFailure() self::assertSame('Internal Server Error', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestException() { $payload = [ diff --git a/tests/Drivers/FCM/PlainTextTest.php b/tests/Drivers/FCM/PlainTextTest.php index a96d4a7..4b2f1fe 100644 --- a/tests/Drivers/FCM/PlainTextTest.php +++ b/tests/Drivers/FCM/PlainTextTest.php @@ -16,6 +16,12 @@ class PlainTextTest extends TestCase { + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleToken() { $payload = [ @@ -41,6 +47,12 @@ public function testSingleToken() self::assertSame('0:1632441600000000%d00000000000000a', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleToken() { $payload = [ @@ -72,6 +84,12 @@ public function testMultipleToken() self::assertSame('0:1632441600000000%d00000000000000b', $feedback->success('abcdefghij')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleFailure() { $payload = [ @@ -97,6 +115,12 @@ public function testSingleFailure() self::assertSame('MissingRegistration', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleFailure() { $payload = [ @@ -128,6 +152,9 @@ public function testMultipleFailure() self::assertSame('MissingRegistration', $feedback->failure('abcdefghij')); } + /** + * @return void + */ public function testMakeOption() { $payload = [ @@ -143,6 +170,11 @@ public function testMakeOption() self::assertSame('fake-api-key', $options->apiKey); } + /** + * @return void + * + * @throws ValidationException + */ public function testValidateOption() { $this->expectExceptionCompat(ValidationException::class); @@ -151,13 +183,24 @@ public function testValidateOption() $options->validate(); } + /** + * @return void + * + * @throws OptionTypeError + */ public function testInvalidOption() { $this->expectExceptionCompat(OptionTypeError::class); - new FCM\PlainText(new FakeOption()); + new FCM\PlainText(new FakeOption()); // @phpstan-ignore argument.type } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestFailure() { $payload = [ @@ -183,6 +226,12 @@ public function testRequestFailure() self::assertSame('Internal Server Error', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestException() { $payload = [ diff --git a/tests/Drivers/FCM/V1Test.php b/tests/Drivers/FCM/V1Test.php index df91f10..2c10c60 100644 --- a/tests/Drivers/FCM/V1Test.php +++ b/tests/Drivers/FCM/V1Test.php @@ -16,6 +16,12 @@ class V1Test extends TestCase { + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleToken() { $payload = [ @@ -28,13 +34,13 @@ public function testSingleToken() $options = new FCM\V1\Option(); $options->payload = $payload; - $options->credentials = json_decode(file_get_contents($this->certs('/fake.json')), true); + $options->credentials = (array)json_decode((string)file_get_contents($this->certs('/fake.json')), true); $options->projectId = 'fake-project-id'; $driver = new FCM\V1($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'name' => 'projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', ])), ]) @@ -48,6 +54,12 @@ public function testSingleToken() self::assertSame('projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleToken() { $payload = [ @@ -60,16 +72,16 @@ public function testMultipleToken() $options = new FCM\V1\Option(); $options->payload = $payload; - $options->credentials = json_decode(file_get_contents($this->certs('/fake.json')), true); + $options->credentials = (array)json_decode((string)file_get_contents($this->certs('/fake.json')), true); $options->projectId = 'fake-project-id'; $driver = new FCM\V1($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'name' => 'projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', ])), - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'name' => 'projects/fake-project-id/messages/0:1632441600000000%d00000000000000b', ])), ]) @@ -88,6 +100,12 @@ public function testMultipleToken() self::assertSame('projects/fake-project-id/messages/0:1632441600000000%d00000000000000b', $feedback->success('abcdefghij')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testAuthKeyIsFile() { $payload = [ @@ -106,7 +124,7 @@ public function testAuthKeyIsFile() $driver = new FCM\V1($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'name' => 'projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', ])), ]) @@ -120,6 +138,12 @@ public function testAuthKeyIsFile() self::assertSame('projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', $feedback->success('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testSingleFailure() { $payload = [ @@ -138,7 +162,7 @@ public function testSingleFailure() $driver = new FCM\V1($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(400, [], json_encode([ + new Response(400, [], (string)json_encode([ 'error' => [ 'code' => 400, 'message' => 'The registration token is not a valid FCM registration token', @@ -162,6 +186,12 @@ public function testSingleFailure() self::assertSame('[INVALID_ARGUMENT] The registration token is not a valid FCM registration token', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testMultipleFailure() { $payload = [ @@ -180,10 +210,10 @@ public function testMultipleFailure() $driver = new FCM\V1($options); $driver->setHttpHandler(HandlerStack::create( new MockHandler([ - new Response(200, [], json_encode([ + new Response(200, [], (string)json_encode([ 'name' => 'projects/fake-project-id/messages/0:1632441600000000%d00000000000000a', ])), - new Response(400, [], json_encode([ + new Response(400, [], (string)json_encode([ 'error' => [ 'code' => 400, 'message' => 'The registration token is not a valid FCM registration token', @@ -212,6 +242,9 @@ public function testMultipleFailure() self::assertSame('[INVALID_ARGUMENT] The registration token is not a valid FCM registration token', $feedback->failure('abcdefghij')); } + /** + * @return void + */ public function testMakeOption() { $payload = [ @@ -229,6 +262,11 @@ public function testMakeOption() self::assertSame('fake-project-id', $options->projectId); } + /** + * @return void + * + * @throws ValidationException + */ public function testValidateOption() { $this->expectExceptionCompat(ValidationException::class); @@ -237,13 +275,24 @@ public function testValidateOption() $options->validate(); } + /** + * @return void + * + * @throws OptionTypeError + */ public function testInvalidOption() { $this->expectExceptionCompat(OptionTypeError::class); - new FCM\V1(new FakeOption()); + new FCM\V1(new FakeOption()); // @phpstan-ignore argument.type } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestFailure() { $payload = [ @@ -256,7 +305,7 @@ public function testRequestFailure() $options = new FCM\V1\Option(); $options->payload = $payload; - $options->credentials = json_decode(file_get_contents($this->certs('/fake.json')), true); + $options->credentials = (array)json_decode((string)file_get_contents($this->certs('/fake.json')), true); $options->projectId = 'fake-project-id'; $driver = new FCM\V1($options); @@ -274,6 +323,12 @@ public function testRequestFailure() self::assertSame('Internal Server Error', $feedback->failure('1234567890')); } + /** + * @return void + * + * @throws OptionTypeError + * @throws ValidationException + */ public function testRequestException() { $payload = [ @@ -286,7 +341,7 @@ public function testRequestException() $options = new FCM\V1\Option(); $options->payload = $payload; - $options->credentials = json_decode(file_get_contents($this->certs('/fake.json')), true); + $options->credentials = (array)json_decode((string)file_get_contents($this->certs('/fake.json')), true); $options->projectId = 'fake-project-id'; $driver = new FCM\V1($options); diff --git a/tests/Drivers/FeedbackTest.php b/tests/Drivers/FeedbackTest.php index 90012c2..97afea1 100644 --- a/tests/Drivers/FeedbackTest.php +++ b/tests/Drivers/FeedbackTest.php @@ -7,6 +7,9 @@ class FeedbackTest extends TestCase { + /** + * @return void + */ public function test() { $feedback = new Feedback(); diff --git a/tests/Fake/FakeDriver.php b/tests/Fake/FakeDriver.php index 3ad4093..ce98377 100644 --- a/tests/Fake/FakeDriver.php +++ b/tests/Fake/FakeDriver.php @@ -3,13 +3,25 @@ namespace Sunaoka\PushNotifications\Tests\Fake; use Sunaoka\PushNotifications\Drivers\Driver; +use Sunaoka\PushNotifications\Drivers\DriverOptionInterface; +use Sunaoka\PushNotifications\Drivers\Feedback; class FakeDriver extends Driver { + /** + * @param DriverOptionInterface $options + * + * @phpstan-ignore constructor.unusedParameter + */ public function __construct($options) { } + /** + * @return Feedback + * + * @phpstan-ignore return.missing + */ public function send() { } diff --git a/tests/PusherTest.php b/tests/PusherTest.php index e2068b9..1508b98 100644 --- a/tests/PusherTest.php +++ b/tests/PusherTest.php @@ -9,6 +9,11 @@ class PusherTest extends TestCase { + /** + * @return void + * + * @throws ValidationException + */ public function testSendFailure() { $this->expectExceptionCompat(ValidationException::class); diff --git a/tests/TestCase.php b/tests/TestCase.php index b456d1d..8e052a8 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,6 +6,11 @@ class TestCase extends \PHPUnit\Framework\TestCase { use Assert; + /** + * @param string $dir + * + * @return string + */ protected function certs($dir) { return __DIR__ . '/Fake/Certs' . $dir;