diff --git a/psalm.baseline.xml b/psalm.baseline.xml index 443eb85..6bf7767 100644 --- a/psalm.baseline.xml +++ b/psalm.baseline.xml @@ -31,7 +31,7 @@ $mailId $mailId - + $mail->subject $mail->subject $mail->from @@ -74,8 +74,6 @@ $partStructure->id $element->charset $element->text - $recipient->mailbox - $recipient->host $recipient->personal $recipient->personal $t[0]->personal @@ -102,13 +100,11 @@ string string - + $params[$paramName] $subPartNum $subPartNum $partStructure->ifid ? $partStructure->id : '' - $recipient->mailbox - $recipient->host $t[0]->mailbox diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 429ad57..8f980a0 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1677,14 +1677,28 @@ protected function getCombinedPath($folder, $absolute = false) */ protected function possiblyGetEmailAndNameFromRecipient(object $recipient) { - if (isset($recipient->mailbox, $recipient->host) && '' !== trim($recipient->mailbox) && '' !== trim($recipient->host)) { - $recipientEmail = strtolower($recipient->mailbox.'@'.$recipient->host); + if (isset($recipient->mailbox, $recipient->host)) { + /** @var mixed */ + $recipientMailbox = $recipient->mailbox; + + /** @var mixed */ + $recipientHost = $recipient->host; + + if (!\is_string($recipientMailbox)) { + throw new UnexpectedValueException('mailbox was present on argument 1 passed to '.__METHOD__.'() but was not a string!'); + } elseif (!\is_string($recipientHost)) { + throw new UnexpectedValueException('host was present on argument 1 passed to '.__METHOD__.'() but was not a string!'); + } + + if ('' !== trim($recipientMailbox) && '' !== trim($recipientHost)) { + $recipientEmail = strtolower($recipientMailbox.'@'.$recipientHost); $recipientName = (isset($recipient->personal) and !empty(trim($recipient->personal))) ? $this->decodeMimeStr($recipient->personal, $this->getServerEncoding()) : null; return [ $recipientEmail, $recipientName, ]; + } } return null;