From 1bdf8ee14fceabee2972c0a93272c291bae3a258 Mon Sep 17 00:00:00 2001 From: Synchro Date: Thu, 5 Jun 2014 01:08:50 +0200 Subject: [PATCH] Fix random typing of error property in SMTP class, fixes #242 Make use of $smtp_conn consistent for a resource (i.e. null when not set, not 0) Make use of $helo_rply consistent Don't need a constructor any more - property default are fine --- class.smtp.php | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/class.smtp.php b/class.smtp.php index ec75ca547..e06dc76f7 100644 --- a/class.smtp.php +++ b/class.smtp.php @@ -123,19 +123,20 @@ class SMTP * The socket for the server connection. * @type resource */ - protected $smtp_conn; + protected $smtp_conn = null; /** * Error message, if any, for the last call. - * @type string + * @type array */ - protected $error = ''; + protected $error = array(); /** * The reply the server sent to us for HELO. - * @type string + * If null, no HELO string has yet been received. + * @type string|null */ - protected $helo_rply = ''; + protected $helo_rply = null; /** * The most recent reply received from the server. @@ -143,18 +144,6 @@ class SMTP */ protected $last_reply = ''; - /** - * Constructor. - * @access public - */ - public function __construct() - { - $this->smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - $this->do_debug = 0; - } - /** * Output debugging info via a user-selected method. * @param string $str Debug string to output @@ -194,7 +183,7 @@ protected function edebug($str) public function connect($host, $port = null, $timeout = 30, $options = array()) { // Clear errors to avoid confusion - $this->error = null; + $this->error = array(); // Make sure we are __not__ connected if ($this->connected()) { // Already connected, generate error @@ -465,7 +454,7 @@ public function connected() */ public function close() { - $this->error = null; // so there is no confusion + $this->error = array(); $this->helo_rply = null; if (!empty($this->smtp_conn)) { // close the connection and cleanup @@ -473,7 +462,7 @@ public function close() if ($this->do_debug >= 3) { $this->edebug('Connection: closed'); } - $this->smtp_conn = 0; + $this->smtp_conn = null; } } @@ -704,7 +693,7 @@ protected function sendCommand($command, $commandstring, $expect) } $this->last_reply = $reply; - $this->error = null; + $this->error = array(); return true; }