From d43d5d82422722c40562b7702ea9d84eabac636c Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 1 Nov 2023 12:08:50 +0100 Subject: [PATCH 1/4] TASK: Declare compatible with Flow 9.x Also raise minimum Flow version to 8.3. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b369496..0a78707 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "MIT" ], "require": { - "neos/flow": "^5.2 || ^6.0 || ^7.0 || ^8.0 ||dev-master", - "swiftmailer/swiftmailer": "^6.0" + "neos/flow": "^8.3 || ^9.0 || dev-main", + "swiftmailer/swiftmailer": "^6.2.5" }, "autoload": { "psr-4": { From 97a327b14508f520cd5cda6a51b6a18b1a03d14d Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 1 Nov 2023 12:22:06 +0100 Subject: [PATCH 2/4] TASK: Add (strict) typing --- Classes/Command/EmailCommandController.php | 2 +- Classes/Mailer.php | 2 ++ Classes/MailerInterface.php | 2 +- Classes/Message.php | 6 +++--- Classes/Transport/LoggingTransport.php | 4 ++-- Classes/Transport/MboxTransport.php | 4 ++-- Migrations/Code/Version20161130105617.php | 5 +++-- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Classes/Command/EmailCommandController.php b/Classes/Command/EmailCommandController.php index d5149dd..ca6ccdb 100644 --- a/Classes/Command/EmailCommandController.php +++ b/Classes/Command/EmailCommandController.php @@ -28,7 +28,7 @@ class EmailCommandController extends CommandController * @param string $contentType The body content type of the message (Default: test/plain) * @param string $charset The body charset of the message (Default: UTF8) */ - public function sendCommand(string $from, string $to, string $subject, string $body = '', string $contentType = 'text/plain', $charset = 'UTF8'): void + public function sendCommand(string $from, string $to, string $subject, string $body = '', string $contentType = 'text/plain', string $charset = 'UTF8'): void { $message = (new Message()) ->setFrom($from) diff --git a/Classes/Mailer.php b/Classes/Mailer.php index ac3a487..20b7f32 100644 --- a/Classes/Mailer.php +++ b/Classes/Mailer.php @@ -1,4 +1,6 @@ generateId(); diff --git a/Migrations/Code/Version20161130105617.php b/Migrations/Code/Version20161130105617.php index 99536f7..26da176 100644 --- a/Migrations/Code/Version20161130105617.php +++ b/Migrations/Code/Version20161130105617.php @@ -1,4 +1,5 @@ searchAndReplace('TYPO3\SwiftMailer', 'Neos\SwiftMailer'); $this->searchAndReplace('TYPO3.SwiftMailer', 'Neos.SwiftMailer'); From 1e3ac668b9d47abbd1ec2cc6b3c821a8f7813559 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 1 Nov 2023 12:22:40 +0100 Subject: [PATCH 3/4] TASK: Clean up source comments --- Classes/Command/EmailCommandController.php | 2 +- Classes/MailerInterface.php | 9 -------- Classes/Message.php | 9 -------- Classes/Transport/LoggingTransport.php | 24 +-------------------- Classes/Transport/MboxTransport.php | 25 ++-------------------- Classes/TransportFactory.php | 4 ---- 6 files changed, 4 insertions(+), 69 deletions(-) diff --git a/Classes/Command/EmailCommandController.php b/Classes/Command/EmailCommandController.php index ca6ccdb..f93bcc0 100644 --- a/Classes/Command/EmailCommandController.php +++ b/Classes/Command/EmailCommandController.php @@ -25,7 +25,7 @@ class EmailCommandController extends CommandController * @param string $to The to address of the message * @param string $subject The subject of the message * @param string $body The body of the message - * @param string $contentType The body content type of the message (Default: test/plain) + * @param string $contentType The body content type of the message (Default: text/plain) * @param string $charset The body charset of the message (Default: UTF8) */ public function sendCommand(string $from, string $to, string $subject, string $body = '', string $contentType = 'text/plain', string $charset = 'UTF8'): void diff --git a/Classes/MailerInterface.php b/Classes/MailerInterface.php index 7d15e88..9750a47 100644 --- a/Classes/MailerInterface.php +++ b/Classes/MailerInterface.php @@ -29,25 +29,16 @@ interface MailerInterface * * The return value is the number of recipients who were accepted for * delivery. - * - * @param \Swift_Mime_SimpleMessage $message - * @param array $failedRecipients An array of failures by-reference - * @return int */ public function send(\Swift_Mime_SimpleMessage $message, array &$failedRecipients = null); /** * Register a plugin using a known unique key (e.g. myPlugin). - * - * @param \Swift_Events_EventListener $plugin - * @return void */ public function registerPlugin(\Swift_Events_EventListener $plugin); /** * The Transport used to send messages. - * - * @return \Swift_Transport */ public function getTransport(); } diff --git a/Classes/Message.php b/Classes/Message.php index ecb0dc4..82e29d3 100644 --- a/Classes/Message.php +++ b/Classes/Message.php @@ -25,21 +25,16 @@ class Message extends \Swift_Message { /** * @Flow\Inject - * @var \Neos\SwiftMailer\MailerInterface */ protected MailerInterface $mailer; /** * True if the message has been sent. - * - * @var bool */ protected bool $sent = false; /** * Holds the failed recipients after the message has been sent - * - * @var array */ protected array $failedRecipients = []; @@ -57,8 +52,6 @@ public function send(): int /** * Checks whether the message has been sent. - * - * @return bool */ public function isSent(): bool { @@ -67,8 +60,6 @@ public function isSent(): bool /** * Returns the recipients for which the mail was not accepted for delivery. - * - * @return array the recipients who were not accepted for delivery */ public function getFailedRecipients(): array { diff --git a/Classes/Transport/LoggingTransport.php b/Classes/Transport/LoggingTransport.php index 6e5e7b1..41541ae 100644 --- a/Classes/Transport/LoggingTransport.php +++ b/Classes/Transport/LoggingTransport.php @@ -26,21 +26,16 @@ class LoggingTransport implements TransportInterface { /** * Store sent messages for testing - * - * @var array */ protected static array $deliveredMessages = []; /** * @Flow\Inject - * @var LoggerInterface */ protected LoggerInterface $logger; /** * The logging transport is always started - * - * @return bool Always true for this transport */ public function isStarted(): bool { @@ -49,8 +44,6 @@ public function isStarted(): bool /** * No op - * - * @return void */ public function start(): void { @@ -58,8 +51,6 @@ public function start(): void /** * No op - * - * @return void */ public function stop(): void { @@ -68,10 +59,6 @@ public function stop(): void /** * "Send" the given Message. This transport will add it to a stored collection of sent messages * for testing purposes and log the message to the system logger. - * - * @param \Swift_Mime_SimpleMessage $message The message to send - * @param array &$failedRecipients Failed recipients - * @return int */ public function send(\Swift_Mime_SimpleMessage $message, &$failedRecipients = null): int { @@ -106,9 +93,6 @@ protected function buildStringFromEmailAndNameArray(array $addresses): string /** * No op - * - * @param \Swift_Events_EventListener $plugin - * @return void */ public function registerPlugin(\Swift_Events_EventListener $plugin): void { @@ -116,8 +100,6 @@ public function registerPlugin(\Swift_Events_EventListener $plugin): void /** * Get delivered messages that were sent through this transport - * - * @return array */ public static function getDeliveredMessages(): array { @@ -126,8 +108,6 @@ public static function getDeliveredMessages(): array /** * Reset the delivered messages (e.g. for tearDown in functional test) - * - * @return void */ public static function reset(): void { @@ -135,9 +115,7 @@ public static function reset(): void } /** - * Check if this Transport mechanism is alive. - * - * @return bool Always true for this transport + * This Transport mechanism is always alive. */ public function ping(): bool { diff --git a/Classes/Transport/MboxTransport.php b/Classes/Transport/MboxTransport.php index 05ff7d1..76ec585 100644 --- a/Classes/Transport/MboxTransport.php +++ b/Classes/Transport/MboxTransport.php @@ -24,15 +24,12 @@ class MboxTransport implements TransportInterface { /** - * @var string The file to write the mails into + * The file to write the mails into */ protected string $mboxPathAndFilename; /** * Set path and filename of mbox file to use. - * - * @param string $mboxPathAndFilename - * @return void */ public function setMboxPathAndFilename(string $mboxPathAndFilename): void { @@ -41,8 +38,6 @@ public function setMboxPathAndFilename(string $mboxPathAndFilename): void /** * The mbox transport is always started - * - * @return boolean Always TRUE for this transport */ public function isStarted(): bool { @@ -51,8 +46,6 @@ public function isStarted(): bool /** * No op - * - * @return void */ public function start(): void { @@ -60,8 +53,6 @@ public function start(): void /** * No op - * - * @return void */ public function stop(): void { @@ -69,10 +60,6 @@ public function stop(): void /** * Outputs the mail to a text file according to RFC 4155. - * - * @param \Swift_Mime_SimpleMessage $message The message to send - * @param array &$failedRecipients Failed recipients (no failures in this transport) - * @return int */ public function send(\Swift_Mime_SimpleMessage $message, &$failedRecipients = null): int { @@ -96,9 +83,6 @@ public function send(\Swift_Mime_SimpleMessage $message, &$failedRecipients = nu /** * Determine the best-use reverse path for this message - * - * @param \Swift_Mime_SimpleMessage $message - * @return string|null */ private function getReversePath(\Swift_Mime_SimpleMessage $message): string { @@ -123,18 +107,13 @@ private function getReversePath(\Swift_Mime_SimpleMessage $message): string /** * No op - * - * @param \Swift_Events_EventListener $plugin - * @return void */ public function registerPlugin(\Swift_Events_EventListener $plugin): void { } /** - * Check if this Transport mechanism is alive. - * - * @return bool Always true for this transport + * This Transport mechanism is always alive. */ public function ping(): bool { diff --git a/Classes/TransportFactory.php b/Classes/TransportFactory.php index d07a320..cbab610 100644 --- a/Classes/TransportFactory.php +++ b/Classes/TransportFactory.php @@ -24,10 +24,6 @@ class TransportFactory /** * Factory method which creates the specified transport with the given options. * - * @param string $transportType Object name of the transport to create - * @param array $transportOptions Options for the transport - * @param array $transportArguments Constructor arguments for the transport - * @return \Swift_Transport The created transport instance * @throws Exception * @throws \ReflectionException */ From 4c9534448a167a62302bdef013e7f348b491a2d7 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 1 Nov 2023 12:23:02 +0100 Subject: [PATCH 4/4] TASK: Rename a variable to be more speaking --- Classes/TransportFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/TransportFactory.php b/Classes/TransportFactory.php index cbab610..dd4e47a 100644 --- a/Classes/TransportFactory.php +++ b/Classes/TransportFactory.php @@ -27,15 +27,15 @@ class TransportFactory * @throws Exception * @throws \ReflectionException */ - public function create(string $transportType, array $transportOptions = [], array $transportArguments = null): \Swift_Transport + public function create(string $transportType, array $transportOptions = [], array $transportConstructorArguments = null): \Swift_Transport { if (!class_exists($transportType)) { throw new Exception(sprintf('The specified transport backend "%s" does not exist.', $transportType), 1269351207); } - if (is_array($transportArguments)) { + if (is_array($transportConstructorArguments)) { $class = new \ReflectionClass($transportType); - $transport = $class->newInstanceArgs($transportArguments); + $transport = $class->newInstanceArgs($transportConstructorArguments); } else { $transport = new $transportType(); }