Преглед на файлове

Remove almost useless method.

Daniele Alessandri преди 13 години
родител
ревизия
214b7d2dc9

+ 1 - 14
lib/Predis/Connection/AbstractConnection.php

@@ -30,16 +30,14 @@ abstract class AbstractConnection implements SingleConnectionInterface
     private $cachedId;
 
     protected $parameters;
-    protected $initCmds;
+    protected $initCmds = array();
 
     /**
      * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection.
      */
     public function __construct(ConnectionParametersInterface $parameters)
     {
-        $this->initCmds = array();
         $this->parameters = $this->checkParameters($parameters);
-        $this->initializeProtocol($parameters);
     }
 
     /**
@@ -72,17 +70,6 @@ abstract class AbstractConnection implements SingleConnectionInterface
         }
     }
 
-    /**
-     * Initializes some common configurations of the underlying protocol processor
-     * from the connection parameters.
-     *
-     * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection.
-     */
-    protected function initializeProtocol(ConnectionParametersInterface $parameters)
-    {
-        // NOOP
-    }
-
     /**
      * Creates the underlying resource used to communicate with Redis.
      *

+ 4 - 10
lib/Predis/Connection/ComposableStreamConnection.php

@@ -32,17 +32,11 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC
      */
     public function __construct(ConnectionParametersInterface $parameters, ProtocolInterface $protocol = null)
     {
-        $this->setProtocol($protocol ?: new TextProtocol());
+        $protocol = $protocol ?: new TextProtocol();
+        $protocol->setOption('iterable_multibulk', $parameters->iterable_multibulk);
 
-        parent::__construct($parameters);
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    protected function initializeProtocol(ConnectionParametersInterface $parameters)
-    {
-        $this->protocol->setOption('iterable_multibulk', $parameters->iterable_multibulk);
+        $this->protocol = $protocol;
+        $this->parameters = $this->checkParameters($parameters);
     }
 
     /**

+ 3 - 9
lib/Predis/Connection/PhpiredisConnection.php

@@ -57,6 +57,7 @@ class PhpiredisConnection extends AbstractConnection
     public function __construct(ConnectionParametersInterface $parameters)
     {
         $this->checkExtensions();
+        $this->initializeReader();
 
         parent::__construct($parameters);
     }
@@ -113,14 +114,6 @@ class PhpiredisConnection extends AbstractConnection
         $this->reader = $reader;
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function initializeProtocol(ConnectionParametersInterface $parameters)
-    {
-        $this->initializeReader();
-    }
-
     /**
      * Gets the handler used by the protocol reader to handle status replies.
      *
@@ -392,6 +385,7 @@ class PhpiredisConnection extends AbstractConnection
      */
     public function __wakeup()
     {
-        $this->initializeProtocol($this->getParameters());
+        $this->checkExtensions();
+        $this->initializeReader();
     }
 }

+ 10 - 8
lib/Predis/Connection/StreamConnection.php

@@ -37,6 +37,16 @@ class StreamConnection extends AbstractConnection
 {
     private $mbiterable;
 
+    /**
+     * {@inheritdoc}
+     */
+    public function __construct(ConnectionParametersInterface $parameters)
+    {
+        $this->mbiterable = (bool) $parameters->iterable_multibulk;
+
+        parent::__construct($parameters);
+    }
+
     /**
      * Disconnects from the server and destroys the underlying resource when
      * PHP's garbage collector kicks in only if the connection has not been
@@ -49,14 +59,6 @@ class StreamConnection extends AbstractConnection
         }
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    protected function initializeProtocol(ConnectionParametersInterface $parameters)
-    {
-        $this->mbiterable = (bool) $parameters->iterable_multibulk;
-    }
-
     /**
      * {@inheritdoc}
      */

+ 2 - 2
lib/Predis/Connection/WebdisConnection.php

@@ -57,13 +57,13 @@ class WebdisConnection implements SingleConnectionInterface
      */
     public function __construct(ConnectionParametersInterface $parameters)
     {
-        $this->parameters = $parameters;
+        $this->checkExtensions();
 
         if ($parameters->scheme !== 'http') {
             throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}");
         }
 
-        $this->checkExtensions();
+        $this->parameters = $parameters;
         $this->resource = $this->initializeCurl($parameters);
         $this->reader = $this->initializeReader($parameters);
     }