diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index 7d37dd9a..a55618fd 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/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. * diff --git a/lib/Predis/Connection/ComposableStreamConnection.php b/lib/Predis/Connection/ComposableStreamConnection.php index ce4d2384..a7b5f8c0 100644 --- a/lib/Predis/Connection/ComposableStreamConnection.php +++ b/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); } /** diff --git a/lib/Predis/Connection/PhpiredisConnection.php b/lib/Predis/Connection/PhpiredisConnection.php index 52d3ab1c..aa265cf0 100644 --- a/lib/Predis/Connection/PhpiredisConnection.php +++ b/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(); } } diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index 98d2441e..2185e3f3 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/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} */ diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index 2e0b1630..5d0b6778 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/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); }