diff --git a/lib/Predis/Network/ComposableStreamConnection.php b/lib/Predis/Network/ComposableStreamConnection.php index 716d1c37..5676791a 100644 --- a/lib/Predis/Network/ComposableStreamConnection.php +++ b/lib/Predis/Network/ComposableStreamConnection.php @@ -6,7 +6,7 @@ use Predis\IConnectionParameters; use Predis\CommunicationException; use Predis\Commands\ICommand; use Predis\Protocols\IProtocolProcessor; -use Predis\Protocols\TextProtocol; +use Predis\Protocols\Text\TextProtocol; class ComposableStreamConnection extends StreamConnection implements IConnectionComposable { private $_protocol; diff --git a/lib/Predis/Protocols/IProtocolProcessor.php b/lib/Predis/Protocols/IProtocolProcessor.php index 7b323ea0..e974ec16 100644 --- a/lib/Predis/Protocols/IProtocolProcessor.php +++ b/lib/Predis/Protocols/IProtocolProcessor.php @@ -5,8 +5,7 @@ namespace Predis\Protocols; use Predis\Commands\ICommand; use Predis\Network\IConnectionComposable; -interface IProtocolProcessor { +interface IProtocolProcessor extends IResponseReader { public function write(IConnectionComposable $connection, ICommand $command); - public function read(IConnectionComposable $connection); public function setOption($option, $value); } diff --git a/lib/Predis/Protocols/IResponseReader.php b/lib/Predis/Protocols/IResponseReader.php index 2de2481d..62b3d5d7 100644 --- a/lib/Predis/Protocols/IResponseReader.php +++ b/lib/Predis/Protocols/IResponseReader.php @@ -2,7 +2,8 @@ namespace Predis\Protocols; +use Predis\Network\IConnectionComposable; + interface IResponseReader { - public function setHandler($prefix, IResponseHandler $handler); - public function getHandler($prefix); + public function read(IConnectionComposable $connection); } diff --git a/lib/Predis/Protocols/ComposableTextProtocol.php b/lib/Predis/Protocols/Text/ComposableTextProtocol.php similarity index 92% rename from lib/Predis/Protocols/ComposableTextProtocol.php rename to lib/Predis/Protocols/Text/ComposableTextProtocol.php index 0c664577..a49cce35 100644 --- a/lib/Predis/Protocols/ComposableTextProtocol.php +++ b/lib/Predis/Protocols/Text/ComposableTextProtocol.php @@ -1,8 +1,11 @@ assertTrue($response->queued); - $this->assertEquals(\Predis\Protocols\TextProtocol::QUEUED, (string)$response); + $this->assertEquals(\Predis\Protocols\Text\TextProtocol::QUEUED, (string)$response); } @@ -280,27 +280,27 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase { /* Predis\Protocols\TextResponseReader */ function testResponseReader_OptionIterableMultiBulkReplies() { - $protocol = new Predis\Protocols\ComposableTextProtocol(); + $protocol = new Predis\Protocols\Text\ComposableTextProtocol(); $reader = $protocol->getReader(); $connection = new \Predis\Network\ComposableStreamConnection(RC::getConnectionParameters(), $protocol); $reader->setHandler( - \Predis\Protocols\TextProtocol::PREFIX_MULTI_BULK, - new \Predis\Protocols\ResponseMultiBulkHandler() + \Predis\Protocols\Text\TextProtocol::PREFIX_MULTI_BULK, + new \Predis\Protocols\Text\ResponseMultiBulkHandler() ); $connection->writeBytes("KEYS *\r\n"); $this->assertInternalType('array', $reader->read($connection)); $reader->setHandler( - \Predis\Protocols\TextProtocol::PREFIX_MULTI_BULK, - new \Predis\Protocols\ResponseMultiBulkStreamHandler() + \Predis\Protocols\Text\TextProtocol::PREFIX_MULTI_BULK, + new \Predis\Protocols\Text\ResponseMultiBulkStreamHandler() ); $connection->writeBytes("KEYS *\r\n"); $this->assertInstanceOf('\Iterator', $reader->read($connection)); } function testResponseReader_OptionExceptionOnError() { - $protocol = new Predis\Protocols\ComposableTextProtocol(); + $protocol = new Predis\Protocols\Text\ComposableTextProtocol(); $reader = $protocol->getReader(); $connection = new \Predis\Network\ComposableStreamConnection(RC::getConnectionParameters(), $protocol); @@ -309,8 +309,8 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase { $reader->read($connection); $reader->setHandler( - \Predis\Protocols\TextProtocol::PREFIX_ERROR, - new \Predis\Protocols\ResponseErrorSilentHandler() + \Predis\Protocols\Text\TextProtocol::PREFIX_ERROR, + new \Predis\Protocols\Text\ResponseErrorSilentHandler() ); $connection->writeBytes($rawCmdUnexpected); $errorReply = $reader->read($connection); @@ -318,8 +318,8 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase { $this->assertEquals(RC::EXCEPTION_WRONG_TYPE, $errorReply->message); $reader->setHandler( - \Predis\Protocols\TextProtocol::PREFIX_ERROR, - new \Predis\Protocols\ResponseErrorHandler() + \Predis\Protocols\Text\TextProtocol::PREFIX_ERROR, + new \Predis\Protocols\Text\ResponseErrorHandler() ); RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function() use ($connection, $rawCmdUnexpected) { @@ -330,7 +330,7 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase { } function testResponseReader_EmptyBulkResponse() { - $protocol = new \Predis\Protocols\ComposableTextProtocol(); + $protocol = new \Predis\Protocols\Text\ComposableTextProtocol(); $connection = new \Predis\Network\ComposableStreamConnection(RC::getConnectionParameters(), $protocol); $client = new \Predis\Client($connection);