diff --git a/README.md b/README.md index 221a9f10..6f68001d 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ By the way most of the common search criteria are available and functioning, bro References: 1. https://stackoverflow.com/questions/36356715/imap-search-unknown-search-criterion-or -1. imap-2007f.tar.gz: `./src/c-client/mail.c` and `./docs/internal.txt` +2. imap-2007f.tar.gz: `./src/c-client/mail.c` and `./docs/internal.txt` #### Message Properties and Operations @@ -182,7 +182,7 @@ $message->isDraft(); $message->isSeen(); ``` -Get message headers as a [\Ddeboer\Imap\Message\Headers](/src/Ddeboer/Imap/Message/Headers.php) object: +Get message headers as a [\Ddeboer\Imap\Message\Headers](/src/Message/Headers.php) object: ```php $message->getHeaders(); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e3360ff6..20d1c64a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,16 +10,6 @@ parameters: count: 1 path: src/Mailbox.php - - - message: "#^Parameter \\#3 \\$reverse of function imap_sort expects bool, bool\\|int given\\.$#" - count: 1 - path: src/Mailbox.php - - - - message: "#^Call to function is_numeric\\(\\) with int will always evaluate to true\\.$#" - count: 1 - path: src/Message.php - - message: "#^Cannot call method getDecodedContent\\(\\) on mixed\\.$#" count: 2 @@ -60,11 +50,6 @@ parameters: count: 1 path: src/MessageIterator.php - - - message: "#^Call to function is_object\\(\\) with Ddeboer\\\\Imap\\\\MessageInterface will always evaluate to true\\.$#" - count: 1 - path: src/MessageIterator.php - - message: "#^Class ArrayIterator specifies template type TKey of interface Iterator as int but it's already specified as mixed\\.$#" count: 1 @@ -75,11 +60,6 @@ parameters: count: 1 path: src/MessageIterator.php - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 - path: src/MessageIterator.php - - message: "#^Interface Iterator specifies template type TKey of interface Traversable as int but it's already specified as mixed\\.$#" count: 2 @@ -164,4 +144,3 @@ parameters: message: "#^Cannot access property \\$parts on mixed\\.$#" count: 2 path: tests/MessageTest.php - diff --git a/src/Mailbox.php b/src/Mailbox.php index 104fa9ad..f1df2ad8 100644 --- a/src/Mailbox.php +++ b/src/Mailbox.php @@ -121,10 +121,6 @@ public function getMessages(ConditionInterface $search = null, int $sortCriteria } $query = $search->toString(); - if (\PHP_VERSION_ID < 80000) { - $descending = (int) $descending; - } - // We need to clear the stack to know whether imap_last_error() // is related to this imap_search \imap_errors(); diff --git a/src/Message.php b/src/Message.php index c36aaeaf..c176e5f8 100644 --- a/src/Message.php +++ b/src/Message.php @@ -80,7 +80,6 @@ protected function assertMessageExists(int $messageNumber): void } $this->messageNumberVerified = true; - $msgno = null; \set_error_handler(static function (): bool { return true; }); @@ -89,7 +88,7 @@ protected function assertMessageExists(int $messageNumber): void \restore_error_handler(); - if (\is_numeric($msgno) && $msgno > 0) { + if ($msgno > 0) { $this->imapMsgNo = $msgno; return; diff --git a/src/Message/AbstractMessage.php b/src/Message/AbstractMessage.php index 4145b2d1..d83414d6 100644 --- a/src/Message/AbstractMessage.php +++ b/src/Message/AbstractMessage.php @@ -321,7 +321,7 @@ private static function gatherAttachments(PartInterface $part): array $attachments[] = $childPart; } if ($childPart->hasChildren()) { - $attachments = \array_merge($attachments, self::gatherAttachments($childPart)); + $attachments = [...$attachments, ...self::gatherAttachments($childPart)]; } } diff --git a/src/Message/AbstractPart.php b/src/Message/AbstractPart.php index e5805361..f39d5cdf 100644 --- a/src/Message/AbstractPart.php +++ b/src/Message/AbstractPart.php @@ -379,7 +379,7 @@ private function lazyParseStructure(): void // When the message is not multipart and the body is the attachment content // Prevents infinite recursion - if (self::isAttachment($this->structure) && !$this instanceof Attachment) { + if (!$this instanceof Attachment && self::isAttachment($this->structure)) { $this->parts[] = new Attachment($this->resource, $this->getNumber(), '1', $this->structure); } @@ -391,12 +391,11 @@ private function lazyParseStructure(): void } foreach ($parts as $key => $partStructure) { $partNumber = (!$this instanceof Message) ? $this->partNumber . '.' : ''; - $partNumber .= (string) ($key + 1); + $partNumber .= $key + 1; $newPartClass = self::isAttachment($partStructure) ? Attachment::class - : SimplePart::class - ; + : SimplePart::class; $this->parts[] = new $newPartClass($this->resource, $this->getNumber(), $partNumber, $partStructure); } @@ -446,10 +445,6 @@ private static function isAttachment(\stdClass $part): bool } */ - if (self::SUBTYPE_RFC822 === \strtoupper($part->subtype)) { - return true; - } - - return false; + return self::SUBTYPE_RFC822 === \strtoupper($part->subtype); } } diff --git a/src/Message/Headers.php b/src/Message/Headers.php index 6d538107..07a675a8 100644 --- a/src/Message/Headers.php +++ b/src/Message/Headers.php @@ -56,7 +56,6 @@ private function parseHeader(string $key, $value) case 'sender': case 'return_path': \assert(\is_array($value)); - /** @var \stdClass $address */ foreach ($value as $address) { if (isset($address->mailbox)) { $address->host = $address->host ?? null; diff --git a/src/MessageIterator.php b/src/MessageIterator.php index 698c0d0b..2b1ee633 100644 --- a/src/MessageIterator.php +++ b/src/MessageIterator.php @@ -39,7 +39,7 @@ public function current(): MessageInterface 'The current value "%s" isn\'t an integer and doesn\'t represent a message;' . ' try to cycle this "%s" with a native php function like foreach or with the method getArrayCopy(),' . ' or check it by calling the methods valid().', - \is_object($current) ? \get_class($current) : \gettype($current), + \get_debug_type($current), self::class )); } diff --git a/tests/MessageTest.php b/tests/MessageTest.php index 4472744e..ecf85274 100644 --- a/tests/MessageTest.php +++ b/tests/MessageTest.php @@ -632,8 +632,7 @@ public function testRawHeaders(): void { $headers = 'From: from@there.com' . "\r\n" . 'To: to@here.com' . "\n" - . "\r\n" - ; + . "\r\n"; $originalMessage = $headers . 'Content' . "\n"; $this->mailbox->addMessage($originalMessage);