22
22
use const SORTSIZE ;
23
23
use const SORTSUBJECT ;
24
24
use const SORTTO ;
25
+ use stdClass ;
25
26
use Throwable ;
26
27
use UnexpectedValueException ;
27
28
@@ -572,6 +573,8 @@ static function (string $folder): string {
572
573
* }> $body An indexed array of bodies (docblock is not complete)
573
574
*
574
575
* @todo flesh out array shape pending resolution of https://github.com/vimeo/psalm/issues/1518
576
+ *
577
+ * @psalm-pure
575
578
*/
576
579
public static function mail_compose (array $ envelope , array $ body ): string
577
580
{
@@ -647,7 +650,7 @@ public static function mail_move(
647
650
/**
648
651
* @param false|resource $imap_stream
649
652
*/
650
- public static function mailboxmsginfo ($ imap_stream ): object
653
+ public static function mailboxmsginfo ($ imap_stream ): stdClass
651
654
{
652
655
\imap_errors (); // flush errors
653
656
@@ -692,7 +695,7 @@ public static function open(
692
695
array $ params = []
693
696
) {
694
697
if (\preg_match ("/^\{.*\}(.*)$/ " , $ mailbox , $ matches )) {
695
- $ mailbox_name = $ matches [1 ];
698
+ $ mailbox_name = $ matches [1 ] ?? '' ;
696
699
697
700
if (!\mb_detect_encoding ($ mailbox_name , 'ASCII ' , true )) {
698
701
$ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -718,6 +721,8 @@ public static function open(
718
721
719
722
/**
720
723
* @param resource|false $imap_stream
724
+ *
725
+ * @psalm-pure
721
726
*/
722
727
public static function ping ($ imap_stream ): bool
723
728
{
@@ -892,6 +897,9 @@ public static function setflag_full(
892
897
* @param false|resource $imap_stream
893
898
*
894
899
* @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
895
903
*
896
904
* @return int[]
897
905
*
@@ -908,7 +916,7 @@ public static function sort(
908
916
\imap_errors (); // flush errors
909
917
910
918
$ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
911
- $ reverse = ( bool ) $ reverse ;
919
+ $ reverse = $ reverse ;
912
920
913
921
/** @var int */
914
922
$ criteria = $ criteria ;
@@ -952,11 +960,8 @@ public static function sort(
952
960
*
953
961
* @psalm-param SA_MESSAGES|SA_RECENT|SA_UNSEEN|SA_UIDNEXT|SA_UIDVALIDITY|SA_ALL $flags
954
962
*/
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
+ {
960
965
$ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
961
966
962
967
$ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -975,10 +980,8 @@ public static function status(
975
980
/**
976
981
* @param false|resource $imap_stream
977
982
*/
978
- public static function subscribe (
979
- $ imap_stream ,
980
- string $ mailbox
981
- ): void {
983
+ public static function subscribe ($ imap_stream , string $ mailbox ): void
984
+ {
982
985
$ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
983
986
984
987
$ mailbox = static ::encodeStringToUtf7Imap ($ mailbox );
@@ -1042,6 +1045,8 @@ public static function unsubscribe(
1042
1045
* Returns the provided string in UTF7-IMAP encoded format.
1043
1046
*
1044
1047
* @return string $str UTF-7 encoded string
1048
+ *
1049
+ * @psalm-pure
1045
1050
*/
1046
1051
public static function encodeStringToUtf7Imap (string $ str ): string
1047
1052
{
@@ -1058,6 +1063,8 @@ public static function encodeStringToUtf7Imap(string $str): string
1058
1063
* Returns the provided string in UTF-8 encoded format.
1059
1064
*
1060
1065
* @return string $str, but UTF-8 encoded
1066
+ *
1067
+ * @psalm-pure
1061
1068
*/
1062
1069
public static function decodeStringFromUtf7ImapToUtf8 (string $ str ): string
1063
1070
{
@@ -1076,6 +1083,8 @@ public static function decodeStringFromUtf7ImapToUtf8(string $str): string
1076
1083
* @throws InvalidArgumentException if $maybe is not a valid resource
1077
1084
*
1078
1085
* @return resource
1086
+ *
1087
+ * @psalm-pure
1079
1088
*/
1080
1089
private static function EnsureResource ($ maybe , string $ method , int $ argument )
1081
1090
{
@@ -1105,6 +1114,8 @@ private static function EnsureConnection($maybe, string $method, int $argument)
1105
1114
1106
1115
/**
1107
1116
* @param array|false $errors
1117
+ *
1118
+ * @psalm-pure
1108
1119
*/
1109
1120
private static function HandleErrors ($ errors , string $ method ): UnexpectedValueException
1110
1121
{
@@ -1117,6 +1128,8 @@ private static function HandleErrors($errors, string $method): UnexpectedValueEx
1117
1128
1118
1129
/**
1119
1130
* @param scalar $msg_number
1131
+ *
1132
+ * @psalm-pure
1120
1133
*/
1121
1134
private static function EnsureRange (
1122
1135
$ msg_number ,
0 commit comments