mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
Reorganize the Predis\Protocols namespace.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Commands\ICommand;
|
||||
use Predis\Protocols\IResponseReader;
|
||||
use Predis\Protocols\ICommandSerializer;
|
||||
use Predis\Protocols\IProtocolProcessorExtended;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ComposableTextProtocol implements IProtocolProcessorExtended {
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseBulkHandler implements IResponseHandler {
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\ServerException;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseErrorHandler implements IResponseHandler {
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\ResponseError;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseErrorSilentHandler implements IResponseHandler {
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseIntegerHandler implements IResponseHandler {
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseMultiBulkHandler implements IResponseHandler {
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
use Predis\Iterators\MultiBulkResponseSimple;
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\ResponseQueued;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class ResponseStatusHandler implements IResponseHandler {
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Commands\ICommand;
|
||||
use Predis\Protocols\ICommandSerializer;
|
||||
|
||||
class TextCommandSerializer implements ICommandSerializer {
|
||||
public function serialize(ICommand $command) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ResponseError;
|
||||
@@ -8,6 +8,7 @@ use Predis\ResponseQueued;
|
||||
use Predis\ServerException;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Commands\ICommand;
|
||||
use Predis\Protocols\IProtocolProcessor;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
use Predis\Iterators\MultiBulkResponseSimple;
|
||||
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocols;
|
||||
namespace Predis\Protocols\Text;
|
||||
|
||||
use Predis\Helpers;
|
||||
use Predis\ProtocolException;
|
||||
use Predis\Protocols\IResponseReader;
|
||||
use Predis\Protocols\IResponseHandler;
|
||||
use Predis\Network\IConnectionComposable;
|
||||
|
||||
class TextResponseReader implements IResponseReader {
|
||||
+12
-12
@@ -164,7 +164,7 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
function testResponseQueued() {
|
||||
$response = new \Predis\ResponseQueued();
|
||||
$this->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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user