diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5163d90..50c9b21 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -14,37 +14,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - php: [7.4, 8.0, 8.1, '8.2'] - laravel: ['7.*', '8.*', '9.*', '10.*', '11.*'] + php: [8.3, 8.2] + laravel: ['11.*', '10.*'] stability: [prefer-lowest, prefer-stable] include: - laravel: 10.* testbench: 8.* - - laravel: 9.* - testbench: 7.* - - laravel: 8.* - testbench: ^6.24.1 - - laravel: 7.* - testbench: ^5.20.0 - laravel: 11.* testbench: 9.* - exclude: - - laravel: 10.* - php: 8.0 - - laravel: 10.* - php: 7.4 - - laravel: 9.* - php: 7.4 - - laravel: 7.* - php: 8.0 - - laravel: 7.* - php: 8.1 - - laravel: 11.* - php: 7.4 - - laravel: 11.* - php: 8.0 - - laravel: 11.* - php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index f3adeda..382ba6b 100755 --- a/composer.json +++ b/composer.json @@ -17,16 +17,16 @@ } ], "require": { - "php": "^8.0|^7.4", - "illuminate/contracts": "9.*|8.*|7.*|^10.0|^11.0" + "php": "^8.2", + "illuminate/contracts": "^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^6.24.1|^v5.20.0|^8.0|^9.0", - "phpunit/phpunit": "^9.5.13|^8.3|^9.5.10|^10.5", - "nunomaduro/collision": "^6.0|^5.0|^8.0", - "nunomaduro/larastan": "^2.0|^1.0", + "orchestra/testbench": "^8.0|^9.0", + "phpunit/phpunit": "^9.5.10|^10.5", + "nunomaduro/collision": "^6.0|^8.0", + "larastan/larastan": "^2.0", "pestphp/pest": "^1.21|^2.34", - "pestphp/pest-plugin-laravel": "^1.1|^2.3", + "pestphp/pest-plugin-laravel": "^2.3", "phpstan/extension-installer": "^1.1", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", diff --git a/src/Channels/SubscriberMailChannel.php b/src/Channels/SubscriberMailChannel.php index 37aa688..3f4982e 100644 --- a/src/Channels/SubscriberMailChannel.php +++ b/src/Channels/SubscriberMailChannel.php @@ -25,8 +25,7 @@ class SubscriberMailChannel extends MailChannel * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification - * - * @return void + * @return \Illuminate\Mail\SentMessage|null */ public function send($notifiable, Notification $notification) { @@ -35,7 +34,7 @@ public function send($notifiable, Notification $notification) $notification instanceof CheckNotifiableSubscriptionStatus && $notification->checkMailSubscriptionStatus() && ! $notifiable->mailSubscriptionStatus($notification)) { - return; + return null; } if (method_exists($notification, 'toMail')) { @@ -56,16 +55,16 @@ public function send($notifiable, Notification $notification) if (! $notifiable->routeNotificationFor('mail', $notification) && ! $message instanceof Mailable) { - return; + return null; } if ($message instanceof Mailable) { $message->send($this->mailer); - return; + return null; } - $this->mailer->mailer($message->mailer ?? null)->send( + return $this->mailer->mailer($message->mailer ?? null)->send( $this->buildView($message), array_merge($message->data(), $this->additionalMessageData($notification)), $this->messageBuilder($notifiable, $notification, $message) diff --git a/src/Facades/Subscriber.php b/src/Facades/Subscriber.php index 8b07a99..93776a8 100644 --- a/src/Facades/Subscriber.php +++ b/src/Facades/Subscriber.php @@ -12,7 +12,7 @@ * * @method static void routes() * @method static string routeName() - * @method static userModel(string $model = null) + * @method static mixed userModel(string $model = null) * @method static void onCompletion(callable|string $handler) * @method static void onUnsubscribeFromMailingList(callable|string $handler) * @method static void onUnsubscribeFromAllMailingLists(callable|string $handler) diff --git a/src/SubscribableApplicationServiceProvider.php b/src/SubscribableApplicationServiceProvider.php index 7091a4c..86fdac0 100644 --- a/src/SubscribableApplicationServiceProvider.php +++ b/src/SubscribableApplicationServiceProvider.php @@ -22,7 +22,9 @@ public function boot() $this->loadRoutes(); } - \YlsIdeas\SubscribableNotifications\Facades\Subscriber::userModel($this->userModel()); + \YlsIdeas\SubscribableNotifications\Facades\Subscriber::userModel( + $this->userModel() + ); \YlsIdeas\SubscribableNotifications\Facades\Subscriber::onUnsubscribeFromMailingList( $this->onUnsubscribeFromMailingList() diff --git a/src/Subscriber.php b/src/Subscriber.php index 11b2a6b..9d73b40 100644 --- a/src/Subscriber.php +++ b/src/Subscriber.php @@ -176,22 +176,15 @@ public function checkSubscriptionStatus($user, ?string $mailingList = null) return (bool) call_user_func($this->onCheckSubscriptionStatusForAllMailingLists, $user); } - /** - * @param string|callable $handler - * @return callable - * @throws \Illuminate\Contracts\Container\BindingResolutionException - */ - protected function parseHandler($handler) + protected function parseHandler(string|callable$handler): callable { if (is_string($handler)) { $parsed = Str::parseCallback($handler); $parsed[0] = $this->app->make($parsed[0]); return $parsed; - } elseif (is_callable($handler)) { - return $handler; } - throw new InvalidArgumentException('Handler argument must be either a string or callable.'); + return $handler; } } diff --git a/tests/SubscriberTest.php b/tests/SubscriberTest.php index 328cb12..675e37a 100755 --- a/tests/SubscriberTest.php +++ b/tests/SubscriberTest.php @@ -291,19 +291,6 @@ public function it_handles_checking_subscription_status_of_all_mailing_lists_via $this->assertTrue($subscriber->checkSubscriptionStatus($expectedUser)); } - /** @test */ - public function it_handles_type_checks_for_a_callable_or_string_handler() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Handler argument must be either a string or callable.'); - - $subscriber = new Subscriber($this->app); - - $subscriber->onCompletion( - new \stdClass() - ); - } - /** @test */ public function it_can_provide_a_user_model() {