Skip to content

Commit

Permalink
Clear error stack before imap_close #72
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Mar 27, 2018
1 parent e6e2030 commit 148a2ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/IMAP/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ class Client {

/**
* Connected parameter
*
* @var bool
*/
protected $connected = false;

/**
* IMAP errors that might have ben occurred
*
* @var array $errors
*/
protected $errors = [];

/**
* Client constructor.
*
Expand Down Expand Up @@ -216,6 +224,7 @@ public function connect($attempts = 3) {
*/
public function disconnect() {
if ($this->isConnected()) {
$this->errors = array_merge($this->errors, imap_errors() ?: []);
$this->connected = ! imap_close($this->connection, CL_EXPUNGE);
}

Expand Down Expand Up @@ -451,7 +460,9 @@ public function getAlerts(){
* @return array
*/
public function getErrors(){
return imap_errors();
$this->errors = array_merge($this->errors, imap_errors() ?: []);

return $this->errors;
}

/**
Expand Down

0 comments on commit 148a2ac

Please sign in to comment.