Skip to content

Commit

Permalink
Separating Swiftmailer to Symfony Mailer from Symfony 5.3 set (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefantalen authored Dec 14, 2023
1 parent 38014d4 commit b7df4d8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
27 changes: 27 additions & 0 deletions config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Symfony\Symfony53\Rector\MethodCall\SwiftCreateMessageToNewEmailRector;
use Rector\Symfony\Symfony53\Rector\MethodCall\SwiftSetBodyToHtmlPlainMethodCallRector;

return static function (RectorConfig $rectorConfig): void {
// @see https://symfony.com/blog/the-end-of-swiftmailer
$rectorConfig->rules([
SwiftCreateMessageToNewEmailRector::class,
SwiftSetBodyToHtmlPlainMethodCallRector::class,
]);

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'Swift_Mailer' => 'Symfony\Component\Mailer\MailerInterface',
'Swift_Message' => 'Symfony\Component\Mime\Email',
// message
'Swift_Mime_SimpleMessage' => 'Symfony\Component\Mime\RawMessage',
// transport
'Swift_SmtpTransport' => 'Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport',
'Swift_FailoverTransport' => 'Symfony\Component\Mailer\Transport\FailoverTransport',
'Swift_SendmailTransport' => 'Symfony\Component\Mailer\Transport\SendmailTransport',
]);
};
16 changes: 0 additions & 16 deletions config/sets/symfony/symfony53.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Rector\Renaming\ValueObject\RenameClassConstFetch;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Symfony53\Rector\Class_\CommandDescriptionToPropertyRector;
use Rector\Symfony\Symfony53\Rector\MethodCall\SwiftCreateMessageToNewEmailRector;
use Rector\Symfony\Symfony53\Rector\MethodCall\SwiftSetBodyToHtmlPlainMethodCallRector;
use Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
Expand Down Expand Up @@ -115,19 +113,5 @@
$rectorConfig->rules([
KernelTestCaseContainerPropertyDeprecationRector::class,
CommandDescriptionToPropertyRector::class,
// @see https://symfony.com/blog/the-end-of-swiftmailer
SwiftCreateMessageToNewEmailRector::class,
SwiftSetBodyToHtmlPlainMethodCallRector::class,
]);

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'Swift_Mailer' => 'Symfony\Component\Mailer\MailerInterface',
'Swift_Message' => 'Symfony\Component\Mime\Email',
// message
'Swift_Mime_SimpleMessage' => 'Symfony\Component\Mime\RawMessage',
// transport
'Swift_SmtpTransport' => 'Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport',
'Swift_FailoverTransport' => 'Symfony\Component\Mailer\Transport\FailoverTransport',
'Swift_SendmailTransport' => 'Symfony\Component\Mailer\Transport\SendmailTransport',
]);
};
18 changes: 18 additions & 0 deletions src/Set/SwiftmailerSetList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Set;

use Rector\Set\Contract\SetListInterface;

/**
* @api
*/
final class SwiftmailerSetList implements SetListInterface
{
/**
* @var string
*/
final public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/swiftmailer/swiftmailer-to-symfony-mailer.php';
}

0 comments on commit b7df4d8

Please sign in to comment.