mirror of
https://github.com/predis/predis.git
synced 2026-09-13 03:47:03 +00:00
Apply minor code-styling changes.
This commit is contained in:
+7
-7
@@ -281,8 +281,9 @@ class Client implements ClientInterface
|
||||
{
|
||||
$error = false;
|
||||
|
||||
$command = new RawCommand($arguments);
|
||||
$response = $this->connection->executeCommand($command);
|
||||
$response = $this->connection->executeCommand(
|
||||
new RawCommand($arguments)
|
||||
);
|
||||
|
||||
if ($response instanceof ResponseInterface) {
|
||||
if ($response instanceof ErrorResponseInterface) {
|
||||
@@ -300,10 +301,9 @@ class Client implements ClientInterface
|
||||
*/
|
||||
public function __call($commandID, $arguments)
|
||||
{
|
||||
$command = $this->createCommand($commandID, $arguments);
|
||||
$response = $this->executeCommand($command);
|
||||
|
||||
return $response;
|
||||
return $this->executeCommand(
|
||||
$this->createCommand($commandID, $arguments)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,7 +345,7 @@ class Client implements ClientInterface
|
||||
protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response)
|
||||
{
|
||||
if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
|
||||
$eval = $this->createCommand('eval');
|
||||
$eval = $this->createCommand('EVAL');
|
||||
$eval->setRawArguments($command->getEvalArguments());
|
||||
|
||||
$response = $this->executeCommand($eval);
|
||||
|
||||
@@ -33,6 +33,7 @@ class Consumer implements Iterator
|
||||
public function __construct(ClientInterface $client)
|
||||
{
|
||||
$this->assertClient($client);
|
||||
|
||||
$this->client = $client;
|
||||
|
||||
$this->start();
|
||||
@@ -62,7 +63,7 @@ class Consumer implements Iterator
|
||||
);
|
||||
}
|
||||
|
||||
if ($client->getProfile()->supportsCommand('monitor') === false) {
|
||||
if ($client->getProfile()->supportsCommand('MONITOR') === false) {
|
||||
throw new NotSupportedException("The current profile does not support 'MONITOR'.");
|
||||
}
|
||||
}
|
||||
@@ -72,9 +73,10 @@ class Consumer implements Iterator
|
||||
*/
|
||||
protected function start()
|
||||
{
|
||||
$this->client->executeCommand(
|
||||
$this->client->createCommand('MONITOR')
|
||||
);
|
||||
$this->valid = true;
|
||||
$monitor = $this->client->createCommand('monitor');
|
||||
$this->client->executeCommand($monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ class Consumer extends AbstractConsumer
|
||||
public function __construct(ClientInterface $client, array $options = null)
|
||||
{
|
||||
$this->checkCapabilities($client);
|
||||
|
||||
$this->options = $options ?: array();
|
||||
$this->client = $client;
|
||||
|
||||
@@ -93,9 +94,11 @@ class Consumer extends AbstractConsumer
|
||||
*/
|
||||
protected function writeRequest($method, $arguments)
|
||||
{
|
||||
$arguments = Command::normalizeArguments($arguments);
|
||||
$command = $this->client->createCommand($method, $arguments);
|
||||
$this->client->getConnection()->writeRequest($command);
|
||||
$this->client->getConnection()->writeRequest(
|
||||
$this->client->createCommand($method,
|
||||
Command::normalizeArguments($arguments)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,12 @@ class MultiExec implements ClientContextInterface
|
||||
*/
|
||||
public function __construct(ClientInterface $client, array $options = null)
|
||||
{
|
||||
$this->preconditions($client);
|
||||
$this->configure($client, $options ?: array());
|
||||
$this->assertClient($client);
|
||||
|
||||
$this->client = $client;
|
||||
$this->state = new MultiExecState();
|
||||
|
||||
$this->configure($client, $options ?: array());
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class MultiExec implements ClientContextInterface
|
||||
*
|
||||
* @throws NotSupportedException
|
||||
*/
|
||||
private function preconditions(ClientInterface $client)
|
||||
private function assertClient(ClientInterface $client)
|
||||
{
|
||||
if ($client->getConnection() instanceof AggregateConnectionInterface) {
|
||||
throw new NotSupportedException(
|
||||
@@ -139,7 +139,7 @@ class MultiExec implements ClientContextInterface
|
||||
$discarded = $this->state->isDiscarded();
|
||||
|
||||
if (!$cas || ($cas && $discarded)) {
|
||||
$this->call('multi');
|
||||
$this->call('MULTI');
|
||||
|
||||
if ($discarded) {
|
||||
$this->state->unflag(MultiExecState::CAS);
|
||||
@@ -160,10 +160,9 @@ class MultiExec implements ClientContextInterface
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$command = $this->client->createCommand($method, $arguments);
|
||||
$response = $this->executeCommand($command);
|
||||
|
||||
return $response;
|
||||
return $this->executeCommand(
|
||||
$this->client->createCommand($method, $arguments)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,8 +177,9 @@ class MultiExec implements ClientContextInterface
|
||||
*/
|
||||
protected function call($commandID, array $arguments = array())
|
||||
{
|
||||
$command = $this->client->createCommand($commandID, $arguments);
|
||||
$response = $this->client->executeCommand($command);
|
||||
$response = $this->client->executeCommand(
|
||||
$this->client->createCommand($commandID, $arguments)
|
||||
);
|
||||
|
||||
if ($response instanceof ErrorResponseInterface) {
|
||||
throw new ServerException($response->getMessage());
|
||||
@@ -239,8 +239,7 @@ class MultiExec implements ClientContextInterface
|
||||
throw new ClientException('Sending WATCH after MULTI is not allowed.');
|
||||
}
|
||||
|
||||
$response = $this->call('watch', is_array($keys) ? $keys : array($keys));
|
||||
|
||||
$response = $this->call('WATCH', is_array($keys) ? $keys : array($keys));
|
||||
$this->state->flag(MultiExecState::WATCH);
|
||||
|
||||
return $response;
|
||||
@@ -255,7 +254,7 @@ class MultiExec implements ClientContextInterface
|
||||
{
|
||||
if ($this->state->check(MultiExecState::INITIALIZED | MultiExecState::CAS)) {
|
||||
$this->state->unflag(MultiExecState::CAS);
|
||||
$this->call('multi');
|
||||
$this->call('MULTI');
|
||||
} else {
|
||||
$this->initialize();
|
||||
}
|
||||
@@ -273,11 +272,13 @@ class MultiExec implements ClientContextInterface
|
||||
public function unwatch()
|
||||
{
|
||||
if (!$this->client->getProfile()->supportsCommand('UNWATCH')) {
|
||||
throw new NotSupportedException('UNWATCH is not supported by the current profile.');
|
||||
throw new NotSupportedException(
|
||||
'UNWATCH is not supported by the current profile.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->state->unflag(MultiExecState::WATCH);
|
||||
$this->__call('unwatch', array());
|
||||
$this->__call('UNWATCH', array());
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -291,7 +292,7 @@ class MultiExec implements ClientContextInterface
|
||||
public function discard()
|
||||
{
|
||||
if ($this->state->isInitialized()) {
|
||||
$this->call($this->state->isCAS() ? 'unwatch' : 'discard');
|
||||
$this->call($this->state->isCAS() ? 'UNWATCH' : 'DISCARD');
|
||||
|
||||
$this->reset();
|
||||
$this->state->flag(MultiExecState::DISCARDED);
|
||||
@@ -378,7 +379,7 @@ class MultiExec implements ClientContextInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
$execResponse = $this->call('exec');
|
||||
$execResponse = $this->call('EXEC');
|
||||
|
||||
if ($execResponse === null) {
|
||||
if ($attempts === 0) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class ConsumerTest extends PredisTestCase
|
||||
$profile = $this->getMock('Predis\Profile\ProfileInterface');
|
||||
$profile->expects($this->once())
|
||||
->method('supportsCommand')
|
||||
->with('monitor')
|
||||
->with('MONITOR')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$client = new Client(null, array('profile' => $profile));
|
||||
@@ -64,7 +64,7 @@ class ConsumerTest extends PredisTestCase
|
||||
$client = $this->getMock('Predis\Client', array('createCommand', 'executeCommand'), array($connection));
|
||||
$client->expects($this->once())
|
||||
->method('createCommand')
|
||||
->with('monitor', array())
|
||||
->with('MONITOR', array())
|
||||
->will($this->returnValue($cmdMonitor));
|
||||
$client->expects($this->once())
|
||||
->method('executeCommand')
|
||||
|
||||
Reference in New Issue
Block a user