mirror of
https://github.com/predis/predis.git
synced 2026-08-31 04:35:05 +00:00
more code formatting
This commit is contained in:
@@ -18,11 +18,12 @@ return (new PhpCsFixer\Config)
|
||||
'phpdoc_separation' => false,
|
||||
'phpdoc_annotation_without_dot' => false,
|
||||
'no_superfluous_phpdoc_tags' => false,
|
||||
'no_unneeded_curly_braces' => false,
|
||||
'global_namespace_import' => true,
|
||||
'yoda_style' => false,
|
||||
'single_line_throw' => false,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'increment_style' => ['style' => 'post'],
|
||||
'increment_style' => false,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
|
||||
+6
-12
@@ -13,7 +13,6 @@
|
||||
namespace Predis;
|
||||
|
||||
use ArrayIterator;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use Predis\Command\CommandInterface;
|
||||
@@ -45,7 +44,7 @@ use Traversable;
|
||||
*/
|
||||
class Client implements ClientInterface, IteratorAggregate
|
||||
{
|
||||
const VERSION = '2.1.1';
|
||||
public const VERSION = '2.1.1';
|
||||
|
||||
/** @var OptionsInterface */
|
||||
private $options;
|
||||
@@ -62,8 +61,8 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
*/
|
||||
public function __construct($parameters = null, $options = null)
|
||||
{
|
||||
$this->options = static::createOptions($options ?? new Options);
|
||||
$this->connection = static::createConnection($this->options, $parameters ?? new Parameters);
|
||||
$this->options = static::createOptions($options ?? new Options());
|
||||
$this->connection = static::createConnection($this->options, $parameters ?? new Parameters());
|
||||
$this->commands = $this->options->commands;
|
||||
}
|
||||
|
||||
@@ -72,9 +71,8 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
*
|
||||
* @param array|OptionsInterface $options Set of client options
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return OptionsInterface
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected static function createOptions($options)
|
||||
{
|
||||
@@ -108,9 +106,8 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
* @param OptionsInterface $options Client options container
|
||||
* @param mixed $parameters Connection parameters
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return ConnectionInterface
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected static function createConnection(OptionsInterface $options, $parameters)
|
||||
{
|
||||
@@ -337,9 +334,8 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
* @param CommandInterface $command Redis command that generated the error.
|
||||
* @param ErrorResponseInterface $response Instance of the error response.
|
||||
*
|
||||
* @throws ServerException
|
||||
*
|
||||
* @return mixed
|
||||
* @throws ServerException
|
||||
*/
|
||||
protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response)
|
||||
{
|
||||
@@ -387,11 +383,9 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
|
||||
return $this->$initializer($arg0, $arg1);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
default:
|
||||
return $this->$initializer($this, $argv);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,9 +23,6 @@ abstract class ClusterStrategy implements StrategyInterface
|
||||
{
|
||||
protected $commands;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->commands = $this->getDefaultCommands();
|
||||
|
||||
@@ -50,7 +50,7 @@ class ZUNIONSTORE extends RedisCommand
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
// support old `$options` array for backwards compatibility
|
||||
if (! isset($arguments[3]) && (isset($arguments[2]['weights']) || isset($arguments[2]['aggregate']))) {
|
||||
if (!isset($arguments[3]) && (isset($arguments[2]['weights']) || isset($arguments[2]['aggregate']))) {
|
||||
$options = array_pop($arguments);
|
||||
array_push($arguments, $options['weights'] ?? []);
|
||||
array_push($arguments, $options['aggregate'] ?? 'sum');
|
||||
|
||||
@@ -273,7 +273,7 @@ class SentinelReplication implements ReplicationInterface
|
||||
|
||||
// don't leak password from between configurations
|
||||
// https://github.com/predis/predis/pull/807/#discussion_r985764770
|
||||
if (! isset($parameters['password'])) {
|
||||
if (!isset($parameters['password'])) {
|
||||
$parameters['password'] = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ use Predis\Connection;
|
||||
use Predis\Response;
|
||||
use PredisTestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class RedisClusterTest extends PredisTestCase
|
||||
{
|
||||
/**
|
||||
@@ -1306,22 +1303,22 @@ class RedisClusterTest extends PredisTestCase
|
||||
/**
|
||||
* @medium
|
||||
* @group disconnected
|
||||
* @group slow
|
||||
* @group slow
|
||||
*/
|
||||
public function testRetryCommandSuccessOnClusterDownErrors()
|
||||
{
|
||||
$clusterDownError= new Response\Error('CLUSTERDOWN') ;
|
||||
$clusterDownError = new Response\Error('CLUSTERDOWN');
|
||||
|
||||
$command = Command\RawCommand::create('get', 'node:1001');
|
||||
$command = Command\RawCommand::create('get', 'node:1001');
|
||||
|
||||
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379');
|
||||
$connection1->expects($this->exactly(3))
|
||||
->method('executeCommand')
|
||||
->with($command)
|
||||
->will($this->onConsecutiveCalls(
|
||||
$clusterDownError,
|
||||
$clusterDownError,
|
||||
'foobar'));
|
||||
$clusterDownError,
|
||||
$clusterDownError,
|
||||
'foobar'));
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
$cluster->useClusterSlots(false);
|
||||
@@ -1334,14 +1331,14 @@ class RedisClusterTest extends PredisTestCase
|
||||
/**
|
||||
* @medium
|
||||
* @group disconnected
|
||||
* @group slow
|
||||
* @group slow
|
||||
*/
|
||||
public function testRetryCommandFailureOnClusterDownErrors()
|
||||
{
|
||||
$this->expectException('Predis\Response\ServerException');
|
||||
$this->expectExceptionMessage('CLUSTERDOWN');
|
||||
|
||||
$clusterDownError= new Response\Error('CLUSTERDOWN') ;
|
||||
$clusterDownError = new Response\Error('CLUSTERDOWN');
|
||||
|
||||
$command = Command\RawCommand::create('get', 'node:1001');
|
||||
|
||||
@@ -1350,11 +1347,10 @@ class RedisClusterTest extends PredisTestCase
|
||||
->method('executeCommand')
|
||||
->with($command)
|
||||
->will($this->onConsecutiveCalls(
|
||||
$clusterDownError,
|
||||
$clusterDownError,
|
||||
$clusterDownError
|
||||
));
|
||||
|
||||
$clusterDownError,
|
||||
$clusterDownError,
|
||||
$clusterDownError
|
||||
));
|
||||
|
||||
$cluster = new RedisCluster(new Connection\Factory());
|
||||
$cluster->useClusterSlots(false);
|
||||
@@ -1367,7 +1363,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
/**
|
||||
* @medium
|
||||
* @group disconnected
|
||||
* @group slow
|
||||
* @group slow
|
||||
*/
|
||||
public function testQueryClusterNodeForSlotMapPauseDurationOnRetry()
|
||||
{
|
||||
@@ -1430,15 +1426,15 @@ class RedisClusterTest extends PredisTestCase
|
||||
|
||||
$cluster->setRetryInterval(2000);
|
||||
|
||||
$startTime = time() ;
|
||||
$startTime = time();
|
||||
$cluster->askSlotMap();
|
||||
$endTime = time();
|
||||
$totalTime=$endTime-$startTime;
|
||||
$t1 = $cluster->getRetryInterval() ;
|
||||
$totalTime = $endTime - $startTime;
|
||||
$t1 = $cluster->getRetryInterval();
|
||||
$t2 = $t1 * 2;
|
||||
|
||||
$expectedTime = ($t1 + $t2 )/1000 ; // expected time for 2 retries (fail 1=wait 2s, fail 2=wait 4s , OK)
|
||||
$this->AssertEqualsWithDelta($expectedTime, $totalTime, 1, 'Unexpected execution time') ;
|
||||
$expectedTime = ($t1 + $t2) / 1000; // expected time for 2 retries (fail 1=wait 2s, fail 2=wait 4s , OK)
|
||||
$this->AssertEqualsWithDelta($expectedTime, $totalTime, 1, 'Unexpected execution time');
|
||||
|
||||
$this->assertCount(16384, $cluster->getSlotMap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user