Collapse some nested if statements
[lhc/web/wiklou.git] / includes / libs / redis / RedisConnectionPool.php
index 82cc233..9a8086f 100644 (file)
@@ -168,7 +168,7 @@ class RedisConnectionPool implements LoggerAwareInterface {
         *
         * @param string $server A hostname/port combination or the absolute path of a UNIX socket.
         *                       If a hostname is specified but no port, port 6379 will be used.
-        * @param LoggerInterface $logger PSR-3 logger intance. [optional]
+        * @param LoggerInterface|null $logger PSR-3 logger intance. [optional]
         * @return RedisConnRef|bool Returns false on failure
         * @throws MWException
         */
@@ -245,13 +245,11 @@ class RedisConnectionPool implements LoggerAwareInterface {
 
                                return false;
                        }
-                       if ( $this->password !== null ) {
-                               if ( !$conn->auth( $this->password ) ) {
-                                       $logger->error(
-                                               'Authentication error connecting to "{redis_server}"',
-                                               [ 'redis_server' => $server ]
-                                       );
-                               }
+                       if ( ( $this->password !== null ) && !$conn->auth( $this->password ) ) {
+                               $logger->error(
+                                       'Authentication error connecting to "{redis_server}"',
+                                       [ 'redis_server' => $server ]
+                               );
                        }
                } catch ( RedisException $e ) {
                        $this->downServers[$server] = time() + self::SERVER_DOWN_TTL;
@@ -364,15 +362,13 @@ class RedisConnectionPool implements LoggerAwareInterface {
         * @return bool Success
         */
        public function reauthenticateConnection( $server, Redis $conn ) {
-               if ( $this->password !== null ) {
-                       if ( !$conn->auth( $this->password ) ) {
-                               $this->logger->error(
-                                       'Authentication error connecting to "{redis_server}"',
-                                       [ 'redis_server' => $server ]
-                               );
+               if ( $this->password !== null && !$conn->auth( $this->password ) ) {
+                       $this->logger->error(
+                               'Authentication error connecting to "{redis_server}"',
+                               [ 'redis_server' => $server ]
+                       );
 
-                               return false;
-                       }
+                       return false;
                }
 
                return true;
@@ -382,7 +378,7 @@ class RedisConnectionPool implements LoggerAwareInterface {
         * Adjust or reset the connection handle read timeout value
         *
         * @param Redis $conn
-        * @param int $timeout Optional
+        * @param int|null $timeout Optional
         */
        public function resetTimeout( Redis $conn, $timeout = null ) {
                $conn->setOption( Redis::OPT_READ_TIMEOUT, $timeout ?: $this->readTimeout );