Skip to content

Commit

Permalink
partially satisfying psalm, updating baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
bapcltd-marv committed Jan 15, 2020
1 parent 0376bc0 commit df627ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
11 changes: 0 additions & 11 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
<code>$emlOrigin</code>
</PossiblyUnusedProperty>
</file>
<file src="src/PhpImap/IncomingMailHeader.php">
<MissingConstructor occurrences="1">
<code>$id</code>
</MissingConstructor>
<MissingPropertyType occurrences="1">
<code>$messageId</code>
</MissingPropertyType>
</file>
<file src="src/PhpImap/Mailbox.php">
<DocblockTypeContradiction occurrences="2">
<code>\is_int($retriesNum)</code>
Expand Down Expand Up @@ -473,9 +465,6 @@
<code>\is_resource($imapStream)</code>
<code>$imapStream &amp;&amp; \is_resource($imapStream)</code>
</RedundantConditionGivenDocblockType>
<UndefinedDocblockClass occurrences="1">
<code>InvalidArgumentException</code>
</UndefinedDocblockClass>
<UnusedVariable occurrences="1">
<code>$value</code>
</UnusedVariable>
Expand Down
3 changes: 2 additions & 1 deletion src/PhpImap/IncomingMailHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class IncomingMailHeader
{
/** @var int|string $id The IMAP message ID - not the "Message-ID:"-header of the email */
/** @var int|string|null $id The IMAP message ID - not the "Message-ID:"-header of the email */
public $id;

/** @var bool */
Expand Down Expand Up @@ -94,5 +94,6 @@ class IncomingMailHeader
*/
public $replyTo = [];

/** @var string|null */
public $messageId;
}
9 changes: 9 additions & 0 deletions src/PhpImap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use DateTime;
use Exception;
use function iconv;
use InvalidArgumentException;
use function mb_list_encodings;
use PhpImap\Exceptions\ConnectionException;
use PhpImap\Exceptions\InvalidParameterException;
use stdClass;
use UnexpectedValueException;

/**
* @see https://github.com/barbushin/php-imap
Expand Down Expand Up @@ -1034,6 +1036,9 @@ public function getMailHeader($mailId)
}

if (isset($head->message_id)) {
if (!is_string($head->message_id)) {
throw new UnexpectedValueException('Message ID was expected to be a string, '.\gettype($head->message_id).' found!');
}
$header->messageId = $head->message_id;
}

Expand Down Expand Up @@ -1110,6 +1115,10 @@ public function getMail($mailId, $markAsSeen = true)
*/
protected function initMailPart(IncomingMail $mail, $partStructure, $partNum, $markAsSeen = true, $emlParse = false)
{
if (!isset($mail->id)) {
throw new InvalidArgumentException('Argument 1 passeed to '.__METHOD__.'() did not have the id property set!');
}

$options = (SE_UID == $this->imapSearchOption) ? FT_UID : 0;

if (!$markAsSeen) {
Expand Down

0 comments on commit df627ac

Please sign in to comment.