@@ -181,14 +181,16 @@ public static function clearflag_full(
181
181
* @param false|resource $imap_stream
182
182
*
183
183
* @psalm-param value-of<self::CLOSE_FLAGS> $flag
184
- * @psalm-param 0|32768 $flag
185
184
*
186
185
* @return true
187
186
*/
188
187
public static function close ($ imap_stream , int $ flag = 0 ): bool
189
188
{
190
189
\imap_errors (); // flush errors
191
190
191
+ /** @var int */
192
+ $ flag = $ flag ;
193
+
192
194
$ result = \imap_close (self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 ), $ flag );
193
195
194
196
if (false === $ result ) {
@@ -699,12 +701,12 @@ public static function open(
699
701
700
702
\imap_errors (); // flush errors
701
703
702
- $ result = \imap_open ($ mailbox , $ username , $ password , $ options , $ n_retries , $ params );
704
+ $ result = @ \imap_open ($ mailbox , $ username , $ password , $ options , $ n_retries , $ params );
703
705
704
706
if (!$ result ) {
705
707
$ lastError = \imap_last_error ();
706
708
707
- if ('' !== \trim ($ lastError )) {
709
+ if (( \is_string ( $ lastError )) && ( '' !== \trim ($ lastError) )) {
708
710
throw new UnexpectedValueException ('IMAP error: ' .$ lastError );
709
711
}
710
712
@@ -890,7 +892,6 @@ public static function setflag_full(
890
892
* @param false|resource $imap_stream
891
893
*
892
894
* @psalm-param value-of<self::SORT_CRITERIA> $criteria
893
- * @psalm-param 1|5|0|2|6|3|4 $criteria
894
895
*
895
896
* @return int[]
896
897
*
@@ -909,6 +910,9 @@ public static function sort(
909
910
$ imap_stream = self ::EnsureConnection ($ imap_stream , __METHOD__ , 1 );
910
911
$ reverse = (int ) $ reverse ;
911
912
913
+ /** @var int */
914
+ $ criteria = $ criteria ;
915
+
912
916
if (null !== $ search_criteria && null !== $ charset ) {
913
917
$ result = \imap_sort (
914
918
$ imap_stream ,
@@ -935,7 +939,7 @@ public static function sort(
935
939
);
936
940
}
937
941
938
- if (! $ result ) {
942
+ if (false === $ result ) {
939
943
throw new UnexpectedValueException ('Could not sort messages! ' , 0 , self ::HandleErrors (\imap_errors (), 'imap_sort ' ));
940
944
}
941
945
@@ -990,7 +994,6 @@ public static function subscribe(
990
994
991
995
/**
992
996
* @psalm-param value-of<self::TIMEOUT_TYPES> $timeout_type
993
- * @psalm-param 4|1|2|3 $timeout_type
994
997
*
995
998
* @return true|int
996
999
*/
@@ -1000,6 +1003,9 @@ public static function timeout(
1000
1003
) {
1001
1004
\imap_errors (); // flush errors
1002
1005
1006
+ /** @var int */
1007
+ $ timeout_type = $ timeout_type ;
1008
+
1003
1009
$ result = \imap_timeout (
1004
1010
$ timeout_type ,
1005
1011
$ timeout
0 commit comments