2222use const SORTSIZE ;
2323use const SORTSUBJECT ;
2424use const SORTTO ;
25+ use stdClass ;
2526use Throwable ;
2627use UnexpectedValueException ;
2728
@@ -572,6 +573,8 @@ static function (string $folder): string {
572573 * }> $body An indexed array of bodies (docblock is not complete)
573574 *
574575 * @todo flesh out array shape pending resolution of https://github.com/vimeo/psalm/issues/1518
576+ *
577+ * @psalm-pure
575578 */
576579 public static function mail_compose (array $ envelope , array $ body ): string
577580 {
@@ -647,7 +650,7 @@ public static function mail_move(
647650 /**
648651 * @param false|resource $imap_stream
649652 */
650- public static function mailboxmsginfo ($ imap_stream ): object
653+ public static function mailboxmsginfo ($ imap_stream ): stdClass
651654 {
652655 \imap_errors (); // flush errors
653656
@@ -692,7 +695,7 @@ public static function open(
692695 array $ params = []
693696 ) {
694697 if (\preg_match ("/^\{.*\}(.*)$/ " , $ mailbox , $ matches )) {
695- $ mailbox_name = $ matches [1 ];
698+ $ mailbox_name = $ matches [1 ] ?? '' ;
696699
697700 if (!\mb_detect_encoding ($ mailbox_name , 'ASCII ' , true )) {
698701 $ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -718,6 +721,8 @@ public static function open(
718721
719722 /**
720723 * @param resource|false $imap_stream
724+ *
725+ * @psalm-pure
721726 */
722727 public static function ping ($ imap_stream ): bool
723728 {
@@ -892,6 +897,9 @@ public static function setflag_full(
892897 * @param false|resource $imap_stream
893898 *
894899 * @psalm-param value-of<self::SORT_CRITERIA> $criteria
900+ * @psalm-suppress InvalidArgument
901+ *
902+ * @todo InvalidArgument, although it's correct: Argument 3 of imap_sort expects int, bool provided https://www.php.net/manual/de/function.imap-sort.php
895903 *
896904 * @return int[]
897905 *
@@ -908,7 +916,7 @@ public static function sort(
908916 \imap_errors (); // flush errors
909917
910918 $ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
911- $ reverse = ( bool ) $ reverse ;
919+ $ reverse = $ reverse ;
912920
913921 /** @var int */
914922 $ criteria = $ criteria ;
@@ -952,11 +960,8 @@ public static function sort(
952960 *
953961 * @psalm-param SA_MESSAGES|SA_RECENT|SA_UNSEEN|SA_UIDNEXT|SA_UIDVALIDITY|SA_ALL $flags
954962 */
955- public static function status (
956- $ imap_stream ,
957- string $ mailbox ,
958- int $ options
959- ): object {
963+ public static function status ($ imap_stream , string $ mailbox , int $ options ): stdClass
964+ {
960965 $ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
961966
962967 $ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -975,10 +980,8 @@ public static function status(
975980 /**
976981 * @param false|resource $imap_stream
977982 */
978- public static function subscribe (
979- $ imap_stream ,
980- string $ mailbox
981- ): void {
983+ public static function subscribe ($ imap_stream , string $ mailbox ): void
984+ {
982985 $ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
983986
984987 $ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -1042,6 +1045,8 @@ public static function unsubscribe(
10421045 * Returns the provided string in UTF7-IMAP encoded format.
10431046 *
10441047 * @return string $str UTF-7 encoded string
1048+ *
1049+ * @psalm-pure
10451050 */
10461051 public static function encodeStringToUtf7Imap (string $ str ): string
10471052 {
@@ -1058,6 +1063,8 @@ public static function encodeStringToUtf7Imap(string $str): string
10581063 * Returns the provided string in UTF-8 encoded format.
10591064 *
10601065 * @return string $str, but UTF-8 encoded
1066+ *
1067+ * @psalm-pure
10611068 */
10621069 public static function decodeStringFromUtf7ImapToUtf8 (string $ str ): string
10631070 {
@@ -1076,6 +1083,8 @@ public static function decodeStringFromUtf7ImapToUtf8(string $str): string
10761083 * @throws InvalidArgumentException if $maybe is not a valid resource
10771084 *
10781085 * @return resource
1086+ *
1087+ * @psalm-pure
10791088 */
10801089 private static function EnsureResource ($ maybe , string $ method , int $ argument )
10811090 {
@@ -1105,6 +1114,8 @@ private static function EnsureConnection($maybe, string $method, int $argument)
11051114
11061115 /**
11071116 * @param array|false $errors
1117+ *
1118+ * @psalm-pure
11081119 */
11091120 private static function HandleErrors ($ errors , string $ method ): UnexpectedValueException
11101121 {
@@ -1117,6 +1128,8 @@ private static function HandleErrors($errors, string $method): UnexpectedValueEx
11171128
11181129 /**
11191130 * @param scalar $msg_number
1131+ *
1132+ * @psalm-pure
11201133 */
11211134 private static function EnsureRange (
11221135 $ msg_number ,
0 commit comments