Skip to content

Commit 170b41d

Browse files
committed
Running php-cs-fixer
Running php-cs-fixer to fix CS drift
1 parent a64dc79 commit 170b41d

31 files changed

+21
-170
lines changed

JsonSerializer.php

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ public function toString(RedisMessage $message): string
1414
'headers' => $message->getHeaders(),
1515
]);
1616

17-
if (JSON_ERROR_NONE !== json_last_error()) {
18-
throw new \InvalidArgumentException(sprintf(
19-
'The malformed json given. Error %s and message %s',
20-
json_last_error(),
21-
json_last_error_msg()
22-
));
17+
if (\JSON_ERROR_NONE !== json_last_error()) {
18+
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
2319
}
2420

2521
return $json;
@@ -28,12 +24,8 @@ public function toString(RedisMessage $message): string
2824
public function toMessage(string $string): RedisMessage
2925
{
3026
$data = json_decode($string, true);
31-
if (JSON_ERROR_NONE !== json_last_error()) {
32-
throw new \InvalidArgumentException(sprintf(
33-
'The malformed json given. Error %s and message %s',
34-
json_last_error(),
35-
json_last_error_msg()
36-
));
27+
if (\JSON_ERROR_NONE !== json_last_error()) {
28+
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
3729
}
3830

3931
return new RedisMessage($data['body'], $data['properties'], $data['headers']);

PhpRedis.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,14 @@ public function connect(): void
9696

9797
$supportedSchemes = ['redis', 'rediss', 'tcp', 'unix'];
9898
if (false == in_array($this->config['scheme'], $supportedSchemes, true)) {
99-
throw new \LogicException(sprintf(
100-
'The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"',
101-
$this->config['scheme'],
102-
implode('", "', $supportedSchemes)
103-
));
99+
throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"', $this->config['scheme'], implode('", "', $supportedSchemes)));
104100
}
105101

106102
$this->redis = new \Redis();
107103

108104
$connectionMethod = $this->config['persistent'] ? 'pconnect' : 'connect';
109105

110-
$host = $this->config['scheme'] === 'rediss' ? 'tls://' . $this->config['host'] : $this->config['host'];
106+
$host = 'rediss' === $this->config['scheme'] ? 'tls://'.$this->config['host'] : $this->config['host'];
111107

112108
$result = call_user_func(
113109
[$this->redis, $connectionMethod],

Redis.php

-28
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,21 @@
77
interface Redis
88
{
99
/**
10-
* @param string $script
11-
* @param array $keys
12-
* @param array $args
13-
*
1410
* @throws ServerException
15-
*
16-
* @return mixed
1711
*/
1812
public function eval(string $script, array $keys = [], array $args = []);
1913

2014
/**
21-
* @param string $key
22-
* @param string $value
23-
* @param float $score
24-
*
2515
* @throws ServerException
26-
*
27-
* @return int
2816
*/
2917
public function zadd(string $key, string $value, float $score): int;
3018

3119
/**
32-
* @param string $key
33-
* @param string $value
34-
*
3520
* @throws ServerException
36-
*
37-
* @return int
3821
*/
3922
public function zrem(string $key, string $value): int;
4023

4124
/**
42-
* @param string $key
43-
* @param string $value
44-
*
4525
* @throws ServerException
4626
*
4727
* @return int length of the list
@@ -53,17 +33,11 @@ public function lpush(string $key, string $value): int;
5333
* @param int $timeout in seconds
5434
*
5535
* @throws ServerException
56-
*
57-
* @return RedisResult|null
5836
*/
5937
public function brpop(array $keys, int $timeout): ?RedisResult;
6038

6139
/**
62-
* @param string $key
63-
*
6440
* @throws ServerException
65-
*
66-
* @return RedisResult|null
6741
*/
6842
public function rpop(string $key): ?RedisResult;
6943

@@ -75,8 +49,6 @@ public function connect(): void;
7549
public function disconnect(): void;
7650

7751
/**
78-
* @param string $key
79-
*
8052
* @throws ServerException
8153
*/
8254
public function del(string $key): void;

RedisConsumer.php

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public function __construct(RedisContext $context, RedisDestination $queue)
3434
$this->queue = $queue;
3535
}
3636

37-
/**
38-
* @return int
39-
*/
4037
public function getRedeliveryDelay(): ?int
4138
{
4239
return $this->redeliveryDelay;

RedisConsumerHelperTrait.php

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ abstract protected function getContext(): RedisContext;
1515

1616
/**
1717
* @param RedisDestination[] $queues
18-
* @param int $timeout
19-
* @param int $redeliveryDelay
20-
*
21-
* @return RedisMessage|null
2218
*/
2319
protected function receiveMessage(array $queues, int $timeout, int $redeliveryDelay): ?RedisMessage
2420
{

RedisContext.php

+2-11
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class RedisContext implements Context
3838
* Callable must return instance of Redis once called.
3939
*
4040
* @param Redis|callable $redis
41-
* @param int $redeliveryDelay
4241
*/
4342
public function __construct($redis, int $redeliveryDelay)
4443
{
@@ -47,11 +46,7 @@ public function __construct($redis, int $redeliveryDelay)
4746
} elseif (is_callable($redis)) {
4847
$this->redisFactory = $redis;
4948
} else {
50-
throw new \InvalidArgumentException(sprintf(
51-
'The $redis argument must be either %s or callable that returns %s once called.',
52-
Redis::class,
53-
Redis::class
54-
));
49+
throw new \InvalidArgumentException(sprintf('The $redis argument must be either %s or callable that returns %s once called.', Redis::class, Redis::class));
5550
}
5651

5752
$this->redeliveryDelay = $redeliveryDelay;
@@ -159,11 +154,7 @@ public function getRedis(): Redis
159154
if (false == $this->redis) {
160155
$redis = call_user_func($this->redisFactory);
161156
if (false == $redis instanceof Redis) {
162-
throw new \LogicException(sprintf(
163-
'The factory must return instance of %s. It returned %s',
164-
Redis::class,
165-
is_object($redis) ? get_class($redis) : gettype($redis)
166-
));
157+
throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', Redis::class, is_object($redis) ? $redis::class : gettype($redis)));
167158
}
168159

169160
$this->redis = $redis;

RedisMessage.php

+6-24
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function isRedelivered(): bool
107107
return $this->redelivered;
108108
}
109109

110-
public function setCorrelationId(string $correlationId = null): void
110+
public function setCorrelationId(?string $correlationId = null): void
111111
{
112112
$this->setHeader('correlation_id', $correlationId);
113113
}
@@ -117,7 +117,7 @@ public function getCorrelationId(): ?string
117117
return $this->getHeader('correlation_id');
118118
}
119119

120-
public function setMessageId(string $messageId = null): void
120+
public function setMessageId(?string $messageId = null): void
121121
{
122122
$this->setHeader('message_id', $messageId);
123123
}
@@ -134,12 +134,12 @@ public function getTimestamp(): ?int
134134
return null === $value ? null : (int) $value;
135135
}
136136

137-
public function setTimestamp(int $timestamp = null): void
137+
public function setTimestamp(?int $timestamp = null): void
138138
{
139139
$this->setHeader('timestamp', $timestamp);
140140
}
141141

142-
public function setReplyTo(string $replyTo = null): void
142+
public function setReplyTo(?string $replyTo = null): void
143143
{
144144
$this->setHeader('reply_to', $replyTo);
145145
}
@@ -149,17 +149,11 @@ public function getReplyTo(): ?string
149149
return $this->getHeader('reply_to');
150150
}
151151

152-
/**
153-
* @return int
154-
*/
155152
public function getAttempts(): int
156153
{
157154
return (int) $this->getHeader('attempts', 0);
158155
}
159156

160-
/**
161-
* @return int
162-
*/
163157
public function getTimeToLive(): ?int
164158
{
165159
return $this->getHeader('time_to_live');
@@ -168,7 +162,7 @@ public function getTimeToLive(): ?int
168162
/**
169163
* Set time to live in milliseconds.
170164
*/
171-
public function setTimeToLive(int $timeToLive = null): void
165+
public function setTimeToLive(?int $timeToLive = null): void
172166
{
173167
$this->setHeader('time_to_live', $timeToLive);
174168
}
@@ -181,38 +175,26 @@ public function getDeliveryDelay(): ?int
181175
/**
182176
* Set delay in milliseconds.
183177
*/
184-
public function setDeliveryDelay(int $deliveryDelay = null): void
178+
public function setDeliveryDelay(?int $deliveryDelay = null): void
185179
{
186180
$this->setHeader('delivery_delay', $deliveryDelay);
187181
}
188182

189-
/**
190-
* @return string
191-
*/
192183
public function getReservedKey(): ?string
193184
{
194185
return $this->reservedKey;
195186
}
196187

197-
/**
198-
* @param string $reservedKey
199-
*/
200188
public function setReservedKey(string $reservedKey)
201189
{
202190
$this->reservedKey = $reservedKey;
203191
}
204192

205-
/**
206-
* @return string
207-
*/
208193
public function getKey(): ?string
209194
{
210195
return $this->key;
211196
}
212197

213-
/**
214-
* @param string $key
215-
*/
216198
public function setKey(string $key): void
217199
{
218200
$this->key = $key;

RedisProducer.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class RedisProducer implements Producer
2929
*/
3030
private $deliveryDelay;
3131

32-
/**
33-
* @param RedisContext $context
34-
*/
3532
public function __construct(RedisContext $context)
3633
{
3734
$this->context = $context;
@@ -74,7 +71,7 @@ public function send(Destination $destination, Message $message): void
7471
/**
7572
* @return self
7673
*/
77-
public function setDeliveryDelay(int $deliveryDelay = null): Producer
74+
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
7875
{
7976
$this->deliveryDelay = $deliveryDelay;
8077

@@ -89,7 +86,7 @@ public function getDeliveryDelay(): ?int
8986
/**
9087
* @return RedisProducer
9188
*/
92-
public function setPriority(int $priority = null): Producer
89+
public function setPriority(?int $priority = null): Producer
9390
{
9491
if (null === $priority) {
9592
return $this;
@@ -106,7 +103,7 @@ public function getPriority(): ?int
106103
/**
107104
* @return self
108105
*/
109-
public function setTimeToLive(int $timeToLive = null): Producer
106+
public function setTimeToLive(?int $timeToLive = null): Producer
110107
{
111108
$this->timeToLive = $timeToLive;
112109

RedisSubscriptionConsumer.php

+2-11
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,17 @@ class RedisSubscriptionConsumer implements SubscriptionConsumer
2828
*/
2929
private $redeliveryDelay = 300;
3030

31-
/**
32-
* @param RedisContext $context
33-
*/
3431
public function __construct(RedisContext $context)
3532
{
3633
$this->context = $context;
3734
$this->subscribers = [];
3835
}
3936

40-
/**
41-
* @return int
42-
*/
4337
public function getRedeliveryDelay(): ?int
4438
{
4539
return $this->redeliveryDelay;
4640
}
4741

48-
/**
49-
* @param int $delay
50-
*/
5142
public function setRedeliveryDelay(int $delay): void
5243
{
5344
$this->redeliveryDelay = $delay;
@@ -89,7 +80,7 @@ public function consume(int $timeout = 0): void
8980
public function subscribe(Consumer $consumer, callable $callback): void
9081
{
9182
if (false == $consumer instanceof RedisConsumer) {
92-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));
83+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class));
9384
}
9485

9586
$queueName = $consumer->getQueue()->getQueueName();
@@ -111,7 +102,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
111102
public function unsubscribe(Consumer $consumer): void
112103
{
113104
if (false == $consumer instanceof RedisConsumer) {
114-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));
105+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class));
115106
}
116107

117108
$queueName = $consumer->getQueue()->getQueueName();

SerializerAwareTrait.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ trait SerializerAwareTrait
1111
*/
1212
private $serializer;
1313

14-
/**
15-
* @param Serializer $serializer
16-
*/
1714
public function setSerializer(Serializer $serializer)
1815
{
1916
$this->serializer = $serializer;

Tests/Functional/CommonUseCasesTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testConsumerReceiveMessageWithZeroTimeout()
9191

9292
$consumer = $this->getContext()->createConsumer($topic);
9393

94-
//guard
94+
// guard
9595
$this->assertNull($consumer->receive(1000));
9696

9797
$message = $this->getContext()->createMessage(__METHOD__);

Tests/Functional/PRedisCommonUseCasesTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ protected function tearDown(): void
3232
$this->context->close();
3333
}
3434

35-
/**
36-
* {@inheritdoc}
37-
*/
3835
protected function getContext()
3936
{
4037
return $this->context;

Tests/Functional/PRedisConsumptionUseCasesTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ protected function tearDown(): void
3232
$this->context->close();
3333
}
3434

35-
/**
36-
* {@inheritdoc}
37-
*/
3835
protected function getContext()
3936
{
4037
return $this->context;

0 commit comments

Comments
 (0)