Skip to content

Commit d5b80b3

Browse files
committed
Merge remote-tracking branch 'origin/master' into contributor-master
2 parents 9509d2e + ff792c3 commit d5b80b3

25 files changed

+234
-313
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,14 @@ jobs:
1111
strategy:
1212
fail-fast: true
1313
matrix:
14-
php: [8.3, 8.2, 8.1]
15-
laravel: [9.*, 10.*, 11.*]
14+
php: [8.4, 8.3, 8.2]
15+
laravel: ['11.*', '12.*']
1616
stability: [prefer-lowest, prefer-stable]
1717
include:
1818
- laravel: 11.*
19-
testbench: 9.*
20-
- laravel: 10.*
21-
testbench: 8.*
22-
- laravel: 9.*
23-
testbench: ^7.19
24-
exclude:
25-
# Laravel 11 doesn't support PHP 8.1
26-
- laravel: 11.*
27-
php: 8.1
28-
# Laravel 9 doesn't support PHP 8.3
29-
- laravel: 10.*
30-
php: 8.3
19+
testbench: ^9.2
20+
- laravel: 12.*
21+
testbench: 10.*
3122

3223
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}
3324

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ tests/temp
44
composer.phar
55
composer.lock
66
.phpunit.result.cache
7+
.phpunit.cache
8+
.phpstan.cache

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All Notable changes to `laravel-notification-channels/webpush` will be documented in this file
44

5+
## 10.0.0 - 2025-02-26
6+
- Adds support for Laravel 12, drops support for Laravel 9 and 10, drops support for PHP 8.1 [#208](https://github.com/laravel-notification-channels/webpush/pull/208)
7+
- Adds native types [#209](https://github.com/laravel-notification-channels/webpush/pull/209) - if you override functions or implement interfaces of this package, please note that you might need to change method signatures
8+
9+
## 9.0.0 - 2024-07-10
10+
- Update web-push library to v9
11+
512
## 8.0.0 - 2024-03-16
613

714
- Added support for Laravel 11.

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@
99
"email": "[email protected]",
1010
"homepage": "http://cretueusebiu.com",
1111
"role": "Developer"
12+
},
13+
{
14+
"name": "Joost de Bruijn",
15+
"email": "[email protected]",
16+
"role": "Maintainer"
1217
}
1318
],
1419
"require": {
15-
"php": "^8.1",
16-
"illuminate/notifications": "^9.0|^10.0|^11.0",
17-
"illuminate/support": "^9.0|^10.0|^11.0",
20+
"php": "^8.2",
21+
"illuminate/notifications": "^11.0|^12.0",
22+
"illuminate/support": "^11.0|^12.0",
1823
"minishlink/web-push": "^9.0"
1924
},
2025
"require-dev": {
21-
"mockery/mockery": "~1.0",
22-
"orchestra/testbench": "^7.0|^8.0|^9.0",
23-
"phpunit/phpunit": "^9.5|^10.5"
26+
"laravel/pint": "^1.21",
27+
"mockery/mockery": "^1.0",
28+
"orchestra/testbench": "^9.2|^10.0",
29+
"larastan/larastan": "^3.1",
30+
"phpunit/phpunit": "^10.5|^11.5.3",
31+
"rector/rector": "^2.0"
2432
},
2533
"autoload": {
2634
"psr-4": {

phpstan-baseline.neon

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Method NotificationChannels\\WebPush\\PushSubscription\:\:findByEndpoint\(\) should return static\(NotificationChannels\\WebPush\\PushSubscription\)\|null but returns NotificationChannels\\WebPush\\PushSubscription\|null\.$#'
5+
identifier: return.type
6+
count: 1
7+
path: src/PushSubscription.php
8+
9+
-
10+
message: '#^Method NotificationChannels\\WebPush\\Test\\User\:\:pushSubscriptions\(\) should return Illuminate\\Database\\Eloquent\\Relations\\MorphMany\<NotificationChannels\\WebPush\\PushSubscription, \$this\(NotificationChannels\\WebPush\\Test\\User\)\> but returns Illuminate\\Database\\Eloquent\\Relations\\MorphMany\<Illuminate\\Database\\Eloquent\\Model, \$this\(NotificationChannels\\WebPush\\Test\\User\)\>\.$#'
11+
identifier: return.type
12+
count: 1
13+
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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
includes:
2+
- ./vendor/larastan/larastan/extension.neon
3+
- ./phpstan-baseline.neon
4+
5+
parameters:
6+
7+
paths:
8+
- src
9+
- tests
10+
- migrations/create_push_subscriptions_table.php.stub
11+
12+
level: 6
13+
14+
tmpDir: .phpstan.cache

rector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Rector\Config\RectorConfig;
4+
5+
return RectorConfig::configure()
6+
->withPaths([
7+
__DIR__.'/src',
8+
__DIR__.'/tests',
9+
])
10+
->withPreparedSets(
11+
deadCode: true,
12+
codeQuality: true,
13+
codingStyle: true,
14+
typeDeclarations: true,
15+
)
16+
->withPhpSets(php82: true);

src/Events/NotificationFailed.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,21 @@
33
namespace NotificationChannels\WebPush\Events;
44

55
use Illuminate\Queue\SerializesModels;
6+
use Minishlink\WebPush\MessageSentReport;
7+
use NotificationChannels\WebPush\PushSubscription;
8+
use NotificationChannels\WebPush\WebPushMessage;
69

710
class NotificationFailed
811
{
912
use SerializesModels;
1013

11-
/**
12-
* @var \Minishlink\WebPush\MessageSentReport
13-
*/
14-
public $report;
15-
16-
/**
17-
* @var \NotificationChannels\WebPush\PushSubscription
18-
*/
19-
public $subscription;
20-
21-
/**
22-
* @var \NotificationChannels\WebPush\WebPushMessage
23-
*/
24-
public $message;
25-
2614
/**
2715
* Create a new event instance.
2816
*
29-
* @param \Minishlink\WebPush\MessageSentReport $report
30-
* @param \NotificationChannels\WebPush\PushSubscription $subscription
31-
* @param \NotificationChannels\WebPush\WebPushMessage $message
3217
* @return void
3318
*/
34-
public function __construct($report, $subscription, $message)
19+
public function __construct(public MessageSentReport $report, public PushSubscription $subscription, public WebPushMessage $message)
3520
{
36-
$this->report = $report;
37-
$this->subscription = $subscription;
38-
$this->message = $message;
21+
//
3922
}
4023
}

src/Events/NotificationSent.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,21 @@
33
namespace NotificationChannels\WebPush\Events;
44

55
use Illuminate\Queue\SerializesModels;
6+
use Minishlink\WebPush\MessageSentReport;
7+
use NotificationChannels\WebPush\PushSubscription;
8+
use NotificationChannels\WebPush\WebPushMessage;
69

710
class NotificationSent
811
{
912
use SerializesModels;
1013

11-
/**
12-
* @var \Minishlink\WebPush\MessageSentReport
13-
*/
14-
public $report;
15-
16-
/**
17-
* @var \NotificationChannels\WebPush\PushSubscription
18-
*/
19-
public $subscription;
20-
21-
/**
22-
* @var \NotificationChannels\WebPush\WebPushMessage
23-
*/
24-
public $message;
25-
2614
/**
2715
* Create a new event instance.
2816
*
29-
* @param \Minishlink\WebPush\MessageSentReport $report
30-
* @param \NotificationChannels\WebPush\PushSubscription $subscription
31-
* @param \NotificationChannels\WebPush\WebPushMessage $message
3217
* @return void
3318
*/
34-
public function __construct($report, $subscription, $message)
19+
public function __construct(public MessageSentReport $report, public PushSubscription $subscription, public WebPushMessage $message)
3520
{
36-
$this->report = $report;
37-
$this->subscription = $subscription;
38-
$this->message = $message;
21+
//
3922
}
4023
}

src/HasPushSubscriptions.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22

33
namespace NotificationChannels\WebPush;
44

5+
use Illuminate\Database\Eloquent\Collection;
6+
use Illuminate\Database\Eloquent\Relations\MorphMany;
7+
58
trait HasPushSubscriptions
69
{
710
/**
811
* Get all of the subscriptions.
912
*
10-
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
13+
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<PushSubscription, $this>
1114
*/
12-
public function pushSubscriptions()
15+
public function pushSubscriptions(): MorphMany
1316
{
1417
return $this->morphMany(config('webpush.model'), 'subscribable');
1518
}
1619

1720
/**
1821
* Update (or create) subscription.
19-
*
20-
* @param string $endpoint
21-
* @param string|null $key
22-
* @param string|null $token
23-
* @param string|null $contentEncoding
24-
* @return \NotificationChannels\WebPush\PushSubscription
2522
*/
26-
public function updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null)
23+
public function updatePushSubscription(string $endpoint, ?string $key = null, ?string $token = null, ?string $contentEncoding = null): PushSubscription
2724
{
2825
$subscription = app(config('webpush.model'))->findByEndpoint($endpoint);
2926

@@ -50,23 +47,17 @@ public function updatePushSubscription($endpoint, $key = null, $token = null, $c
5047

5148
/**
5249
* Determine if the model owns the given subscription.
53-
*
54-
* @param \NotificationChannels\WebPush\PushSubscription $subscription
55-
* @return bool
5650
*/
57-
public function ownsPushSubscription($subscription)
51+
public function ownsPushSubscription(PushSubscription $subscription): bool
5852
{
5953
return (string) $subscription->subscribable_id === (string) $this->getKey() &&
6054
$subscription->subscribable_type === $this->getMorphClass();
6155
}
6256

6357
/**
6458
* Delete subscription by endpoint.
65-
*
66-
* @param string $endpoint
67-
* @return void
6859
*/
69-
public function deletePushSubscription($endpoint)
60+
public function deletePushSubscription(string $endpoint): void
7061
{
7162
$this->pushSubscriptions()
7263
->where('endpoint', $endpoint)
@@ -76,9 +67,9 @@ public function deletePushSubscription($endpoint)
7667
/**
7768
* Get all of the subscriptions.
7869
*
79-
* @return \Illuminate\Database\Eloquent\Collection
70+
* @return \Illuminate\Database\Eloquent\Collection<array-key, \NotificationChannels\WebPush\PushSubscription>
8071
*/
81-
public function routeNotificationForWebPush()
72+
public function routeNotificationForWebPush(): Collection
8273
{
8374
return $this->pushSubscriptions;
8475
}

0 commit comments

Comments
 (0)