Skip to content

Commit 148a2ac

Browse files
committed
Clear error stack before imap_close #72
1 parent e6e2030 commit 148a2ac

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/IMAP/Client.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,18 @@ class Client {
8989

9090
/**
9191
* Connected parameter
92+
*
9293
* @var bool
9394
*/
9495
protected $connected = false;
9596

97+
/**
98+
* IMAP errors that might have ben occurred
99+
*
100+
* @var array $errors
101+
*/
102+
protected $errors = [];
103+
96104
/**
97105
* Client constructor.
98106
*
@@ -216,6 +224,7 @@ public function connect($attempts = 3) {
216224
*/
217225
public function disconnect() {
218226
if ($this->isConnected()) {
227+
$this->errors = array_merge($this->errors, imap_errors() ?: []);
219228
$this->connected = ! imap_close($this->connection, CL_EXPUNGE);
220229
}
221230

@@ -451,7 +460,9 @@ public function getAlerts(){
451460
* @return array
452461
*/
453462
public function getErrors(){
454-
return imap_errors();
463+
$this->errors = array_merge($this->errors, imap_errors() ?: []);
464+
465+
return $this->errors;
455466
}
456467

457468
/**

0 commit comments

Comments
 (0)