From 626332d42a6c4d12389b40ae57113e95f3b2ce56 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 2 Oct 2021 08:40:56 +0200 Subject: Don't use is_resource() where not needed --- program/lib/Roundcube/db/oracle.php | 7 ++++--- program/lib/Roundcube/rcube_imap_generic.php | 6 +++--- program/lib/Roundcube/rcube_ldap.php | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'program') diff --git a/program/lib/Roundcube/db/oracle.php b/program/lib/Roundcube/db/oracle.php index a7e8a0883..038a4a52d 100644 --- a/program/lib/Roundcube/db/oracle.php +++ b/program/lib/Roundcube/db/oracle.php @@ -198,13 +198,14 @@ class rcube_db_oracle extends rcube_db * Helper method to handle DB errors. * This by default logs the error but could be overridden by a driver implementation * - * @param string Query that triggered the error + * @param string Query that triggered the error + * @param resource Query result * - * @return mixed Result to be stored and returned + * @return bool Result to be stored and returned */ protected function handle_error($query, $result = null) { - $error = oci_error(is_resource($result) ? $result : $this->dbh); + $error = oci_error($result ?: $this->dbh); // @TODO: Find error codes for key errors if (empty($this->options['ignore_key_errors']) || !in_array($error['code'], ['23000', '23505'])) { diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 8755f1f9a..d7a7df830 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -413,7 +413,7 @@ class rcube_imap_generic */ protected function eof() { - if (!is_resource($this->fp)) { + if (!$this->fp) { return true; } @@ -562,7 +562,7 @@ class rcube_imap_generic * @param string $pass Password * @param string $type Authentication type (PLAIN/CRAM-MD5/DIGEST-MD5) * - * @return resource Connection resource on success, error code on error + * @return resource|int Connection resource on success, error code on error */ protected function authenticate($user, $pass, $type = 'PLAIN') { @@ -817,7 +817,7 @@ class rcube_imap_generic * @param string $user Username * @param string $pass Password * - * @return resource Connection resource on success, error code on error + * @return resource|int Connection resource on success, error code on error */ protected function login($user, $password) { diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 2b136f0b1..0b4fc6112 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -488,7 +488,7 @@ class rcube_ldap extends rcube_addressbook } // end foreach hosts - if (!is_resource($this->ldap->conn)) { + if (empty($this->ldap->conn)) { rcube::raise_error([ 'code' => 100, 'type' => 'ldap', 'file' => __FILE__, 'line' => __LINE__, -- cgit v1.2.3