Skip to content

Commit 69d24f9

Browse files
committed
refactor: declare generics
1 parent e4e4da1 commit 69d24f9

File tree

9 files changed

+39
-5
lines changed

9 files changed

+39
-5
lines changed

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ parameters:
1111
identifier: return.type
1212
count: 1
1313
path: tests/User.php
14+
15+
-
16+
message: '#^Unable to resolve the template type TRelatedModel in call to method Illuminate\\Database\\Eloquent\\Model\:\:morphMany\(\)$#'
17+
identifier: argument.templateType
18+
count: 1
19+
path: tests/User.php

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ parameters:
99
- tests
1010
- migrations/create_push_subscriptions_table.php.stub
1111

12-
level: 5
12+
level: 6
1313

1414
tmpDir: .phpstan.cache

src/HasPushSubscriptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function deletePushSubscription(string $endpoint): void
6767
/**
6868
* Get all of the subscriptions.
6969
*
70-
* @return \Illuminate\Database\Eloquent\Collection<\NotificationChannels\WebPush\PushSubscription>
70+
* @return \Illuminate\Database\Eloquent\Collection<array-key, \NotificationChannels\WebPush\PushSubscription>
7171
*/
7272
public function routeNotificationForWebPush(): Collection
7373
{

src/PushSubscription.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class PushSubscription extends Model
2828
/**
2929
* Create a new model instance.
3030
*
31+
* @param array<string, mixed> $attributes
3132
* @return void
3233
*/
3334
public function __construct(array $attributes = [])
@@ -45,6 +46,8 @@ public function __construct(array $attributes = [])
4546

4647
/**
4748
* Get the model related to the subscription.
49+
*
50+
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this>
4851
*/
4952
public function subscribable(): MorphTo
5053
{

src/VapidKeysGenerateCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function handle(): void
4646

4747
/**
4848
* Set the keys in the environment file.
49+
*
50+
* @param array{'publicKey': string, 'privateKey': string} $keys
4951
*/
5052
protected function setKeysInEnvironmentFile(array $keys): bool
5153
{
@@ -62,6 +64,8 @@ protected function setKeysInEnvironmentFile(array $keys): bool
6264

6365
/**
6466
* Write a new environment file with the given keys.
67+
*
68+
* @param array{'publicKey': string, 'privateKey': string} $keys
6569
*/
6670
protected function writeNewEnvironmentFileWith(array $keys): void
6771
{

src/WebPushChannel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ class WebPushChannel
1414
/**
1515
* @return void
1616
*/
17-
public function __construct(protected WebPush $webPush, protected ReportHandlerInterface $reportHandler) {}
17+
public function __construct(protected WebPush $webPush, protected ReportHandlerInterface $reportHandler)
18+
{
19+
//
20+
}
1821

1922
/**
2023
* Send the given notification.
2124
*/
2225
public function send(mixed $notifiable, Notification $notification): void
2326
{
24-
/** @var \Illuminate\Database\Eloquent\Collection $subscriptions */
27+
/** @var \Illuminate\Database\Eloquent\Collection<array-key, PushSubscription> $subscriptions */
2528
$subscriptions = $notifiable->routeNotificationFor('WebPush', $notification);
2629

2730
if ($subscriptions->isEmpty()) {

src/WebPushMessage.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class WebPushMessage
1111
{
1212
protected string $title;
1313

14+
/**
15+
* @var array<array-key, array{'title': string, 'action': string, 'icon'?: string}>
16+
*/
1417
protected array $actions = [];
1518

1619
protected string $badge;
@@ -31,10 +34,16 @@ class WebPushMessage
3134

3235
protected string $tag;
3336

37+
/**
38+
* @var array<int>
39+
*/
3440
protected array $vibrate;
3541

3642
protected mixed $data;
3743

44+
/**
45+
* @var array<string, mixed>
46+
*/
3847
protected array $options = [];
3948

4049
/**
@@ -168,6 +177,7 @@ public function tag(string $value): static
168177
/**
169178
* Set the notification vibration pattern.
170179
*
180+
* @param array<int> $value
171181
* @return $this
172182
*/
173183
public function vibrate(array $value): static
@@ -194,6 +204,7 @@ public function data(mixed $value): static
194204
*
195205
* @link https://github.com/web-push-libs/web-push-php#notifications-and-default-options
196206
*
207+
* @param array<string, mixed> $value
197208
* @return $this
198209
*/
199210
public function options(array $value): static
@@ -205,6 +216,8 @@ public function options(array $value): static
205216

206217
/**
207218
* Get the notification options.
219+
*
220+
* @return array<string, mixed>
208221
*/
209222
public function getOptions(): array
210223
{
@@ -213,6 +226,8 @@ public function getOptions(): array
213226

214227
/**
215228
* Get an array representation of the message.
229+
*
230+
* @return array<string, mixed>
216231
*/
217232
public function toArray(): array
218233
{

src/WebPushServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function boot(): void
4040

4141
/**
4242
* Get the authentication details.
43+
*
44+
* @return array<string, mixed>
4345
*/
4446
protected function webPushAuth(): array
4547
{

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getEnvironmentSetUp($app)
3434

3535
/**
3636
* @param \Illuminate\Foundation\Application $app
37-
* @return array
37+
* @return array<array-key, class-string>
3838
*/
3939
protected function getPackageProviders($app)
4040
{
@@ -61,6 +61,7 @@ protected function setUpDatabase()
6161
}
6262

6363
/**
64+
* @param array<string, mixed> $attributes
6465
* @return \NotificationChannels\WebPush\Test\User
6566
*/
6667
public function createUser(array $attributes)

0 commit comments

Comments
 (0)