diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5bc6f11c0..7a82ca251 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,7 @@ jobs: - '8.1' - '8.2' - '8.3' + - '8.4' redis: - 3 - 4 @@ -69,7 +70,7 @@ jobs: run: vendor/bin/phpunit --coverage-clover build/logs/clover-default.xml --coverage-filter ./src - name: Run tests using Relay - if: ${{ matrix.redis >= '6' }} + if: ${{ matrix.php != '8.4' && matrix.redis >= '6' }} run: vendor/bin/phpunit -c phpunit.relay.xml - name: Run tests using Relay with coverage diff --git a/src/Client.php b/src/Client.php index c73ff2e51..7c0b4add3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -472,7 +472,7 @@ public function pipeline(...$arguments) * * @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; @@ -520,12 +520,12 @@ public function transaction(...$arguments) /** * Actual transaction context initializer method. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable used to execute the context. + * @param array|null $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. * * @return MultiExecTransaction|array */ - protected function createTransaction(array $options = null, $callable = null) + protected function createTransaction(?array $options = null, $callable = null) { $transaction = new MultiExecTransaction($this, $options); @@ -552,12 +552,12 @@ public function pubSubLoop(...$arguments) /** * Actual publish/subscribe context initializer method. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable used to execute the context. + * @param array|null $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. * * @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/ClientContextInterface.php b/src/ClientContextInterface.php index e443ee5d1..d6cb74512 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -65,8 +65,8 @@ * @method $this randomkey() * @method $this rename($key, $target) * @method $this renamenx($key, $target) - * @method $this scan($cursor, array $options = null) - * @method $this sort($key, array $options = null) + * @method $this scan($cursor, ?array $options = null) + * @method $this sort($key, ?array $options = null) * @method $this sort_ro(string $key, ?string $byPattern = null, ?LimitOffsetCount $limit = null, array $getPatterns = [], ?string $sorting = null, bool $alpha = false) * @method $this ttl($key) * @method $this type($key) @@ -163,7 +163,7 @@ * @method $this hmget($key, array $fields) * @method $this hmset($key, array $dictionary) * @method $this hrandfield(string $key, int $count = 1, bool $withValues = false) - * @method $this hscan($key, $cursor, array $options = null) + * @method $this hscan($key, $cursor, ?array $options = null) * @method $this hset($key, $field, $value) * @method $this hsetnx($key, $field, $value) * @method $this hvals($key) @@ -225,7 +225,7 @@ * @method $this spop($key, $count = null) * @method $this srandmember($key, $count = null) * @method $this srem($key, $member) - * @method $this sscan($key, $cursor, array $options = null) + * @method $this sscan($key, $cursor, ?array $options = null) * @method $this sunion(array|string $keys) * @method $this sunionstore($destination, array|string $keys) * @method $this tdigestadd(string $key, float ...$value) @@ -255,7 +255,7 @@ * @method $this tsdecrby(string $key, float $value, ?DecrByArguments $arguments = null) * @method $this tsdel(string $key, int $fromTimestamp, int $toTimestamp) * @method $this tsdeleterule(string $sourceKey, string $destKey) - * @method $this tsget(string $key, GetArguments $arguments = null) + * @method $this tsget(string $key, ?GetArguments $arguments = null) * @method $this tsincrby(string $key, float $value, ?IncrByArguments $arguments = null) * @method $this tsinfo(string $key, ?InfoArguments $arguments = null) * @method $this tsmadd(mixed ...$keyTimestampValue) @@ -277,22 +277,22 @@ * @method $this zmpop(array $keys, string $modifier = 'min', int $count = 1) * @method $this zmscore(string $key, string ...$member) * @method $this zrandmember(string $key, int $count = 1, bool $withScores = false) - * @method $this zrange($key, $start, $stop, array $options = null) - * @method $this zrangebyscore($key, $min, $max, array $options = null) + * @method $this zrange($key, $start, $stop, ?array $options = null) + * @method $this zrangebyscore($key, $min, $max, ?array $options = null) * @method $this zrangestore(string $destination, string $source, int|string $min, string|int $max, string|bool $by = false, bool $reversed = false, bool $limit = false, int $offset = 0, int $count = 0) * @method $this zrank($key, $member) * @method $this zrem($key, $member) * @method $this zremrangebyrank($key, $start, $stop) * @method $this zremrangebyscore($key, $min, $max) - * @method $this zrevrange($key, $start, $stop, array $options = null) - * @method $this zrevrangebyscore($key, $max, $min, array $options = null) + * @method $this zrevrange($key, $start, $stop, ?array $options = null) + * @method $this zrevrangebyscore($key, $max, $min, ?array $options = null) * @method $this zrevrank($key, $member) * @method $this zunion(array $keys, int[] $weights = [], string $aggregate = 'sum', bool $withScores = false) * @method $this zunionstore(string $destination, array $keys, int[] $weights = [], string $aggregate = 'sum') * @method $this zscore($key, $member) - * @method $this zscan($key, $cursor, array $options = null) - * @method $this zrangebylex($key, $start, $stop, array $options = null) - * @method $this zrevrangebylex($key, $start, $stop, array $options = null) + * @method $this zscan($key, $cursor, ?array $options = null) + * @method $this zrangebylex($key, $start, $stop, ?array $options = null) + * @method $this zrevrangebylex($key, $start, $stop, ?array $options = null) * @method $this zremrangebylex($key, $min, $max) * @method $this zlexcount($key, $min, $max) * @method $this pexpiretime(string $key) @@ -312,7 +312,7 @@ * @method $this evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null) * @method $this evalsha_ro(string $sha1, array $keys, ...$argument) * @method $this script($subcommand, $argument = null) - * @method $this shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) + * @method $this shutdown(?bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) * @method $this auth($password) * @method $this echo($message) * @method $this ping($message = null) @@ -335,8 +335,8 @@ * @method $this geohash($key, array $members) * @method $this geopos($key, array $members) * @method $this geodist($key, $member1, $member2, $unit = null) - * @method $this georadius($key, $longitude, $latitude, $radius, $unit, array $options = null) - * @method $this georadiusbymember($key, $member, $radius, $unit, array $options = null) + * @method $this georadius($key, $longitude, $latitude, $radius, $unit, ?array $options = null) + * @method $this georadiusbymember($key, $member, $radius, $unit, ?array $options = null) * @method $this geosearch(string $key, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $withCoord = false, bool $withDist = false, bool $withHash = false) * @method $this geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false) * diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 5250dabd5..e27c43f18 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -74,8 +74,8 @@ * @method string|null randomkey() * @method mixed rename(string $key, string $target) * @method int renamenx(string $key, string $target) - * @method array scan($cursor, array $options = null) - * @method array sort(string $key, array $options = null) + * @method array scan($cursor, ?array $options = null) + * @method array sort(string $key, ?array $options = null) * @method array sort_ro(string $key, ?string $byPattern = null, ?LimitOffsetCount $limit = null, array $getPatterns = [], ?string $sorting = null, bool $alpha = false) * @method int ttl(string $key) * @method mixed type(string $key) @@ -172,7 +172,7 @@ * @method array hmget(string $key, array $fields) * @method mixed hmset(string $key, array $dictionary) * @method array hrandfield(string $key, int $count = 1, bool $withValues = false) - * @method array hscan(string $key, $cursor, array $options = null) + * @method array hscan(string $key, $cursor, ?array $options = null) * @method int hset(string $key, string $field, string $value) * @method int hsetnx(string $key, string $field, string $value) * @method array hvals(string $key) @@ -231,10 +231,10 @@ * @method string[] smembers(string $key) * @method array smismember(string $key, string ...$members) * @method int smove(string $source, string $destination, string $member) - * @method string|array|null spop(string $key, int $count = null) - * @method string|null srandmember(string $key, int $count = null) + * @method string|array|null spop(string $key, ?int $count = null) + * @method string|null srandmember(string $key, ?int $count = null) * @method int srem(string $key, array|string $member) - * @method array sscan(string $key, int $cursor, array $options = null) + * @method array sscan(string $key, int $cursor, ?array $options = null) * @method string[] sunion(array|string $keys) * @method int sunionstore(string $destination, array|string $keys) * @method int touch(string[]|string $keyOrKeys, string ...$keys = null) @@ -265,7 +265,7 @@ * @method int tsdecrby(string $key, float $value, ?DecrByArguments $arguments = null) * @method int tsdel(string $key, int $fromTimestamp, int $toTimestamp) * @method Status tsdeleterule(string $sourceKey, string $destKey) - * @method array tsget(string $key, GetArguments $arguments = null) + * @method array tsget(string $key, ?GetArguments $arguments = null) * @method int tsincrby(string $key, float $value, ?IncrByArguments $arguments = null) * @method array tsinfo(string $key, ?InfoArguments $arguments = null) * @method array tsmadd(mixed ...$keyTimestampValue) @@ -275,12 +275,12 @@ * @method array tsqueryindex(string ...$filterExpression) * @method array tsrange(string $key, $fromTimestamp, $toTimestamp, ?RangeArguments $arguments = null) * @method array tsrevrange(string $key, $fromTimestamp, $toTimestamp, ?RangeArguments $arguments = null) - * @method string xadd(string $key, array $dictionary, string $id = '*', array $options = null) + * @method string xadd(string $key, array $dictionary, string $id = '*', ?array $options = null) * @method int xdel(string $key, string ...$id) * @method int xlen(string $key) * @method array xrevrange(string $key, string $end, string $start, ?int $count = null) * @method array xrange(string $key, string $start, string $end, ?int $count = null) - * @method string xtrim(string $key, array|string $strategy, string $threshold, array $options = null) + * @method string xtrim(string $key, array|string $strategy, string $threshold, ?array $options = null) * @method int zadd(string $key, array $membersAndScoresDictionary) * @method int zcard(string $key) * @method string zcount(string $key, int|string $min, int|string $max) @@ -295,22 +295,22 @@ * @method array zpopmin(string $key, int $count = 1) * @method array zpopmax(string $key, int $count = 1) * @method mixed zrandmember(string $key, int $count = 1, bool $withScores = false) - * @method array zrange(string $key, int|string $start, int|string $stop, array $options = null) - * @method array zrangebyscore(string $key, int|string $min, int|string $max, array $options = null) + * @method array zrange(string $key, int|string $start, int|string $stop, ?array $options = null) + * @method array zrangebyscore(string $key, int|string $min, int|string $max, ?array $options = null) * @method int zrangestore(string $destination, string $source, int|string $min, int|string $max, string|bool $by = false, bool $reversed = false, bool $limit = false, int $offset = 0, int $count = 0) * @method int|null zrank(string $key, string $member) * @method int zrem(string $key, string ...$member) * @method int zremrangebyrank(string $key, int|string $start, int|string $stop) * @method int zremrangebyscore(string $key, int|string $min, int|string $max) - * @method array zrevrange(string $key, int|string $start, int|string $stop, array $options = null) - * @method array zrevrangebyscore(string $key, int|string $max, int|string $min, array $options = null) + * @method array zrevrange(string $key, int|string $start, int|string $stop, ?array $options = null) + * @method array zrevrangebyscore(string $key, int|string $max, int|string $min, ?array $options = null) * @method int|null zrevrank(string $key, string $member) * @method array zunion(array $keys, int[] $weights = [], string $aggregate = 'sum', bool $withScores = false) * @method int zunionstore(string $destination, array $keys, int[] $weights = [], string $aggregate = 'sum') * @method string|null zscore(string $key, string $member) - * @method array zscan(string $key, int $cursor, array $options = null) - * @method array zrangebylex(string $key, string $start, string $stop, array $options = null) - * @method array zrevrangebylex(string $key, string $start, string $stop, array $options = null) + * @method array zscan(string $key, int $cursor, ?array $options = null) + * @method array zrangebylex(string $key, string $start, string $stop, ?array $options = null) + * @method array zrevrangebylex(string $key, string $start, string $stop, ?array $options = null) * @method int zremrangebylex(string $key, string $min, string $max) * @method int zlexcount(string $key, string $min, string $max) * @method int pexpiretime(string $key) @@ -330,10 +330,10 @@ * @method mixed evalsha(string $script, int $numkeys, string ...$keyOrArg = null) * @method mixed evalsha_ro(string $sha1, array $keys, ...$argument) * @method mixed script($subcommand, $argument = null) - * @method Status shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) + * @method Status shutdown(?bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) * @method mixed auth(string $password) * @method string echo(string $message) - * @method mixed ping(string $message = null) + * @method mixed ping(?string $message = null) * @method mixed select(int $database) * @method mixed bgrewriteaof() * @method mixed bgsave() @@ -353,8 +353,8 @@ * @method array geohash(string $key, array $members) * @method array geopos(string $key, array $members) * @method string|null geodist(string $key, $member1, $member2, $unit = null) - * @method array georadius(string $key, $longitude, $latitude, $radius, $unit, array $options = null) - * @method array georadiusbymember(string $key, $member, $radius, $unit, array $options = null) + * @method array georadius(string $key, $longitude, $latitude, $radius, $unit, ?array $options = null) + * @method array georadiusbymember(string $key, $member, $radius, $unit, ?array $options = null) * @method array geosearch(string $key, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $withCoord = false, bool $withDist = false, bool $withHash = false) * @method int geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false) * diff --git a/src/Cluster/PredisStrategy.php b/src/Cluster/PredisStrategy.php index 574b86f9e..084c52585 100644 --- a/src/Cluster/PredisStrategy.php +++ b/src/Cluster/PredisStrategy.php @@ -23,9 +23,9 @@ class PredisStrategy extends ClusterStrategy protected $distributor; /** - * @param DistributorInterface $distributor Optional distributor instance. + * @param DistributorInterface|null $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 8ae5c0f5e..cf1fbafed 100644 --- a/src/Cluster/RedisStrategy.php +++ b/src/Cluster/RedisStrategy.php @@ -25,9 +25,9 @@ class RedisStrategy extends ClusterStrategy protected $hashGenerator; /** - * @param HashGeneratorInterface $hashGenerator Hash generator instance. + * @param HashGeneratorInterface|null $hashGenerator Hash generator instance. */ - public function __construct(HashGeneratorInterface $hashGenerator = null) + public function __construct(?HashGeneratorInterface $hashGenerator = null) { parent::__construct(); diff --git a/src/Command/Redis/Container/FunctionContainer.php b/src/Command/Redis/Container/FunctionContainer.php index 8f2a673d1..dfa309eea 100644 --- a/src/Command/Redis/Container/FunctionContainer.php +++ b/src/Command/Redis/Container/FunctionContainer.php @@ -19,9 +19,9 @@ * @method string dump() * @method Status flush(?string $mode = null) * @method Status kill() - * @method array list(string $libraryNamePattern = null, bool $withCode = false) + * @method array list(?string $libraryNamePattern = null, bool $withCode = false) * @method string load(string $functionCode, bool $replace = 'false') - * @method Status restore(string $value, string $policy = null) + * @method Status restore(string $value, ?string $policy = null) * @method array stats() */ class FunctionContainer extends AbstractContainer diff --git a/src/Command/Strategy/SubcommandStrategyResolver.php b/src/Command/Strategy/SubcommandStrategyResolver.php index cda84268e..b714d5276 100644 --- a/src/Command/Strategy/SubcommandStrategyResolver.php +++ b/src/Command/Strategy/SubcommandStrategyResolver.php @@ -23,7 +23,7 @@ class SubcommandStrategyResolver implements StrategyResolverInterface */ private $separator; - public function __construct(string $separator = null) + public function __construct(?string $separator = null) { $this->separator = $separator; } diff --git a/src/CommunicationException.php b/src/CommunicationException.php index 0fc7c07a6..9fd69a021 100644 --- a/src/CommunicationException.php +++ b/src/CommunicationException.php @@ -32,7 +32,7 @@ public function __construct( 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 3fff04129..7ff7f26e3 100644 --- a/src/Configuration/Options.php +++ b/src/Configuration/Options.php @@ -41,9 +41,9 @@ class Options implements OptionsInterface protected $input; /** - * @param array $options Named array of client options + * @param array|null $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 c30fd09d3..7d5658611 100644 --- a/src/Connection/Cluster/PredisCluster.php +++ b/src/Connection/Cluster/PredisCluster.php @@ -50,9 +50,9 @@ class PredisCluster implements ClusterInterface, IteratorAggregate, Countable private $distributor; /** - * @param StrategyInterface $strategy Optional cluster strategy. + * @param StrategyInterface|null $strategy Optional cluster strategy. */ - public function __construct(StrategyInterface $strategy = null) + public function __construct(?StrategyInterface $strategy = null) { $this->strategy = $strategy ?: new PredisStrategy(); $this->distributor = $this->strategy->getDistributor(); diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php index 0287de2ac..b44360bb9 100644 --- a/src/Connection/Cluster/RedisCluster.php +++ b/src/Connection/Cluster/RedisCluster.php @@ -65,12 +65,12 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable private $retryInterval = 10; /** - * @param FactoryInterface $connections Optional connection factory. - * @param StrategyInterface $strategy Optional cluster strategy. + * @param FactoryInterface $connections Optional connection factory. + * @param StrategyInterface|null $strategy Optional cluster strategy. */ public function __construct( FactoryInterface $connections, - StrategyInterface $strategy = null + ?StrategyInterface $strategy = null ) { $this->connections = $connections; $this->strategy = $strategy ?: new RedisClusterStrategy(); @@ -271,9 +271,9 @@ private function queryClusterNodeForSlotMap(NodeConnectionInterface $connection) * the CLUSTER SLOTS command against the specified node or a random one from * the pool. * - * @param NodeConnectionInterface $connection Optional connection instance. + * @param NodeConnectionInterface|null $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 ad69cbc12..db1ba9418 100644 --- a/src/Connection/CompositeStreamConnection.php +++ b/src/Connection/CompositeStreamConnection.php @@ -26,12 +26,12 @@ class CompositeStreamConnection extends StreamConnection implements CompositeCon protected $protocol; /** - * @param ParametersInterface $parameters Initialization parameters for the connection. - * @param ProtocolProcessorInterface $protocol Protocol processor. + * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ProtocolProcessorInterface|null $protocol Protocol processor. */ 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 a52c4a035..07e7c13ad 100644 --- a/src/Connection/RelayMethods.php +++ b/src/Connection/RelayMethods.php @@ -28,11 +28,11 @@ public function onFlushed(?callable $callback) /** * Registers a new `invalidated` event listener. * - * @param callable $callback - * @param string $pattern + * @param callable $callback + * @param string|null $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 @@ public function maxMemory() * @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 9d57a5ac3..31897ed3e 100644 --- a/src/Connection/Replication/MasterSlaveReplication.php +++ b/src/Connection/Replication/MasterSlaveReplication.php @@ -72,7 +72,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 dce18f6b7..573633332 100644 --- a/src/Connection/Replication/SentinelReplication.php +++ b/src/Connection/Replication/SentinelReplication.php @@ -117,13 +117,13 @@ class SentinelReplication implements ReplicationInterface * @param string $service Name of the service for autodiscovery. * @param array $sentinels Sentinel servers connection parameters. * @param ConnectionFactoryInterface $connectionFactory Connection factory instance. - * @param ReplicationStrategy $strategy Replication strategy instance. + * @param ReplicationStrategy|null $strategy Replication strategy instance. */ public function __construct( $service, array $sentinels, ConnectionFactoryInterface $connectionFactory, - ReplicationStrategy $strategy = null + ?ReplicationStrategy $strategy = null ) { $this->sentinels = $sentinels; $this->service = $service; diff --git a/src/Protocol/Text/CompositeProtocolProcessor.php b/src/Protocol/Text/CompositeProtocolProcessor.php index 3f7df02e5..01c7e4548 100644 --- a/src/Protocol/Text/CompositeProtocolProcessor.php +++ b/src/Protocol/Text/CompositeProtocolProcessor.php @@ -37,12 +37,12 @@ class CompositeProtocolProcessor implements ProtocolProcessorInterface protected $reader; /** - * @param RequestSerializerInterface $serializer Request serializer. - * @param ResponseReaderInterface $reader Response reader. + * @param RequestSerializerInterface|null $serializer Request serializer. + * @param ResponseReaderInterface|null $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/PubSub/Consumer.php b/src/PubSub/Consumer.php index b52673232..d32178b6a 100644 --- a/src/PubSub/Consumer.php +++ b/src/PubSub/Consumer.php @@ -28,9 +28,9 @@ class Consumer extends AbstractConsumer /** * @param ClientInterface $client Client instance used by the consumer. - * @param array $options Options for the consumer initialization. + * @param array|null $options Options for the consumer initialization. */ - public function __construct(ClientInterface $client, array $options = null) + public function __construct(ClientInterface $client, ?array $options = null) { $this->checkCapabilities($client); diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index 32ac1e123..65b7545bc 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -49,9 +49,9 @@ class MultiExec implements ClientContextInterface /** * @param ClientInterface $client Client instance used by the transaction. - * @param array $options Initialization options. + * @param array|null $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/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index 4ad148c15..49ab922a1 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -74,7 +74,7 @@ protected function sleep(float $seconds): void * * @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); } @@ -243,7 +243,7 @@ protected function getCommandFactory(): Command\Factory * * @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 d4e0b4ec1..8cb77e18b 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/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 70d492f49..f8a20724b 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -325,7 +325,7 @@ protected function getClusterStrategy(): StrategyInterface * * @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 d21b0b3bc..36846753a 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -348,7 +348,7 @@ protected function getClusterStrategy(): StrategyInterface * * @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/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index c58e677a0..f6e588bdf 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -123,7 +123,7 @@ protected function createMockException( 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/ConnectionExceptionTest.php b/tests/Predis/Connection/ConnectionExceptionTest.php index 066b7b324..e1f06baca 100644 --- a/tests/Predis/Connection/ConnectionExceptionTest.php +++ b/tests/Predis/Connection/ConnectionExceptionTest.php @@ -26,7 +26,7 @@ protected function getException( 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 1dcc532c8..521bd3938 100644 --- a/tests/Predis/Connection/Replication/SentinelReplicationTest.php +++ b/tests/Predis/Connection/Replication/SentinelReplicationTest.php @@ -1530,7 +1530,7 @@ public function testMethodGetSentinelConnectionAfterSentinelRestart(): void * * @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 c36fb0c0c..5fe87abc0 100644 --- a/tests/Predis/Protocol/ProtocolExceptionTest.php +++ b/tests/Predis/Protocol/ProtocolExceptionTest.php @@ -28,7 +28,7 @@ protected function getException( 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 128bbce4f..ca9ae4bd9 100644 --- a/tests/Predis/Replication/ReplicationStrategyTest.php +++ b/tests/Predis/Replication/ReplicationStrategyTest.php @@ -390,7 +390,7 @@ public function testSetLuaScriptAsReadOperationWorksWithScriptCommandAndCallable * * @return array */ - protected function getExpectedCommands(string $type = null): array + protected function getExpectedCommands(?string $type = null): array { $commands = [ /* commands operating on the connection */