changed type hints

This commit is contained in:
Fabien Potencier 2019-06-04 11:03:18 +02:00
parent f6a6fb6834
commit d56ae06ca3
3 changed files with 2 additions and 20 deletions

View File

@ -11,12 +11,10 @@
namespace Symfony\Component\Mailer;
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
use Symfony\Component\Mailer\Exception\LogicException;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Header\Headers;
use Symfony\Component\Mime\Message;
use Symfony\Component\Mime\RawMessage;
/**
* @author Fabien Potencier <fabien@symfony.com>
@ -31,13 +29,8 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope
private $recipientsSet = false;
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;
}

View File

@ -91,10 +91,4 @@ class SmtpEnvelopeTest extends TestCase
$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());
}
public function testCreateWithRawMessage()
{
$this->expectException(\InvalidArgumentException::class);
SmtpEnvelope::create(new RawMessage(''));
}
}

View File

@ -28,17 +28,12 @@ final class MessageConverter
/**
* @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) {
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
$body = $message->getBody();
if ($body instanceof TextPart) {