From 6f2c007d1be866e47bf6a9f8e6900fe6ec2a6901 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 02 Apr 2016 07:02:55 -0400
Subject: [PATCH] CS fixes: Replace use of "bool ? true : false" with just "bool"

---
 program/lib/Roundcube/rcube_imap_generic.php |   44 ++++++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index f45f608..764604d 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -107,7 +107,11 @@
             $this->debug('C: ' . $log);
         }
 
-        $res = fwrite($this->fp, $string . ($endln ? "\r\n" : ''));
+        if ($endln) {
+            $string .= "\r\n";
+        }
+
+        $res = fwrite($this->fp, $string);
 
         if ($res === false) {
             @fclose($this->fp);
@@ -174,6 +178,7 @@
                 }
             }
         }
+
         return $res;
     }
 
@@ -194,7 +199,7 @@
 
         do {
             if ($this->eof()) {
-                return $line ? $line : null;
+                return $line ?: null;
             }
 
             $buffer = fgets($this->fp, $size);
@@ -462,7 +467,7 @@
             }
         }
 
-        return !empty($result) ? $result : false;
+        return $result ?: false;
     }
 
     /**
@@ -997,7 +1002,18 @@
                 return false;
             }
 
-            if (!stream_socket_enable_crypto($this->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
+            if (isset($this->prefs['socket_options']['ssl']['crypto_method'])) {
+                $crypto_method = $this->prefs['socket_options']['ssl']['crypto_method'];
+            }
+            else {
+                // There is no flag to enable all TLS methods. Net_SMTP
+                // handles enabling TLS similarly.
+                $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT
+                    | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
+                    | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
+            }
+
+            if (!stream_socket_enable_crypto($this->fp, true, $crypto_method)) {
                 $this->setError(self::ERROR_BAD, "Unable to negotiate TLS");
                 $this->closeConnection();
                 return false;
@@ -1047,7 +1063,7 @@
      */
     public function connected()
     {
-        return ($this->fp && $this->logged) ? true : false;
+        return $this->fp && $this->logged;
     }
 
     /**
@@ -3454,6 +3470,7 @@
         if (!is_array($entries)) {
             $entries = array($entries);
         }
+
         // create entries string
         // ANNOTATEMORE drafts before version 08 require quoted parameters
         foreach ($entries as $idx => $name) {
@@ -3464,7 +3481,8 @@
         if (!is_array($attribs)) {
             $attribs = array($attribs);
         }
-        // create entries string
+
+        // create attributes string
         foreach ($attribs as $idx => $name) {
             $attribs[$idx] = $this->escape($name, true);
         }
@@ -3725,9 +3743,9 @@
                 if (!is_numeric(($bytes = substr($str, 1, $epos - 1)))) {
                     // error
                 }
+
                 $result[] = $bytes ? substr($str, $epos + 3, $bytes) : '';
-                // Advance the string
-                $str = substr($str, $epos + 3 + $bytes);
+                $str      = substr($str, $epos + 3 + $bytes);
                 break;
 
             // Quoted string
@@ -3744,9 +3762,7 @@
                         }
                     }
                 }
-                if ($str[$pos] != '"') {
-                    // error
-                }
+
                 // we need to strip slashes for a quoted string
                 $result[] = stripslashes(substr($str, 1, $pos - 1));
                 $str      = substr($str, $pos + 1);
@@ -3754,13 +3770,13 @@
 
             // Parenthesized list
             case '(':
-                $str = substr($str, 1);
+                $str      = substr($str, 1);
                 $result[] = self::tokenizeResponse($str);
                 break;
+
             case ')':
                 $str = substr($str, 1);
                 return $result;
-                break;
 
             // String atom, number, astring, NIL, *, %
             default:
@@ -3773,7 +3789,7 @@
                 // we do not exclude [ and ] (#1489223)
                 if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) {
                     $result[] = $m[1] == 'NIL' ? null : $m[1];
-                    $str = substr($str, strlen($m[1]));
+                    $str      = substr($str, strlen($m[1]));
                 }
                 break;
             }

--
Gitblit v1.9.1