diff --git a/captainhook.json b/captainhook.json deleted file mode 100644 index 871a15f..0000000 --- a/captainhook.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "commit-msg": { - "enabled": true, - "actions": [] - }, - "pre-push": { - "enabled": false, - "actions": [] - }, - "pre-commit": { - "enabled": true, - "actions": [ - { - "action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting", - "options": [], - "conditions": [] - }, - { - "action": "vendor/bin/phpunit", - "options": [], - "conditions": [] - }, - { - "action": "vendor/bin/ecs", - "options": [], - "conditions": [] - }, - { - "action": "vendor/bin/psalm", - "options": [], - "conditions": [] - }, - { - "action": "vendor/bin/phpstan", - "options": [], - "conditions": [] - } - ] - }, - "prepare-commit-msg": { - "enabled": false, - "actions": [] - }, - "post-commit": { - "enabled": false, - "actions": [] - }, - "post-merge": { - "enabled": false, - "actions": [] - }, - "post-checkout": { - "enabled": false, - "actions": [] - }, - "post-rewrite": { - "enabled": false, - "actions": [] - }, - "post-change": { - "enabled": false, - "actions": [] - } -} diff --git a/composer-require-checker.json b/composer-require-checker.json index 9e0e296..6903106 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,5 +1,15 @@ { "symbol-whitelist": [ + "Symfony\\Component\\Mailer\\Bridge\\Amazon\\Transport\\SesTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Google\\Transport\\GmailTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Infobip\\Transport\\InfobipTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Mailchimp\\Transport\\MandrillTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Mailgun\\Transport\\MailgunTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Mailjet\\Transport\\MailjetTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\OhMySmtp\\Transport\\OhMySmtpTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Postmark\\Transport\\PostmarkTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Sendgrid\\Transport\\SendgridTransportFactory", + "Symfony\\Component\\Mailer\\Bridge\\Sendinblue\\Transport\\SendinblueTransportFactory", "yii\\psr\\DynamicLogger" ] } diff --git a/composer.json b/composer.json index aa4f38c..5e582be 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ ], "require": { "php": ">=8.1", - "psr/event-dispatcher": "1.0.0", + "psr/event-dispatcher": "^1.0", "symfony/mailer": "^6.4 || ^7.0", "symfony/mime": "^6.4 || ^7.0", "yiisoft/yii2": ">=2.0.4" @@ -79,4 +79,4 @@ "psalm": "psalm", "test": "phpunit" } -} \ No newline at end of file +} diff --git a/src/Mailer.php b/src/Mailer.php index 044b15e..ef20eb9 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -84,6 +84,7 @@ private function getTransport(): TransportInterface /** * @psalm-suppress UndefinedClass + * @psalm-suppress RedundantConditionGivenDocblockType * @throws InvalidConfigException * @throws \yii\di\NotInstantiableException */ @@ -92,8 +93,9 @@ private function getTransportFactory(): Transport if (isset($this->transportFactory)) { return $this->transportFactory; } + // Use the Yii DI container, if available. - if (isset(\Yii::$container)) { + if (isset(Yii::$container)) { $factories = []; foreach ([ NullTransportFactory::class, @@ -114,13 +116,13 @@ private function getTransportFactory(): Transport if (!class_exists($factoryClass)) { continue; } - $factories[] = \Yii::$container->get($factoryClass); + $factories[] = Yii::$container->get($factoryClass); } } else { $factories = Transport::getDefaultFactories(); } - /** @psalm-suppress InvalidArgument Symfony's type annotation is wrong */ + /** @psalm-var array $factories */ return new Transport($factories); } @@ -154,7 +156,7 @@ private function createTransport(array $config = []): TransportInterface } /** - * @param MessageWrapperInterface&MessageInterface $message + * @param MessageInterface|MessageWrapperInterface $message * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface */ protected function sendMessage($message): bool diff --git a/tests/MailerTest.php b/tests/MailerTest.php index c344881..6ab0996 100644 --- a/tests/MailerTest.php +++ b/tests/MailerTest.php @@ -169,7 +169,7 @@ public function testSendMessageThrowsOnBadMessageType(): void public function testDiContainer(): void { - \Yii::$container = new Container(); + Yii::$container = new Container(); $dispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); $dispatcherCreator = $this @@ -180,7 +180,7 @@ public function testDiContainer(): void $dispatcherCreator ->expects(self::atLeastOnce()) ->method('__invoke')->willReturn($dispatcherMock); - \Yii::$container->set(EventDispatcherInterface::class, $dispatcherCreator); + Yii::$container->set(EventDispatcherInterface::class, $dispatcherCreator); $mailer = new Mailer();