rectorphp/rector-symfony

SwiftSetBodyToHtmlPlainMethodCallRector example makes use of ->text but inside code it uses ->plain which afaik doesnt exist

torian257x opened this issue ยท 5 comments

->plain doesnt exist see https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Mime/Email.php

->text does

other things seem to be wrong too like still handing second argument.

Hi, thanks for noticing. Could you send a fix to this rule?

Looks like the initial plan was to replace a Swift_Message with an Email, but things got misaligned.

The current rule cannot be used for such a replacement because there are more stones to be moved.

<?php

$message = (new Swift_Message())
    ->setSubject('Your subject')
    ->setFrom(['john@doe.com' => 'John Doe'])
    ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
    ->setBody('Here is the message itself')
?>
-----
<?php

$message = (new \Symfony\Component\Mime\Email())
    ->subject('Your subject')
    ->from(new \Symfony\Component\Mime\Address('john@doe.com', 'John Doe'))
    ->to(...['receiver@domain.org', new \Symfony\Component\Mime\Address('other@domain.org', 'A name')])
    ->text('Here is the message itself')
?>

yeah... no... swift mailer and symfony mailer are just too incompatible for our project.

attachments etc etc we refactored by hand into a service so we wont have to do this ever again.

@TomasVotruba i think conclusion is to close this issue

@JohJohan Thanks for update ๐Ÿ‘ Closing then