diff --git a/src/Client.php b/src/Client.php index 710066a3..ab5acfa8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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); diff --git a/src/Cluster/PredisStrategy.php b/src/Cluster/PredisStrategy.php index 574b86f9..04f31b11 100644 --- a/src/Cluster/PredisStrategy.php +++ b/src/Cluster/PredisStrategy.php @@ -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(); diff --git a/src/Cluster/RedisStrategy.php b/src/Cluster/RedisStrategy.php index 8ae5c0f5..dadf782e 100644 --- a/src/Cluster/RedisStrategy.php +++ b/src/Cluster/RedisStrategy.php @@ -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(); diff --git a/src/Collection/Iterator/CursorBasedIterator.php b/src/Collection/Iterator/CursorBasedIterator.php index 946bbc3a..c63b7140 100644 --- a/src/Collection/Iterator/CursorBasedIterator.php +++ b/src/Collection/Iterator/CursorBasedIterator.php @@ -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; + } } /** diff --git a/src/Command/Argument/Stream/XInfoStreamOptions.php b/src/Command/Argument/Stream/XInfoStreamOptions.php index 71967901..02dcea3e 100644 --- a/src/Command/Argument/Stream/XInfoStreamOptions.php +++ b/src/Command/Argument/Stream/XInfoStreamOptions.php @@ -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'; diff --git a/src/CommunicationException.php b/src/CommunicationException.php index 0fc7c07a..9fd69a02 100644 --- a/src/CommunicationException.php +++ b/src/CommunicationException.php @@ -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, diff --git a/src/Configuration/Options.php b/src/Configuration/Options.php index 3fff0412..3cad8e95 100644 --- a/src/Configuration/Options.php +++ b/src/Configuration/Options.php @@ -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 ?? []; } diff --git a/src/Connection/Cluster/PredisCluster.php b/src/Connection/Cluster/PredisCluster.php index 59725b1f..d5834ba3 100644 --- a/src/Connection/Cluster/PredisCluster.php +++ b/src/Connection/Cluster/PredisCluster.php @@ -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(); diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php index 0c47f540..cc6f1fb0 100644 --- a/src/Connection/Cluster/RedisCluster.php +++ b/src/Connection/Cluster/RedisCluster.php @@ -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; diff --git a/src/Connection/CompositeStreamConnection.php b/src/Connection/CompositeStreamConnection.php index ad69cbc1..431663ca 100644 --- a/src/Connection/CompositeStreamConnection.php +++ b/src/Connection/CompositeStreamConnection.php @@ -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(); diff --git a/src/Connection/RelayMethods.php b/src/Connection/RelayMethods.php index a52c4a03..d59dd41f 100644 --- a/src/Connection/RelayMethods.php +++ b/src/Connection/RelayMethods.php @@ -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); } diff --git a/src/Connection/Replication/MasterSlaveReplication.php b/src/Connection/Replication/MasterSlaveReplication.php index fabc7c66..a94283a5 100644 --- a/src/Connection/Replication/MasterSlaveReplication.php +++ b/src/Connection/Replication/MasterSlaveReplication.php @@ -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(); } diff --git a/src/Connection/Replication/SentinelReplication.php b/src/Connection/Replication/SentinelReplication.php index d7aaca36..6a5dfcd8 100644 --- a/src/Connection/Replication/SentinelReplication.php +++ b/src/Connection/Replication/SentinelReplication.php @@ -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; diff --git a/src/Consumer/AbstractDispatcherLoop.php b/src/Consumer/AbstractDispatcherLoop.php index 6b82e5de..8ae80348 100644 --- a/src/Consumer/AbstractDispatcherLoop.php +++ b/src/Consumer/AbstractDispatcherLoop.php @@ -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; } diff --git a/src/Consumer/DispatcherLoopInterface.php b/src/Consumer/DispatcherLoopInterface.php index c913f2e9..3d2e4a77 100644 --- a/src/Consumer/DispatcherLoopInterface.php +++ b/src/Consumer/DispatcherLoopInterface.php @@ -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. diff --git a/src/Consumer/PubSub/Consumer.php b/src/Consumer/PubSub/Consumer.php index 11935a1b..13726b78 100644 --- a/src/Consumer/PubSub/Consumer.php +++ b/src/Consumer/PubSub/Consumer.php @@ -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()); diff --git a/src/Consumer/Push/Consumer.php b/src/Consumer/Push/Consumer.php index f656c491..793233ca 100644 --- a/src/Consumer/Push/Consumer.php +++ b/src/Consumer/Push/Consumer.php @@ -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); diff --git a/src/Protocol/Parser/UnexpectedTypeException.php b/src/Protocol/Parser/UnexpectedTypeException.php index 4e7c700b..f05e4a05 100644 --- a/src/Protocol/Parser/UnexpectedTypeException.php +++ b/src/Protocol/Parser/UnexpectedTypeException.php @@ -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; diff --git a/src/Protocol/Text/CompositeProtocolProcessor.php b/src/Protocol/Text/CompositeProtocolProcessor.php index 3f7df02e..19494c05 100644 --- a/src/Protocol/Text/CompositeProtocolProcessor.php +++ b/src/Protocol/Text/CompositeProtocolProcessor.php @@ -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()); diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index 3edc1a0b..83f81c55 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -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); diff --git a/tests/PHPUnit/PredisCommandTestCase.php b/tests/PHPUnit/PredisCommandTestCase.php index 7080173f..65ea899c 100644 --- a/tests/PHPUnit/PredisCommandTestCase.php +++ b/tests/PHPUnit/PredisCommandTestCase.php @@ -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(); } /** diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index bd6937eb..70477622 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -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(), diff --git a/tests/PHPUnit/RedisCommandConstraint.php b/tests/PHPUnit/RedisCommandConstraint.php index 9a8e17b9..2466c7e0 100644 --- a/tests/PHPUnit/RedisCommandConstraint.php +++ b/tests/PHPUnit/RedisCommandConstraint.php @@ -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()); diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index bbc17762..1e85053c 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -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')); diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 77c22345..f0b4bb77 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -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 */ diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index e2112f19..91c24eda 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -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 */ diff --git a/tests/Predis/Command/Redis/SPUBLISH_Test.php b/tests/Predis/Command/Redis/SPUBLISH_Test.php index 89b14bdd..a71cdb81 100644 --- a/tests/Predis/Command/Redis/SPUBLISH_Test.php +++ b/tests/Predis/Command/Redis/SPUBLISH_Test.php @@ -12,9 +12,7 @@ namespace Predis\Command\Redis; -use Predis\Command\Redis; - -class SPUBLISH_Test extends Redis\PredisCommandTestCase +class SPUBLISH_Test extends PredisCommandTestCase { /** * {@inheritDoc} diff --git a/tests/Predis/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index 28d1d37b..4512bdf4 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -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]) diff --git a/tests/Predis/Connection/Cluster/RedisClusterTest.php b/tests/Predis/Connection/Cluster/RedisClusterTest.php index f32fc833..94c72926 100644 --- a/tests/Predis/Connection/Cluster/RedisClusterTest.php +++ b/tests/Predis/Connection/Cluster/RedisClusterTest.php @@ -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()); diff --git a/tests/Predis/Connection/ConnectionExceptionTest.php b/tests/Predis/Connection/ConnectionExceptionTest.php index 066b7b32..e1f06bac 100644 --- a/tests/Predis/Connection/ConnectionExceptionTest.php +++ b/tests/Predis/Connection/ConnectionExceptionTest.php @@ -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); } diff --git a/tests/Predis/Connection/Replication/SentinelReplicationTest.php b/tests/Predis/Connection/Replication/SentinelReplicationTest.php index f79f6ac0..7723214b 100644 --- a/tests/Predis/Connection/Replication/SentinelReplicationTest.php +++ b/tests/Predis/Connection/Replication/SentinelReplicationTest.php @@ -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(); diff --git a/tests/Predis/Protocol/ProtocolExceptionTest.php b/tests/Predis/Protocol/ProtocolExceptionTest.php index c36fb0c0..5fe87abc 100644 --- a/tests/Predis/Protocol/ProtocolExceptionTest.php +++ b/tests/Predis/Protocol/ProtocolExceptionTest.php @@ -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); } diff --git a/tests/Predis/Replication/ReplicationStrategyTest.php b/tests/Predis/Replication/ReplicationStrategyTest.php index 128bbce4..ca9ae4bd 100644 --- a/tests/Predis/Replication/ReplicationStrategyTest.php +++ b/tests/Predis/Replication/ReplicationStrategyTest.php @@ -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 */