mirror of
https://github.com/predis/predis.git
synced 2026-09-12 19:37:05 +00:00
Codestyle changes (#1437)
This commit is contained in:
committed by
GitHub
parent
cf28b2a997
commit
4b28ab1c74
+4
-4
@@ -478,7 +478,7 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
*
|
||||
* @return Pipeline|array
|
||||
*/
|
||||
protected function createPipeline(array $options = null, $callable = null)
|
||||
protected function createPipeline(?array $options = null, $callable = null)
|
||||
{
|
||||
if (isset($options['atomic']) && $options['atomic']) {
|
||||
$class = Atomic::class;
|
||||
@@ -531,7 +531,7 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
*
|
||||
* @return MultiExecTransaction|array
|
||||
*/
|
||||
protected function createTransaction(array $options = null, $callable = null)
|
||||
protected function createTransaction(?array $options = null, $callable = null)
|
||||
{
|
||||
$transaction = new MultiExecTransaction($this, $options);
|
||||
|
||||
@@ -561,7 +561,7 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
* @param callable|null $preLoopCallback Callback that should be called on client before enter a loop.
|
||||
* @return PushConsumer
|
||||
*/
|
||||
public function push(callable $preLoopCallback = null): PushConsumer
|
||||
public function push(?callable $preLoopCallback = null): PushConsumer
|
||||
{
|
||||
return new PushConsumer($this, $preLoopCallback);
|
||||
}
|
||||
@@ -574,7 +574,7 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
*
|
||||
* @return PubSubConsumer|null
|
||||
*/
|
||||
protected function createPubSub(array $options = null, $callable = null)
|
||||
protected function createPubSub(?array $options = null, $callable = null)
|
||||
{
|
||||
if ($this->connection instanceof RelayConnection) {
|
||||
$pubsub = new RelayPubSubConsumer($this, $options);
|
||||
|
||||
@@ -25,7 +25,7 @@ class PredisStrategy extends ClusterStrategy
|
||||
/**
|
||||
* @param DistributorInterface $distributor Optional distributor instance.
|
||||
*/
|
||||
public function __construct(DistributorInterface $distributor = null)
|
||||
public function __construct(?DistributorInterface $distributor = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class RedisStrategy extends ClusterStrategy
|
||||
/**
|
||||
* @param HashGeneratorInterface $hashGenerator Hash generator instance.
|
||||
*/
|
||||
public function __construct(HashGeneratorInterface $hashGenerator = null)
|
||||
public function __construct(?HashGeneratorInterface $hashGenerator = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
@@ -176,13 +176,13 @@ abstract class CursorBasedIterator implements Iterator
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
if ($this->elements) {
|
||||
$this->extractNext();
|
||||
} elseif ($this->cursor) {
|
||||
goto tryFetch;
|
||||
} else {
|
||||
$this->valid = false;
|
||||
}
|
||||
if ($this->elements) {
|
||||
$this->extractNext();
|
||||
} elseif ($this->cursor) {
|
||||
goto tryFetch;
|
||||
} else {
|
||||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ class XInfoStreamOptions implements ArrayableArgument
|
||||
* @param int|null $count
|
||||
* @return self
|
||||
*/
|
||||
public function full(int $count = null): self
|
||||
public function full(?int $count = null): self
|
||||
{
|
||||
$this->options[] = 'FULL';
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class CommunicationException extends PredisException
|
||||
NodeConnectionInterface $connection,
|
||||
$message = '',
|
||||
$code = 0,
|
||||
Exception $innerException = null
|
||||
?Exception $innerException = null
|
||||
) {
|
||||
parent::__construct(
|
||||
is_null($message) ? '' : $message,
|
||||
|
||||
@@ -43,7 +43,7 @@ class Options implements OptionsInterface
|
||||
/**
|
||||
* @param array $options Named array of client options
|
||||
*/
|
||||
public function __construct(array $options = null)
|
||||
public function __construct(?array $options = null)
|
||||
{
|
||||
$this->input = $options ?? [];
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class PredisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
* @param ParametersInterface $parameters
|
||||
* @param StrategyInterface|null $strategy Optional cluster strategy.
|
||||
*/
|
||||
public function __construct(ParametersInterface $parameters, StrategyInterface $strategy = null)
|
||||
public function __construct(ParametersInterface $parameters, ?StrategyInterface $strategy = null)
|
||||
{
|
||||
$this->connectionParameters = $parameters;
|
||||
$this->strategy = $strategy ?: new PredisStrategy();
|
||||
|
||||
@@ -87,8 +87,8 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
public function __construct(
|
||||
FactoryInterface $connections,
|
||||
ParametersInterface $parameters,
|
||||
StrategyInterface $strategy = null,
|
||||
int $readTimeout = null
|
||||
?StrategyInterface $strategy = null,
|
||||
?int $readTimeout = null
|
||||
) {
|
||||
$this->connections = $connections;
|
||||
$this->connectionParameters = $parameters;
|
||||
@@ -296,7 +296,7 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable
|
||||
*
|
||||
* @param NodeConnectionInterface $connection Optional connection instance.
|
||||
*/
|
||||
public function askSlotMap(NodeConnectionInterface $connection = null)
|
||||
public function askSlotMap(?NodeConnectionInterface $connection = null)
|
||||
{
|
||||
if (!$connection && !$connection = $this->getRandomConnection()) {
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,7 @@ class CompositeStreamConnection extends StreamConnection implements CompositeCon
|
||||
*/
|
||||
public function __construct(
|
||||
ParametersInterface $parameters,
|
||||
ProtocolProcessorInterface $protocol = null
|
||||
?ProtocolProcessorInterface $protocol = null
|
||||
) {
|
||||
$this->parameters = $this->assertParameters($parameters);
|
||||
$this->protocol = $protocol ?: new TextProtocolProcessor();
|
||||
|
||||
@@ -32,7 +32,7 @@ trait RelayMethods
|
||||
* @param string $pattern
|
||||
* @return bool
|
||||
*/
|
||||
public function onInvalidated(?callable $callback, string $pattern = null)
|
||||
public function onInvalidated(?callable $callback, ?string $pattern = null)
|
||||
{
|
||||
return $this->client->onInvalidated($callback, $pattern);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ trait RelayMethods
|
||||
* @param ?int $db
|
||||
* @return bool
|
||||
*/
|
||||
public function flushMemory(string $endpointId = null, int $db = null)
|
||||
public function flushMemory(?string $endpointId = null, ?int $db = null)
|
||||
{
|
||||
return $this->client->flushMemory($endpointId, $db);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class MasterSlaveReplication implements ReplicationInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(ReplicationStrategy $strategy = null)
|
||||
public function __construct(?ReplicationStrategy $strategy = null)
|
||||
{
|
||||
$this->strategy = $strategy ?: new ReplicationStrategy();
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class SentinelReplication implements ReplicationInterface
|
||||
$service,
|
||||
array $sentinels,
|
||||
ConnectionFactoryInterface $connectionFactory,
|
||||
ReplicationStrategy $strategy = null
|
||||
?ReplicationStrategy $strategy = null
|
||||
) {
|
||||
$this->sentinels = $sentinels;
|
||||
$this->service = $service;
|
||||
|
||||
@@ -48,7 +48,7 @@ abstract class AbstractDispatcherLoop implements DispatcherLoopInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setDefaultCallback(callable $callback = null): void
|
||||
public function setDefaultCallback(?callable $callback = null): void
|
||||
{
|
||||
$this->defaultCallback = $callback;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ interface DispatcherLoopInterface
|
||||
* @param callable|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultCallback(callable $callback = null): void;
|
||||
public function setDefaultCallback(?callable $callback = null): void;
|
||||
|
||||
/**
|
||||
* Binds given message type to given callback.
|
||||
|
||||
@@ -55,7 +55,7 @@ class Consumer extends AbstractConsumer
|
||||
* @param array|null $options Options for the consumer initialization.
|
||||
* @throws NotSupportedException
|
||||
*/
|
||||
public function __construct(ClientInterface $client, array $options = null)
|
||||
public function __construct(ClientInterface $client, ?array $options = null)
|
||||
{
|
||||
$this->options = $options ?: [];
|
||||
$this->setSubscriptionContext($client->getConnection());
|
||||
|
||||
@@ -22,7 +22,7 @@ class Consumer extends AbstractConsumer
|
||||
* @param ClientInterface $client
|
||||
* @param callable|null $preLoopCallback Callback that should be called on client before enter a loop.
|
||||
*/
|
||||
public function __construct(ClientInterface $client, callable $preLoopCallback = null)
|
||||
public function __construct(ClientInterface $client, ?callable $preLoopCallback = null)
|
||||
{
|
||||
parent::__construct($client);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class UnexpectedTypeException extends UnexpectedValueException
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
public function __construct(string $type, $message = '', $code = 0, Throwable $previous = null)
|
||||
public function __construct(string $type, $message = '', $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ class CompositeProtocolProcessor implements ProtocolProcessorInterface
|
||||
* @param ResponseReaderInterface $reader Response reader.
|
||||
*/
|
||||
public function __construct(
|
||||
RequestSerializerInterface $serializer = null,
|
||||
ResponseReaderInterface $reader = null
|
||||
?RequestSerializerInterface $serializer = null,
|
||||
?ResponseReaderInterface $reader = null
|
||||
) {
|
||||
$this->setRequestSerializer($serializer ?: new RequestSerializer());
|
||||
$this->setResponseReader($reader ?: new ResponseReader());
|
||||
|
||||
@@ -51,7 +51,7 @@ class MultiExec implements ClientContextInterface
|
||||
* @param ClientInterface $client Client instance used by the transaction.
|
||||
* @param array $options Initialization options.
|
||||
*/
|
||||
public function __construct(ClientInterface $client, array $options = null)
|
||||
public function __construct(ClientInterface $client, ?array $options = null)
|
||||
{
|
||||
$this->assertClient($client);
|
||||
|
||||
|
||||
@@ -36,13 +36,13 @@ abstract class PredisCommandTestCase extends PredisTestCase
|
||||
/**
|
||||
* Returns a new command instance.
|
||||
*
|
||||
* @return Command\CommandInterface
|
||||
* @return CommandInterface
|
||||
*/
|
||||
public function getCommand(): Command\CommandInterface
|
||||
public function getCommand(): CommandInterface
|
||||
{
|
||||
$command = $this->getExpectedCommand();
|
||||
|
||||
return $command instanceof Command\CommandInterface ? $command : new $command();
|
||||
return $command instanceof CommandInterface ? $command : new $command();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,7 +75,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @return RedisCommandConstraint
|
||||
*/
|
||||
public function isRedisCommand($command = null, array $arguments = null): RedisCommandConstraint
|
||||
public function isRedisCommand($command = null, ?array $arguments = null): RedisCommandConstraint
|
||||
{
|
||||
return new RedisCommandConstraint($command, $arguments);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
protected function createClient(array $parameters = null, array $options = null, ?bool $flushdb = true): Client
|
||||
protected function createClient(?array $parameters = null, ?array $options = null, ?bool $flushdb = true): Client
|
||||
{
|
||||
$parameters = array_merge(
|
||||
$this->getDefaultParametersArray(),
|
||||
|
||||
@@ -25,7 +25,7 @@ class RedisCommandConstraint extends PHPUnit\Framework\Constraint\Constraint
|
||||
* @param string|CommandInterface $command Expected command instance or command ID
|
||||
* @param ?array $arguments Expected command arguments
|
||||
*/
|
||||
public function __construct($command, array $arguments = null)
|
||||
public function __construct($command, ?array $arguments = null)
|
||||
{
|
||||
if ($command instanceof CommandInterface) {
|
||||
$this->commandID = strtoupper($command->getId());
|
||||
|
||||
@@ -226,7 +226,7 @@ class ClientTest extends PredisTestCase
|
||||
*/
|
||||
public function testConstructorWithReplicationArgument(): void
|
||||
{
|
||||
$replication = new Connection\Replication\MasterSlaveReplication();
|
||||
$replication = new MasterSlaveReplication();
|
||||
|
||||
$factory = new Connection\Factory();
|
||||
$replication->add($factory->create('tcp://host1?alias=master'));
|
||||
|
||||
@@ -340,7 +340,7 @@ class PredisStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the key space */
|
||||
|
||||
@@ -363,7 +363,7 @@ class RedisStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the key space */
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
|
||||
namespace Predis\Command\Redis;
|
||||
|
||||
use Predis\Command\Redis;
|
||||
|
||||
class SPUBLISH_Test extends Redis\PredisCommandTestCase
|
||||
class SPUBLISH_Test extends PredisCommandTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
@@ -123,7 +123,7 @@ class CommunicationExceptionTest extends PredisTestCase
|
||||
Connection\NodeConnectionInterface $connection,
|
||||
string $message,
|
||||
int $code = 0,
|
||||
Exception $inner = null
|
||||
?Exception $inner = null
|
||||
) {
|
||||
return $this->getMockBuilder('Predis\CommunicationException')
|
||||
->setConstructorArgs([$connection, $message, $code, $inner])
|
||||
|
||||
@@ -28,7 +28,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
*/
|
||||
public function testAcceptsCustomConnectionFactory(): void
|
||||
{
|
||||
/** @var Connection\FactoryInterface */
|
||||
/** @var FactoryInterface */
|
||||
$factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock();
|
||||
$cluster = new RedisCluster($factory, new Parameters());
|
||||
|
||||
@@ -1194,7 +1194,7 @@ class RedisClusterTest extends PredisTestCase
|
||||
))
|
||||
->willReturn($response);
|
||||
|
||||
/** @var Connection\FactoryInterface */
|
||||
/** @var FactoryInterface */
|
||||
$factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock();
|
||||
|
||||
$cluster = new RedisCluster($factory, new Parameters());
|
||||
|
||||
@@ -26,7 +26,7 @@ class ConnectionExceptionTest extends CommunicationExceptionTest
|
||||
NodeConnectionInterface $connection,
|
||||
string $message,
|
||||
int $code = 0,
|
||||
Exception $inner = null
|
||||
?Exception $inner = null
|
||||
) {
|
||||
return new ConnectionException($connection, $message, $code, $inner);
|
||||
}
|
||||
|
||||
@@ -1566,7 +1566,7 @@ class SentinelReplicationTest extends PredisTestCase
|
||||
*
|
||||
* @return SentinelReplication
|
||||
*/
|
||||
protected function getReplicationConnection(string $service, array $sentinels, Connection\FactoryInterface $factory = null): SentinelReplication
|
||||
protected function getReplicationConnection(string $service, array $sentinels, ?Connection\FactoryInterface $factory = null): SentinelReplication
|
||||
{
|
||||
$factory = $factory ?: new Connection\Factory();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ProtocolExceptionTest extends CommunicationExceptionTest
|
||||
NodeConnectionInterface $connection,
|
||||
string $message,
|
||||
int $code = 0,
|
||||
Exception $inner = null
|
||||
?Exception $inner = null
|
||||
): CommunicationException {
|
||||
return new ProtocolException($connection, $message, $code, $inner);
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ class ReplicationStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the connection */
|
||||
|
||||
Reference in New Issue
Block a user