bug #39812 Make EmailMessage & SmsMessage transport nullable (odolbeau)
This PR was merged into the 5.1 branch.
Discussion
----------
Make EmailMessage & SmsMessage transport nullable
| Q | A
| ------------- | ---
| Branch? | 5.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
Ideally, this should have been done in #38361 as it's exactly the same problem: the `transport` method can be called with `null` with deserializing a message from json (for example).
Commits
-------
d98aca06d0
Make EmailMessage & SmsMessage transport nullable
This commit is contained in:
commit
41697467bc
@ -97,11 +97,14 @@ final class EmailMessage implements MessageInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function transport(string $transport): self
|
||||
public function transport(?string $transport): self
|
||||
{
|
||||
if (!$this->message instanceof Email) {
|
||||
throw new LogicException('Cannot set a Transport on a RawMessage instance.');
|
||||
}
|
||||
if (null === $transport) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->message->getHeaders()->addTextHeader('X-Transport', $transport);
|
||||
|
||||
|
@ -81,7 +81,7 @@ final class SmsMessage implements MessageInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function transport(string $transport): self
|
||||
public function transport(?string $transport): self
|
||||
{
|
||||
$this->transport = $transport;
|
||||
|
||||
|
Reference in New Issue
Block a user