minor #31837 Change type hints (fabpot)
This PR was merged into the 4.3 branch.
Discussion
----------
Change type hints
| Q | A
| ------------- | ---
| Branch? | 4.3 for features / 3.4, 4.2 or 4.3 for bug fixes <!-- see below -->
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
see https://github.com/symfony/symfony/pull/31774#discussion_r289597824
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/roadmap):
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against branch 4.4.
- Legacy code removals go to the master branch.
-->
Commits
-------
d56ae06ca3
changed type hints
This commit is contained in:
commit
5a88e4cfd6
@ -11,12 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Mailer;
|
namespace Symfony\Component\Mailer;
|
||||||
|
|
||||||
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
|
|
||||||
use Symfony\Component\Mailer\Exception\LogicException;
|
use Symfony\Component\Mailer\Exception\LogicException;
|
||||||
use Symfony\Component\Mime\Address;
|
use Symfony\Component\Mime\Address;
|
||||||
use Symfony\Component\Mime\Header\Headers;
|
use Symfony\Component\Mime\Header\Headers;
|
||||||
use Symfony\Component\Mime\Message;
|
use Symfony\Component\Mime\Message;
|
||||||
use Symfony\Component\Mime\RawMessage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
@ -31,13 +29,8 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope
|
|||||||
private $recipientsSet = false;
|
private $recipientsSet = false;
|
||||||
private $message;
|
private $message;
|
||||||
|
|
||||||
public function __construct(RawMessage $message)
|
public function __construct(Message $message)
|
||||||
{
|
{
|
||||||
if (!$message instanceof Message) {
|
|
||||||
// FIXME: parse the raw message to create the envelope?
|
|
||||||
throw new InvalidArgumentException(sprintf('Unable to create an SmtpEnvelope from a "%s" message.', RawMessage::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +91,4 @@ class SmtpEnvelopeTest extends TestCase
|
|||||||
$e = SmtpEnvelope::create(new Message($headers));
|
$e = SmtpEnvelope::create(new Message($headers));
|
||||||
$this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients());
|
$this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithRawMessage()
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
SmtpEnvelope::create(new RawMessage(''));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,12 @@ final class MessageConverter
|
|||||||
/**
|
/**
|
||||||
* @throws RuntimeException when unable to convert the message to an email
|
* @throws RuntimeException when unable to convert the message to an email
|
||||||
*/
|
*/
|
||||||
public static function toEmail(RawMessage $message): Email
|
public static function toEmail(Message $message): Email
|
||||||
{
|
{
|
||||||
if ($message instanceof Email) {
|
if ($message instanceof Email) {
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RawMessage::class === \get_class($message)) {
|
|
||||||
// FIXME: parse the raw message to create the envelope?
|
|
||||||
throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as it is not supported yet.', RawMessage::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to convert to a "simple" Email instance
|
// try to convert to a "simple" Email instance
|
||||||
$body = $message->getBody();
|
$body = $message->getBody();
|
||||||
if ($body instanceof TextPart) {
|
if ($body instanceof TextPart) {
|
||||||
|
Reference in New Issue
Block a user