Skip to content

Commit dd4c7ec

Browse files
committed
refactor: rector, pint and phpstan issues
1 parent 82092f8 commit dd4c7ec

16 files changed

Lines changed: 53 additions & 44 deletions

‎config/webpush.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use NotificationChannels\WebPush\PushSubscription;
4+
35
return [
46

57
/**
@@ -16,7 +18,7 @@
1618
/**
1719
* This is model that will be used to for push subscriptions.
1820
*/
19-
'model' => \NotificationChannels\WebPush\PushSubscription::class,
21+
'model' => PushSubscription::class,
2022

2123
/**
2224
* This is the name of the table that will be created by the migration and

‎src/DeclarativeWebPushMessage.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
use NotificationChannels\WebPush\Exceptions\MessageValidationFailed;
77

88
/**
9-
* @implements \Illuminate\Contracts\Support\Arrayable<string, mixed>
10-
*
119
* @link https://www.w3.org/TR/push-api/#members
1210
*/
1311
class DeclarativeWebPushMessage implements WebPushMessageInterface

‎src/Events/NotificationFailed.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace NotificationChannels\WebPush\Events;
46

57
use Illuminate\Queue\SerializesModels;
@@ -13,8 +15,6 @@ class NotificationFailed
1315

1416
/**
1517
* Create a new event instance.
16-
*
17-
* @return void
1818
*/
1919
public function __construct(public MessageSentReport $report, public PushSubscription $subscription, public WebPushMessageInterface $message)
2020
{

‎src/Events/NotificationSent.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace NotificationChannels\WebPush\Events;
46

57
use Illuminate\Queue\SerializesModels;
@@ -13,8 +15,6 @@ class NotificationSent
1315

1416
/**
1517
* Create a new event instance.
16-
*
17-
* @return void
1818
*/
1919
public function __construct(public MessageSentReport $report, public PushSubscription $subscription, public WebPushMessageInterface $message)
2020
{

‎src/Exceptions/MessageValidationFailed.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace NotificationChannels\WebPush\Exceptions;
44

5-
class MessageValidationFailed extends \Exception
5+
final class MessageValidationFailed extends \Exception
66
{
7-
public static function titleRequired(): static
7+
public static function titleRequired(): self
88
{
9-
return new static('"title" must be set for Declarative Web Push messages');
9+
return new self('"title" must be set for Declarative Web Push messages');
1010
}
1111

12-
public static function navigateRequired(): static
12+
public static function navigateRequired(): self
1313
{
14-
return new static('"navigate" must be set for Declarative Web Push messages');
14+
return new self('"navigate" must be set for Declarative Web Push messages');
1515
}
1616
}

‎src/HasPushSubscriptions.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait HasPushSubscriptions
1010
/**
1111
* Get all of the subscriptions.
1212
*
13-
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<PushSubscription, $this>
13+
* @return MorphMany<PushSubscription, $this>
1414
*/
1515
public function pushSubscriptions(): MorphMany
1616
{
@@ -67,7 +67,7 @@ public function deletePushSubscription(string $endpoint): void
6767
/**
6868
* Get all of the subscriptions.
6969
*
70-
* @return \Illuminate\Database\Eloquent\Collection<array-key, \NotificationChannels\WebPush\PushSubscription>
70+
* @return Collection<array-key, PushSubscription>
7171
*/
7272
public function routeNotificationForWebPush(): Collection
7373
{

‎src/PushSubscription.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class PushSubscription extends Model
3434
* Create a new model instance.
3535
*
3636
* @param array<string, mixed> $attributes
37-
* @return void
3837
*/
3938
public function __construct(array $attributes = [])
4039
{
@@ -52,7 +51,7 @@ public function __construct(array $attributes = [])
5251
/**
5352
* Get the model related to the subscription.
5453
*
55-
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this>
54+
* @return MorphTo<Model, $this>
5655
*/
5756
public function subscribable(): MorphTo
5857
{

‎src/ReportHandler.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace NotificationChannels\WebPush;
46

7+
use Illuminate\Contracts\Events\Dispatcher;
58
use Minishlink\WebPush\MessageSentReport;
69
use NotificationChannels\WebPush\Events\NotificationFailed;
710
use NotificationChannels\WebPush\Events\NotificationSent;
@@ -10,10 +13,8 @@ class ReportHandler implements ReportHandlerInterface
1013
{
1114
/**
1215
* Create a new report handler.
13-
*
14-
* @return void
1516
*/
16-
public function __construct(protected \Illuminate\Contracts\Events\Dispatcher $events)
17+
public function __construct(protected Dispatcher $events)
1718
{
1819
//
1920
}

‎src/ReportHandlerInterface.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace NotificationChannels\WebPush;
46

57
use Minishlink\WebPush\MessageSentReport;

‎src/WebPushChannel.php‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212

1313
class WebPushChannel
1414
{
15-
/**
16-
* @return void
17-
*/
1815
public function __construct(protected WebPush $webPush, protected ReportHandlerInterface $reportHandler)
1916
{
2017
//
@@ -25,20 +22,20 @@ public function __construct(protected WebPush $webPush, protected ReportHandlerI
2522
*/
2623
public function send(mixed $notifiable, Notification $notification): void
2724
{
28-
/** @var \Illuminate\Database\Eloquent\Collection<array-key, PushSubscription> $subscriptions */
25+
/** @var Collection<array-key, PushSubscription> $subscriptions */
2926
$subscriptions = $notifiable->routeNotificationFor('WebPush', $notification);
3027

3128
if ($subscriptions->isEmpty()) {
3229
return;
3330
}
3431

35-
/** @var \NotificationChannels\WebPush\WebPushMessageInterface $message */
32+
/** @var WebPushMessageInterface $message */
3633
// @phpstan-ignore-next-line
3734
$message = $notification->toWebPush($notifiable, $notification);
3835
$payload = json_encode($message->toArray());
3936
$options = $message->getOptions();
4037

41-
/** @var \NotificationChannels\WebPush\PushSubscription $subscription */
38+
/** @var PushSubscription $subscription */
4239
foreach ($subscriptions as $subscription) {
4340
$this->webPush->queueNotification(new Subscription(
4441
$subscription->endpoint,
@@ -56,12 +53,12 @@ public function send(mixed $notifiable, Notification $notification): void
5653
/**
5754
* Handle the reports.
5855
*
59-
* @param \Illuminate\Database\Eloquent\Collection<array-key, PushSubscription> $subscriptions
56+
* @param Collection<array-key, PushSubscription> $subscriptions
6057
*/
6158
protected function handleReports(Generator $reports, Collection $subscriptions, WebPushMessageInterface $message): void
6259
{
6360
foreach ($reports as $report) {
64-
/** @var \Minishlink\WebPush\MessageSentReport $report */
61+
/** @var MessageSentReport $report */
6562
$subscription = $this->findSubscription($subscriptions, $report);
6663

6764
if (filled($subscription)) {
@@ -71,7 +68,7 @@ protected function handleReports(Generator $reports, Collection $subscriptions,
7168
}
7269

7370
/**
74-
* @param \Illuminate\Database\Eloquent\Collection<array-key, PushSubscription> $subscriptions
71+
* @param Collection<array-key, PushSubscription> $subscriptions
7572
*/
7673
protected function findSubscription(Collection $subscriptions, MessageSentReport $report): ?PushSubscription
7774
{

0 commit comments

Comments
 (0)