Skip to content

Commit 8392317

Browse files
committed
TASK: Define types according to the interface
1 parent 97c8415 commit 8392317

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

Classes/Queue/RedisQueue.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@ public function __construct($name, array $options = [])
8080
/**
8181
* @inheritdoc
8282
*/
83-
public function getName()
83+
public function getName(): string
8484
{
8585
return $this->name;
8686
}
8787

8888
/**
8989
* @inheritdoc
90+
* @throws JobQueueException
9091
*/
91-
public function submit($payload, array $options = [])
92+
public function submit($payload, array $options = []): string
9293
{
9394
$this->checkClientConnection();
9495
$messageId = Algorithms::generateUUID();
@@ -103,8 +104,9 @@ public function submit($payload, array $options = [])
103104

104105
/**
105106
* @inheritdoc
107+
* @throws JobQueueException
106108
*/
107-
public function waitAndTake($timeout = null)
109+
public function waitAndTake(?int $timeout = null): ?Message
108110
{
109111
if ($timeout === null) {
110112
$timeout = $this->defaultTimeout;
@@ -124,8 +126,9 @@ public function waitAndTake($timeout = null)
124126

125127
/**
126128
* @inheritdoc
129+
* @throws JobQueueException
127130
*/
128-
public function waitAndReserve($timeout = null)
131+
public function waitAndReserve(?int $timeout = null): ?Message
129132
{
130133
if ($timeout === null) {
131134
$timeout = $this->defaultTimeout;
@@ -137,8 +140,9 @@ public function waitAndReserve($timeout = null)
137140

138141
/**
139142
* @inheritdoc
143+
* @throws JobQueueException
140144
*/
141-
public function release($messageId, array $options = [])
145+
public function release(string $messageId, array $options = []): void
142146
{
143147
$this->checkClientConnection();
144148
$this->client->multi()
@@ -150,8 +154,9 @@ public function release($messageId, array $options = [])
150154

151155
/**
152156
* @inheritdoc
157+
* @throws JobQueueException
153158
*/
154-
public function abort($messageId)
159+
public function abort(string $messageId): void
155160
{
156161
$this->checkClientConnection();
157162
$numberOfRemoved = $this->client->lRem("queue:{$this->name}:processing", $messageId, 0);
@@ -162,8 +167,9 @@ public function abort($messageId)
162167

163168
/**
164169
* @inheritdoc
170+
* @throws JobQueueException
165171
*/
166-
public function finish($messageId)
172+
public function finish(string $messageId): bool
167173
{
168174
$this->checkClientConnection();
169175
$numberOfRemoved = $this->client->lRem("queue:{$this->name}:processing", $messageId, 0);
@@ -174,8 +180,9 @@ public function finish($messageId)
174180

175181
/**
176182
* @inheritdoc
183+
* @throws JobQueueException
177184
*/
178-
public function peek($limit = 1)
185+
public function peek(int $limit = 1): array
179186
{
180187
$this->checkClientConnection();
181188
$result = $this->client->lRange("queue:{$this->name}:messages", -($limit), -1);
@@ -192,6 +199,7 @@ public function peek($limit = 1)
192199

193200
/**
194201
* @inheritdoc
202+
* @throws JobQueueException
195203
*/
196204
public function countReady(): int
197205
{
@@ -201,6 +209,7 @@ public function countReady(): int
201209

202210
/**
203211
* @inheritdoc
212+
* @throws JobQueueException
204213
*/
205214
public function countReserved(): int
206215
{
@@ -210,6 +219,7 @@ public function countReserved(): int
210219

211220
/**
212221
* @inheritdoc
222+
* @throws JobQueueException
213223
*/
214224
public function countFailed(): int
215225
{
@@ -221,15 +231,16 @@ public function countFailed(): int
221231
* @return void
222232
* @throws JobQueueException
223233
*/
224-
public function setUp()
234+
public function setUp(): void
225235
{
226236
$this->checkClientConnection();
227237
}
228238

229239
/**
230240
* @inheritdoc
241+
* @throws JobQueueException
231242
*/
232-
public function flush()
243+
public function flush(): void
233244
{
234245
$this->checkClientConnection();
235246
$this->client->flushDB();
@@ -239,7 +250,7 @@ public function flush()
239250
* @param string $messageId
240251
* @return Message
241252
*/
242-
protected function getMessageById($messageId)
253+
protected function getMessageById(string $messageId): ?Message
243254
{
244255
if (!is_string($messageId)) {
245256
return null;

0 commit comments

Comments
 (0)