@@ -48,9 +48,7 @@ public function __construct(bool $cert_validation = true, mixed $encryption = fa
48
48
}
49
49
50
50
/**
51
- * @throws ImapBadRequestException
52
- * @throws ImapServerErrorException
53
- * @throws RuntimeException
51
+ * Handle the class destruction / tear down
54
52
*/
55
53
public function __destruct () {
56
54
$ this ->logout ();
@@ -382,12 +380,12 @@ public function requestAndResponse(string $command, array $tokens = [], bool $do
382
380
383
381
/**
384
382
* Escape one or more literals i.e. for sendRequest
385
- * @param string| array $string the literal/-s
383
+ * @param array|string $string the literal/-s
386
384
*
387
385
* @return string|array escape literals, literals with newline ar returned
388
386
* as array('{size}', 'string');
389
387
*/
390
- public function escapeString ($ string ) {
388
+ public function escapeString (array | string $ string ): array | string {
391
389
if (func_num_args () < 2 ) {
392
390
if (str_contains ($ string , "\n" )) {
393
391
return ['{ ' . strlen ($ string ) . '} ' , $ string ];
@@ -423,7 +421,7 @@ public function escapeList(array $list): string {
423
421
/**
424
422
* Login to a new session.
425
423
*
426
- * @param string $user username
424
+ * @param string $user username
427
425
* @param string $password password
428
426
*
429
427
* @return Response
@@ -460,7 +458,7 @@ public function authenticate(string $user, string $token): Response {
460
458
$ is_plus = $ this ->readLine ($ response , $ tokens , '+ ' , true );
461
459
if ($ is_plus ) {
462
460
// try to log the challenge somewhere where it can be found
463
- error_log ("got an extra server challenge: $ response " );
461
+ error_log ("got an extra server challenge: $ tokens " );
464
462
// respond with an empty response.
465
463
$ response ->stack ($ this ->sendRequest ('' ));
466
464
} else {
@@ -510,18 +508,7 @@ public function logout(): Response {
510
508
*/
511
509
public function reset (): void {
512
510
$ this ->stream = null ;
513
- $ this ->uid_cache = null ;
514
-
515
- return $ result ;
516
- }
517
-
518
- /**
519
- * Check if the current session is connected
520
- *
521
- * @return bool
522
- */
523
- public function connected (): bool {
524
- return (boolean ) $ this ->stream ;
511
+ $ this ->uid_cache = [];
525
512
}
526
513
527
514
/**
@@ -532,6 +519,7 @@ public function connected(): bool {
532
519
* @throws ImapBadRequestException
533
520
* @throws ImapServerErrorException
534
521
* @throws RuntimeException
522
+ * @throws ResponseException
535
523
*/
536
524
public function getCapabilities (): Response {
537
525
$ response = $ this ->requestAndResponse ('CAPABILITY ' );
@@ -616,8 +604,8 @@ public function examineFolder(string $folder = 'INBOX'): Response {
616
604
617
605
/**
618
606
* Fetch one or more items of one or more messages
619
- * @param string| array $items items to fetch [RFC822.HEADER, FLAGS, RFC822.TEXT, etc]
620
- * @param int| array $from message for items or start message if $to !== null
607
+ * @param array|string $items items to fetch [RFC822.HEADER, FLAGS, RFC822.TEXT, etc]
608
+ * @param array|int $from message for items or start message if $to !== null
621
609
* @param int|null $to if null only one message ($from) is fetched, else it's the
622
610
* last message, INF means last message available
623
611
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
@@ -729,7 +717,7 @@ public function fetch(array|string $items, array|int $from, mixed $to = null, in
729
717
730
718
/**
731
719
* Fetch message headers
732
- * @param array| int $uids
720
+ * @param int|array $uids
733
721
* @param string $rfc
734
722
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
735
723
* message numbers instead.
@@ -743,7 +731,7 @@ public function content(int|array $uids, string $rfc = "RFC822", int|string $uid
743
731
744
732
/**
745
733
* Fetch message headers
746
- * @param array| int $uids
734
+ * @param int|array $uids
747
735
* @param string $rfc
748
736
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
749
737
* message numbers instead.
@@ -757,7 +745,7 @@ public function headers(int|array $uids, string $rfc = "RFC822", int|string $uid
757
745
758
746
/**
759
747
* Fetch message flags
760
- * @param array| int $uids
748
+ * @param int|array $uids
761
749
* @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
762
750
* message numbers instead.
763
751
*
@@ -825,7 +813,7 @@ public function getMessageNumber(string $id): Response {
825
813
* Get a list of available folders
826
814
*
827
815
* @param string $reference mailbox reference for list
828
- * @param string $folder mailbox name match with wildcards
816
+ * @param string $folder mailbox name match with wildcards
829
817
*
830
818
* @return Response folders that matched $folder as array(name => array('delimiter' => .., 'flags' => ..))
831
819
*
@@ -853,15 +841,15 @@ public function folders(string $reference = '', string $folder = '*'): Response
853
841
/**
854
842
* Manage flags
855
843
*
856
- * @param array $flags flags to set, add or remove - see $mode
857
- * @param int $from message for items or start message if $to !== null
858
- * @param null $to if null only one message ($from) is fetched, else it's the
844
+ * @param array|string $flags flags to set, add or remove - see $mode
845
+ * @param int $from message for items or start message if $to !== null
846
+ * @param int| null $to if null only one message ($from) is fetched, else it's the
859
847
* last message, INF means last message available
860
- * @param null $mode '+' to add flags, '-' to remove flags, everything else sets the flags as given
861
- * @param bool $silent if false the return values are the new flags for the wanted messages
862
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
848
+ * @param string| null $mode '+' to add flags, '-' to remove flags, everything else sets the flags as given
849
+ * @param bool $silent if false the return values are the new flags for the wanted messages
850
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
863
851
* message numbers instead.
864
- * @param null $item command used to store a flag
852
+ * @param string| null $item command used to store a flag
865
853
*
866
854
* @return Response new flags if $silent is false, else true or false depending on success
867
855
* @throws ImapBadRequestException
@@ -898,10 +886,10 @@ public function store(
898
886
/**
899
887
* Append a new message to given folder
900
888
*
901
- * @param string $folder name of target folder
889
+ * @param string $folder name of target folder
902
890
* @param string $message full message content
903
- * @param null $flags flags for new message
904
- * @param null $date date for new message
891
+ * @param array| null $flags flags for new message
892
+ * @param string| null $date date for new message
905
893
*
906
894
* @return Response
907
895
*
@@ -926,11 +914,11 @@ public function appendMessage(string $folder, string $message, array $flags = nu
926
914
/**
927
915
* Copy a message set from current folder to another folder
928
916
*
929
- * @param string $folder destination folder
917
+ * @param string $folder destination folder
930
918
* @param $from
931
- * @param null $to if null only one message ($from) is fetched, else it's the
919
+ * @param int| null $to if null only one message ($from) is fetched, else it's the
932
920
* last message, INF means last message available
933
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
921
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
934
922
* message numbers instead.
935
923
*
936
924
* @return Response
@@ -950,8 +938,8 @@ public function copyMessage(string $folder, $from, int $to = null, int|string $u
950
938
* Copy multiple messages to the target folder
951
939
*
952
940
* @param array $messages List of message identifiers
953
- * @param string $folder Destination folder
954
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
941
+ * @param string $folder Destination folder
942
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
955
943
* message numbers instead.
956
944
*
957
945
* @return Response Tokens if operation successful, false if an error occurred
@@ -972,11 +960,11 @@ public function copyManyMessages(array $messages, string $folder, int|string $ui
972
960
/**
973
961
* Move a message set from current folder to another folder
974
962
*
975
- * @param string $folder destination folder
963
+ * @param string $folder destination folder
976
964
* @param $from
977
- * @param null $to if null only one message ($from) is fetched, else it's the
965
+ * @param int| null $to if null only one message ($from) is fetched, else it's the
978
966
* last message, INF means last message available
979
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
967
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
980
968
* message numbers instead.
981
969
*
982
970
* @return Response
@@ -996,8 +984,8 @@ public function moveMessage(string $folder, $from, int $to = null, int|string $u
996
984
* Move multiple messages to the target folder
997
985
*
998
986
* @param array $messages List of message identifiers
999
- * @param string $folder Destination folder
1000
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
987
+ * @param string $folder Destination folder
988
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
1001
989
* message numbers instead.
1002
990
*
1003
991
* @return Response
@@ -1126,7 +1114,7 @@ public function expunge(): Response {
1126
1114
/**
1127
1115
* Send noop command
1128
1116
*
1129
- * @return array success
1117
+ * @return Response
1130
1118
* @throws ImapBadRequestException
1131
1119
* @throws ImapServerErrorException
1132
1120
* @throws RuntimeException
@@ -1198,7 +1186,7 @@ public function done(): bool {
1198
1186
* Search for matching messages
1199
1187
*
1200
1188
* @param array $params
1201
- * @param int $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
1189
+ * @param int|string $uid set to IMAP::ST_UID or any string representing the UID - set to IMAP::ST_MSGN to use
1202
1190
* message numbers instead.
1203
1191
*
1204
1192
* @return Response message ids
@@ -1254,15 +1242,19 @@ public function overview(string $sequence, int|string $uid = IMAP::ST_UID): Resp
1254
1242
1255
1243
/**
1256
1244
* Enable the debug mode
1245
+ *
1246
+ * @return void
1257
1247
*/
1258
- public function enableDebug (){
1248
+ public function enableDebug (): void {
1259
1249
$ this ->debug = true ;
1260
1250
}
1261
1251
1262
1252
/**
1263
1253
* Disable the debug mode
1254
+ *
1255
+ * @return void
1264
1256
*/
1265
- public function disableDebug (){
1257
+ public function disableDebug (): void {
1266
1258
$ this ->debug = false ;
1267
1259
}
1268
1260
@@ -1273,7 +1265,7 @@ public function disableDebug(){
1273
1265
*
1274
1266
* @return int|string
1275
1267
*/
1276
- public function buildSet ($ from , $ to = null ) {
1268
+ public function buildSet ($ from , $ to = null ): int | string {
1277
1269
$ set = (int )$ from ;
1278
1270
if ($ to !== null ) {
1279
1271
$ set .= ': ' . ($ to == INF ? '* ' : (int )$ to );
0 commit comments