Skip to content

Commit

Permalink
Deprecate uasge of SenderInterface without CC and BCC
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 23, 2022
1 parent 626e77c commit 8b9adbd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTagTypeFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symplify\EasyCodingStandard\Config\ECSConfig;
Expand All @@ -25,6 +26,7 @@
PhpdocTagTypeFixer::class,
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
VisibilityRequiredFixer::class => ['*Spec.php'],
NoSuperfluousPhpdocTagsFixer::class => ['src/Component/Sender/SenderInterface.php'],
'**/var/*',
'src/Bundle/test/app/AppKernel.php',
]);
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ parameters:
- '/Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\./'
- '/Cannot call method has\(\) on object\|null/'
- '/Property Sylius\\Component\\Mailer\\Model\\Email\:\:\$id is never written\, only read\./'
- '/PHPDoc tag \@param references unknown parameter\: \$bccRecipients/'
- '/PHPDoc tag \@param references unknown parameter\: \$ccRecipients/'
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</projectFiles>

<issueHandlers>
<InvalidDocblockParamName>
<errorLevel type="suppress">
<file name="src/Component/Sender/SenderInterface.php" />
</errorLevel>
</InvalidDocblockParamName>

<PossiblyNullReference>
<errorLevel type="suppress">
<file name="src/Bundle/DependencyInjection/Configuration.php" />
Expand Down
8 changes: 2 additions & 6 deletions src/Bundle/Sender/Adapter/SymfonyMailerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,8 @@ private function sendMessage(
->html($renderedEmail->getBody())
;

if (!empty($ccRecipients)) {
$message->addCc(...$ccRecipients);
}
if (!empty($bccRecipients)) {
$message->addBcc(...$bccRecipients);
}
$message->addCc(...$ccRecipients);
$message->addBcc(...$bccRecipients);

foreach ($attachments as $attachment) {
$message->attachFromPath($attachment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function it_sends_an_email_with_events(
$message->getBody()->bodyToString() === 'body' &&
$message->getFrom()[0] == new Address('[email protected]', 'arnaud') &&
$message->getTo()[0] == new Address('[email protected]')
;
;
}))->shouldBeCalled();

$dispatcher
Expand Down
4 changes: 4 additions & 0 deletions src/Component/Sender/SenderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
interface SenderInterface
{
/**
* @deprecated using this method without 2 last arguments ($ccRecipients and $bccRecipients) is deprecated since 1.8 and won't be possible since 2.0
*
* @param string[]|null[] $recipients A list of email addresses to receive the message. Providing null or empty string in the list of recipients is deprecated and will be removed in SyliusMailerBundle 2.0
* @param string[] $attachments A list of file paths to attach to the message.
* @param string[] $replyTo A list of email addresses to set as the Reply-To address for the message.
* @param string[] $ccRecipients A list of email addresses set as carbon copy
* @param string[] $bccRecipients A list of email addresses set as blind carbon copy
*/
public function send(
string $code,
Expand Down

0 comments on commit 8b9adbd

Please sign in to comment.