diff --git a/.gitattributes b/.gitattributes index 525249a..80517fa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,5 @@ /.php-cs-fixer.php export-ignore /CHANGELOG.md export-ignore /README.md export-ignore +/UPGRADE-2.0.md export-ignore /phpunit.xml.dist export-ignore diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e096b92..daa45e2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,26 +9,15 @@ jobs: strategy: fail-fast: true matrix: - php: ['7.2', '7.3', '7.4', '8.0'] - laravel: ['^6.18', '8.*'] + php: ['8.0', '8.1'] + laravel: ['9.*'] composer-flags: ['--prefer-stable'] can-fail: [false] include: - - php: '7.2' - laravel: '^6.18' + - php: '8.0' + laravel: '9.*' composer-flags: '--prefer-stable --prefer-lowest' can-fail: false - - php: '8.1' - laravel: '8.*' - composer-flags: '--prefer-stable' - can-fail: false - - php: '8.1' - laravel: '9.*' - composer-flags: '' - can-fail: true - exclude: - - php: '7.2' - laravel: '8.*' name: "PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 2f3ce41..c23682e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -12,8 +12,8 @@ return (new PhpCsFixer\Config()) ->setRules( [ - '@PHP71Migration' => true, - '@PHP71Migration:risky' => true, + '@PHP81Migration' => true, + '@PHP80Migration:risky' => true, '@PHPUnit84Migration:risky' => true, '@PSR12' => true, '@PSR2' => true, diff --git a/CHANGELOG.md b/CHANGELOG.md index af3a217..b6b9dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,5 @@ # Changelog -## 1.4.0 (2022-01-29) +## 2.0.0 (2022-??-??) -- Added support for Laravel 9 - -## 1.3.0 (2020-11-09) - -- Drop support for Laravel 6.17 and earlier -- Drop support for Laravel 7 -- Allow install on PHP 8 - -## 1.2.0 (2020-09-07) - -- Added support for Laravel 8 - -## 1.1.0 (2020-03-21) - -- Add a notification channel to send SMS messages +- Consult the UPGRADE guide for changes between 1.x and 2.0 diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md new file mode 100644 index 0000000..af9beab --- /dev/null +++ b/UPGRADE-2.0.md @@ -0,0 +1,8 @@ +# Upgrade from 1.x to 2.0 + +The below guide will assist in upgrading from the 1.x versions to 2.0. + +## Package Requirements + +- Laravel 9 or later +- PHP 8.0 or later diff --git a/composer.json b/composer.json index 216945c..f09a4ae 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,16 @@ "description": "Twilio SDK integration for Laravel", "keywords": ["laravel", "twilio"], "require": { - "php": "^7.2 || ^8.0", - "illuminate/support": "^6.18 || ^8.0 || ^9.0", - "twilio/sdk": "^6.0" + "php": "^8.0", + "illuminate/http": "^9.0", + "illuminate/support": "^9.0", + "twilio/sdk": "^6.33" }, "require-dev": { - "guzzlehttp/guzzle": "^6.3 || ^7.0", - "laravel/framework": "^6.18 || ^8.0 || ^9.0", - "orchestra/testbench": "^4.0 || ^6.0 || ^7.0", - "phpunit/phpunit": "^8.5 || ^9.3" + "guzzlehttp/guzzle": "^7.2", + "laravel/framework": "^9.0", + "orchestra/testbench": "^7.0", + "phpunit/phpunit": "^9.5" }, "suggest": { "illuminate/notifications": "To use Laravel's notifications component with this package" diff --git a/docs/client-usage.md b/docs/client-usage.md index da9059a..cafae7c 100644 --- a/docs/client-usage.md +++ b/docs/client-usage.md @@ -110,8 +110,7 @@ TwilioClient::twilio(); This package attempts to create an appropriate `Twilio\Http\Client` for the SDK based on the packages available in your application, using the following preferences: -- If using Laravel 7 and Guzzle is available, a client using [Laravel's HTTP client](https://laravel.com/docs/http-client) is used -- If Guzzle is available, the Twilio SDK's Guzzle client is used -- If neither of the above criteria are met, the Twilio SDK's Curl client is used +- If Guzzle is available, a client using [Laravel's HTTP client](https://laravel.com/docs/http-client) is used +- If Guzzle is not available, the Twilio SDK's Curl client is used If you need to customize the HTTP client used by default in your application, you can extend the `Twilio\Http\Client` service this package creates to use your own HTTP client. diff --git a/docs/connections.md b/docs/connections.md index 6457df3..8884263 100644 --- a/docs/connections.md +++ b/docs/connections.md @@ -56,7 +56,7 @@ class AppServiceProvider extends ServiceProvider { \TwilioClient::extend( 'custom', - function (Container $container): TwilioClientContract { + static function (Container $container): TwilioClientContract { /* * Create a custom client from your application. * diff --git a/docs/index.md b/docs/index.md index 28a187d..66d143c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ -- [Introduction](/open-source/packages/laravel-twilio/docs/1.x/intro) -- [Installation & Setup](/open-source/packages/laravel-twilio/docs/1.x/installation) -- [Using The Client](/open-source/packages/laravel-twilio/docs/1.x/client-usage) -- [Connection Management](/open-source/packages/laravel-twilio/docs/1.x/connections) -- [Notifications](/open-source/packages/laravel-twilio/docs/1.x/notifications) +- [Introduction](/open-source/packages/laravel-twilio/docs/2.x/intro) +- [Installation & Setup](/open-source/packages/laravel-twilio/docs/2.x/installation) +- [Using The Client](/open-source/packages/laravel-twilio/docs/2.x/client-usage) +- [Connection Management](/open-source/packages/laravel-twilio/docs/2.x/connections) +- [Notifications](/open-source/packages/laravel-twilio/docs/2.x/notifications) diff --git a/docs/notifications.md b/docs/notifications.md index e5695f5..d18c01a 100644 --- a/docs/notifications.md +++ b/docs/notifications.md @@ -16,11 +16,9 @@ class User extends Authenticatable /** * Get the notification's delivery channels. * - * @param mixed $notifiable - * - * @return array + * @return string[] */ - public function via($notifiable) + public function via(mixed $notifiable): array { // This application's users can receive notifications by mail and Twilio SMS return ['mail', 'twilio']; @@ -28,12 +26,8 @@ class User extends Authenticatable /** * Get the notification routing information for the Twilio driver. - * - * @param Notification $notification - * - * @return string */ - public function routeNotificationForTwilio($notification) + public function routeNotificationForTwilio(Notification $notification): string { return $this->mobile_number; } @@ -45,6 +39,7 @@ For notifications that support being sent as an SMS, you should define a `toTwil ```php namespace App\Notifications; +use App\Models\User; use Illuminate\Notifications\Notification; final class PasswordExpiredNotification extends Notification @@ -52,13 +47,10 @@ final class PasswordExpiredNotification extends Notification /** * Get the Twilio / SMS representation of the notification. * - * @param mixed $notifiable - * - * @return string + * @param User $notifiable */ - public function toTwilio($notifiable) + public function toTwilio(mixed $notifiable): string { - // The $notifiable in this example is your User model return sprintf('Hello %s, this is a note that the password for your %s account has expired.', $notifiable->name, config('app.name')); } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8c60310..7412eb2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,7 @@ - - + - ./tests/ - - + + src/ - - + + diff --git a/src/ConnectionManager.php b/src/ConnectionManager.php index 4fd8c18..7b57b69 100644 --- a/src/ConnectionManager.php +++ b/src/ConnectionManager.php @@ -14,86 +14,62 @@ class ConnectionManager extends Manager implements TwilioClientContract { /** - * Get a connection instance. - * - * @param string|null $name - * - * @return TwilioClientContract - * * @throws \InvalidArgumentException if the driver cannot be created */ - public function connection(?string $name = null) + public function connection(?string $name = null): TwilioClientContract { return $this->driver($name); } /** * Get the default channel driver name. - * - * @return string */ - public function getDefaultDriver() + public function getDefaultDriver(): string { return $this->config->get('twilio.default', 'twilio'); } /** - * Create a new driver instance. - * * @param string $driver * - * @return TwilioClientContract - * * @throws \InvalidArgumentException if the driver cannot be created */ - protected function createDriver($driver) + protected function createDriver($driver): TwilioClientContract { try { return parent::createDriver($driver); } catch (\InvalidArgumentException $e) { - if ($this->config->has("twilio.connections.$driver")) { - try { - return $this->container->make( - TwilioClient::class, - [ - 'twilio' => $this->container->make( - RestClient::class, - [ - 'username' => $this->config->get("twilio.connections.$driver.sid"), - 'password' => $this->config->get("twilio.connections.$driver.token"), - 'httpClient' => $this->container->make(HttpClient::class), - ] - ), - 'from' => $this->config->get("twilio.connections.$driver.from"), - ] - ); - } catch (ConfigurationException $e) { - throw new \InvalidArgumentException("Driver [$driver] is not correctly configured.", $e->getCode(), $e); - } + if (!$this->config->has("twilio.connections.$driver")) { + throw $e; } - throw $e; + try { + return $this->container->make( + TwilioClient::class, + [ + 'twilio' => $this->container->make( + RestClient::class, + [ + 'username' => $this->config->get("twilio.connections.$driver.sid"), + 'password' => $this->config->get("twilio.connections.$driver.token"), + 'httpClient' => $this->container->make(HttpClient::class), + ] + ), + 'from' => $this->config->get("twilio.connections.$driver.from"), + ] + ); + } catch (ConfigurationException $e) { + throw new \InvalidArgumentException("Driver [$driver] is not correctly configured.", $e->getCode(), $e); + } } } - /** - * Provides access to the REST API client from the Twilio SDK. - * - * @return RestClient - */ public function twilio(): RestClient { return $this->connection()->twilio(); } /** - * Create a call through the Twilio API. - * - * @param string $to The phone number to create a call to. - * @param array $params Optional arguments for the created call. - * - * @return CallInstance - * * @throws TwilioException on Twilio API failure */ public function call(string $to, array $params = []): CallInstance @@ -102,14 +78,6 @@ public function call(string $to, array $params = []): CallInstance } /** - * Send a SMS through the Twilio API. - * - * @param string $to The phone number to send the SMS to. - * @param string $message The message body to send. - * @param array $params Optional arguments for the SMS. - * - * @return MessageInstance - * * @throws TwilioException on Twilio API failure */ public function message(string $to, string $message, array $params = []): MessageInstance diff --git a/src/Contracts/TwilioClient.php b/src/Contracts/TwilioClient.php index 8f9f290..1210e47 100644 --- a/src/Contracts/TwilioClient.php +++ b/src/Contracts/TwilioClient.php @@ -11,19 +11,12 @@ interface TwilioClient { /** * Provides access to the REST API client from the Twilio SDK. - * - * @return Client */ public function twilio(): Client; /** * Create a call through the Twilio API. * - * @param string $to The phone number to create a call to. - * @param array $params Optional arguments for the created call. - * - * @return CallInstance - * * @throws TwilioException on Twilio API failure */ public function call(string $to, array $params = []): CallInstance; @@ -31,12 +24,6 @@ public function call(string $to, array $params = []): CallInstance; /** * Send a SMS through the Twilio API. * - * @param string $to The phone number to send the SMS to. - * @param string $message The message body to send. - * @param array $params Optional arguments for the SMS. - * - * @return MessageInstance - * * @throws TwilioException on Twilio API failure */ public function message(string $to, string $message, array $params = []): MessageInstance; diff --git a/src/Notifications/Channels/TwilioChannel.php b/src/Notifications/Channels/TwilioChannel.php index 18ac3b9..d17473f 100644 --- a/src/Notifications/Channels/TwilioChannel.php +++ b/src/Notifications/Channels/TwilioChannel.php @@ -9,32 +9,14 @@ final class TwilioChannel { - /** - * @var TwilioClient - */ - private $twilio; - - /** - * Creates a new Twilio notification channel. - * - * @param TwilioClient $twilio The Twilio client. - */ - public function __construct(TwilioClient $twilio) + public function __construct(private TwilioClient $twilio) { - $this->twilio = $twilio; } /** - * Send the given notification. - * - * @param mixed $notifiable - * @param Notification $notification - * - * @return MessageInstance|null - * * @throws TwilioException on Twilio API failure */ - public function send($notifiable, Notification $notification): ?MessageInstance + public function send(mixed $notifiable, Notification $notification): ?MessageInstance { $to = $notifiable->routeNotificationFor('twilio', $notification); diff --git a/src/Providers/TwilioProvider.php b/src/Providers/TwilioProvider.php index d49a4e4..611bb35 100644 --- a/src/Providers/TwilioProvider.php +++ b/src/Providers/TwilioProvider.php @@ -21,8 +21,6 @@ final class TwilioProvider extends ServiceProvider implements DeferrableProvider { /** - * Get the services provided by the provider. - * * @return array */ public function provides(): array @@ -35,9 +33,6 @@ public function provides(): array ]; } - /** - * Bootstrap any application services. - */ public function boot(): void { $this->publishes( @@ -48,9 +43,6 @@ public function boot(): void ); } - /** - * Register any application services. - */ public function register(): void { $this->registerConnectionManager(); @@ -60,37 +52,24 @@ public function register(): void $this->mergeConfigFrom(__DIR__ . '/../../config/twilio.php', 'twilio'); } - /** - * Registers the binding for the connection manager. - */ private function registerConnectionManager(): void { $this->app->singleton( ConnectionManager::class, - static function (Application $app): ConnectionManager { - return new ConnectionManager($app); - } + static fn (Application $app): ConnectionManager => new ConnectionManager($app) ); $this->app->alias(ConnectionManager::class, TwilioClient::class); } - /** - * Registers the binding for the HTTP client. - */ private function registerHttpClient(): void { $this->app->bind( TwilioHttpClient::class, static function (Application $app): TwilioHttpClient { - // If Guzzle is installed, then we will either use Laravel's native client or Guzzle directly + // If Guzzle is installed, then we will either use Laravel's native client if (class_exists(Guzzle::class)) { - // Use Laravel's HTTP client if able - if (class_exists(Factory::class)) { - return new LaravelHttpClient($app->make(Factory::class)); - } - - return new GuzzleClient(new Guzzle()); + return new LaravelHttpClient($app->make(Factory::class)); } // Default to the curl client @@ -99,9 +78,6 @@ static function (Application $app): TwilioHttpClient { ); } - /** - * Registers the binding for the notification channel. - */ private function registerNotificationChannel(): void { Notification::resolved(static function (ChannelManager $manager): void { diff --git a/src/Twilio/Http/LaravelHttpClient.php b/src/Twilio/Http/LaravelHttpClient.php index 0541b09..9fdc524 100644 --- a/src/Twilio/Http/LaravelHttpClient.php +++ b/src/Twilio/Http/LaravelHttpClient.php @@ -3,40 +3,17 @@ namespace BabDev\Twilio\Twilio\Http; use Illuminate\Http\Client\Factory; -use Illuminate\Http\Client\PendingRequest; use Twilio\Exceptions\HttpException; use Twilio\Http\Client; use Twilio\Http\Response; final class LaravelHttpClient implements Client { - /** - * @var Factory - */ - private $httpFactory; - - /** - * Instantiate the HTTP client - * - * @param Factory $httpFactory - */ - public function __construct(Factory $httpFactory) + public function __construct(private Factory $httpFactory) { - $this->httpFactory = $httpFactory; } /** - * @param string $method The request method to use - * @param string $url The URI to send the request to - * @param array $params Query parameters for the request - * @param array $data The request body - * @param array $headers Request headers - * @param string|null $user The username to authenticate with - * @param string|null $password The password to authenticate with - * @param int|null $timeout The request timeout - * - * @return Response - * * @throws HttpException if the request cannot be completed */ public function request( @@ -49,7 +26,6 @@ public function request( string $password = null, int $timeout = null ): Response { - /** @var PendingRequest $request */ $request = $this->httpFactory->asForm(); if ($user && $password) { diff --git a/src/TwilioClient.php b/src/TwilioClient.php index c2c6aca..0b8db31 100644 --- a/src/TwilioClient.php +++ b/src/TwilioClient.php @@ -11,45 +11,18 @@ final class TwilioClient implements TwilioClientContract { /** - * @var Client + * @param string $from The default from number to use. */ - private $twilio; - - /** - * @var string - */ - private $from; - - /** - * Creates a new Twilio client instance. - * - * @param Client $twilio The Twilio SDK client. - * @param string $from The default from number to use. - */ - public function __construct(Client $twilio, string $from) + public function __construct(private Client $twilio, private string $from) { - $this->twilio = $twilio; - $this->from = $from; } - /** - * Provides access to the REST API client from the Twilio SDK. - * - * @return Client - */ public function twilio(): Client { return $this->twilio; } /** - * Create a call through the Twilio API. - * - * @param string $to The phone number to create a call to. - * @param array $params Optional arguments for the created call. - * - * @return CallInstance - * * @throws TwilioException on Twilio API failure */ public function call(string $to, array $params = []): CallInstance @@ -62,14 +35,6 @@ public function call(string $to, array $params = []): CallInstance } /** - * Send a SMS through the Twilio API. - * - * @param string $to The phone number to send the SMS to. - * @param string $message The message body to send. - * @param array $params Optional arguments for the SMS. - * - * @return MessageInstance - * * @throws TwilioException on Twilio API failure */ public function message(string $to, string $message, array $params = []): MessageInstance @@ -77,7 +42,7 @@ public function message(string $to, string $message, array $params = []): Messag $params['body'] = $message; // Allows specifying a custom from number with fallback - $params['from'] = $params['from'] ?? $this->from; + $params['from'] ??= $this->from; return $this->twilio()->messages->create($to, $params); } diff --git a/tests/ConnectionManagerTest.php b/tests/ConnectionManagerTest.php index b2cf4fa..6ba6d5b 100644 --- a/tests/ConnectionManagerTest.php +++ b/tests/ConnectionManagerTest.php @@ -9,6 +9,7 @@ use Illuminate\Contracts\Container\Container; use Illuminate\Support\ServiceProvider; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\MockObject\MockObject; use Twilio\Rest\Api\V2010\Account\CallInstance; use Twilio\Rest\Api\V2010\Account\MessageInstance; use Twilio\Rest\Client; @@ -46,8 +47,10 @@ public function testAnUnknownCustomConnectionCausesAnException(): void public function testRetrievingTheSdkClientProxiesThrough(): void { + /** @var MockObject&Client $twilioClient */ $twilioClient = $this->createMock(Client::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('twilio') @@ -57,9 +60,7 @@ public function testRetrievingTheSdkClientProxiesThrough(): void $manager = $this->app->make(ConnectionManager::class); $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($twilioClient, $manager->twilio()); @@ -67,8 +68,10 @@ function (Container $container) use ($client): TwilioClientContract { public function testPlacingACallProxiesThrough(): void { + /** @var MockObject&CallInstance $call */ $call = $this->createMock(CallInstance::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('call') @@ -78,9 +81,7 @@ public function testPlacingACallProxiesThrough(): void $manager = $this->app->make(ConnectionManager::class); $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($call, $manager->call('me', [])); @@ -88,8 +89,10 @@ function (Container $container) use ($client): TwilioClientContract { public function testSendingAMessageProxiesThrough(): void { + /** @var MockObject&MessageInstance $message */ $message = $this->createMock(MessageInstance::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('message') @@ -100,9 +103,7 @@ public function testSendingAMessageProxiesThrough(): void $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($message, $manager->message('me', 'Hello!', [])); diff --git a/tests/Facades/TwilioClientTest.php b/tests/Facades/TwilioClientTest.php index 3f60477..b66d904 100644 --- a/tests/Facades/TwilioClientTest.php +++ b/tests/Facades/TwilioClientTest.php @@ -10,6 +10,7 @@ use Illuminate\Contracts\Container\Container; use Illuminate\Support\ServiceProvider; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\MockObject\MockObject; use Twilio\Rest\Api\V2010\Account\CallInstance; use Twilio\Rest\Api\V2010\Account\MessageInstance; use Twilio\Rest\Client; @@ -44,8 +45,10 @@ public function testAnUnknownCustomConnectionCausesAnException(): void public function testRetrievingTheSdkClientProxiesThrough(): void { + /** @var MockObject&Client $twilioClient */ $twilioClient = $this->createMock(Client::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('twilio') @@ -55,9 +58,7 @@ public function testRetrievingTheSdkClientProxiesThrough(): void $manager = $this->app->make(ConnectionManager::class); $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($twilioClient, \TwilioClient::twilio()); @@ -65,8 +66,10 @@ function (Container $container) use ($client): TwilioClientContract { public function testPlacingACallProxiesThrough(): void { + /** @var MockObject&CallInstance $call */ $call = $this->createMock(CallInstance::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('call') @@ -76,9 +79,7 @@ public function testPlacingACallProxiesThrough(): void $manager = $this->app->make(ConnectionManager::class); $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($call, \TwilioClient::call('me', [])); @@ -86,8 +87,10 @@ function (Container $container) use ($client): TwilioClientContract { public function testSendingAMessageProxiesThrough(): void { + /** @var MockObject&MessageInstance $message */ $message = $this->createMock(MessageInstance::class); + /** @var MockObject&TwilioClientContract $client */ $client = $this->createMock(TwilioClientContract::class); $client->expects($this->once()) ->method('message') @@ -98,9 +101,7 @@ public function testSendingAMessageProxiesThrough(): void $manager->extend( 'twilio', - function (Container $container) use ($client): TwilioClientContract { - return $client; - } + static fn (Container $container): TwilioClientContract => $client ); $this->assertSame($message, \TwilioClient::message('me', 'Hello!', [])); diff --git a/tests/Notifications/Channels/TwilioChannelTest.php b/tests/Notifications/Channels/TwilioChannelTest.php index 987a259..2905d3f 100644 --- a/tests/Notifications/Channels/TwilioChannelTest.php +++ b/tests/Notifications/Channels/TwilioChannelTest.php @@ -23,19 +23,19 @@ public function testANotificationIsSent(): void $notifiable = new class() { use Notifiable; - public function via($notifiable) + public function via(mixed $notifiable): array { return ['twilio']; } - public function routeNotificationForTwilio($notification) + public function routeNotificationForTwilio(Notification $notification): string { return '+19418675309'; } }; $notification = new class() extends Notification { - public function toTwilio($notifiable) + public function toTwilio(mixed $notifiable): string { return 'This is a test'; } @@ -54,19 +54,18 @@ public function testANotificationIsNotSentWhenTheNotifiableDoesNotProvideARecipi $notifiable = new class() { use Notifiable; - public function via($notifiable) + public function via(mixed $notifiable): array { return ['twilio']; } - public function routeNotificationForTwilio($notification): void + public function routeNotificationForTwilio(Notification $notification): void { - } }; $notification = new class() extends Notification { - public function toTwilio($notifiable) + public function toTwilio(mixed $notifiable): string { return 'This is a test'; } @@ -85,19 +84,19 @@ public function testANotificationIsNotSentWhenTheNotificationDoesNotProvideAMess $notifiable = new class() { use Notifiable; - public function via($notifiable) + public function via(mixed $notifiable): array { return ['twilio']; } - public function routeNotificationForTwilio($notification) + public function routeNotificationForTwilio(Notification $notification): string { return '+19418675309'; } }; $notification = new class() extends Notification { - public function toTwilio($notifiable): void + public function toTwilio(mixed $notifiable): void { } }; diff --git a/tests/Twilio/Http/LaravelHttpClientTest.php b/tests/Twilio/Http/LaravelHttpClientTest.php index 145ae81..81713ca 100644 --- a/tests/Twilio/Http/LaravelHttpClientTest.php +++ b/tests/Twilio/Http/LaravelHttpClientTest.php @@ -11,15 +11,6 @@ final class LaravelHttpClientTest extends TestCase { - public static function setUpBeforeClass(): void - { - if (!class_exists(Factory::class)) { - self::markTestSkipped('Test only applies to Laravel 7 or newer.'); - } - - parent::setUpBeforeClass(); - } - public function testARequestCanBeSentToTheTwilioApiWithoutCredentials(): void { $url = 'https://api.twilio.com/2010-04-01/Accounts/SID/Messages.json';