@@ -80,15 +80,16 @@ public function __construct($name, array $options = [])
80
80
/**
81
81
* @inheritdoc
82
82
*/
83
- public function getName ()
83
+ public function getName (): string
84
84
{
85
85
return $ this ->name ;
86
86
}
87
87
88
88
/**
89
89
* @inheritdoc
90
+ * @throws JobQueueException
90
91
*/
91
- public function submit ($ payload , array $ options = [])
92
+ public function submit ($ payload , array $ options = []): string
92
93
{
93
94
$ this ->checkClientConnection ();
94
95
$ messageId = Algorithms::generateUUID ();
@@ -103,8 +104,9 @@ public function submit($payload, array $options = [])
103
104
104
105
/**
105
106
* @inheritdoc
107
+ * @throws JobQueueException
106
108
*/
107
- public function waitAndTake ($ timeout = null )
109
+ public function waitAndTake (? int $ timeout = null ): ? Message
108
110
{
109
111
if ($ timeout === null ) {
110
112
$ timeout = $ this ->defaultTimeout ;
@@ -124,8 +126,9 @@ public function waitAndTake($timeout = null)
124
126
125
127
/**
126
128
* @inheritdoc
129
+ * @throws JobQueueException
127
130
*/
128
- public function waitAndReserve ($ timeout = null )
131
+ public function waitAndReserve (? int $ timeout = null ): ? Message
129
132
{
130
133
if ($ timeout === null ) {
131
134
$ timeout = $ this ->defaultTimeout ;
@@ -137,8 +140,9 @@ public function waitAndReserve($timeout = null)
137
140
138
141
/**
139
142
* @inheritdoc
143
+ * @throws JobQueueException
140
144
*/
141
- public function release ($ messageId , array $ options = [])
145
+ public function release (string $ messageId , array $ options = []): void
142
146
{
143
147
$ this ->checkClientConnection ();
144
148
$ this ->client ->multi ()
@@ -150,8 +154,9 @@ public function release($messageId, array $options = [])
150
154
151
155
/**
152
156
* @inheritdoc
157
+ * @throws JobQueueException
153
158
*/
154
- public function abort ($ messageId )
159
+ public function abort (string $ messageId ): void
155
160
{
156
161
$ this ->checkClientConnection ();
157
162
$ numberOfRemoved = $ this ->client ->lRem ("queue: {$ this ->name }:processing " , $ messageId , 0 );
@@ -162,8 +167,9 @@ public function abort($messageId)
162
167
163
168
/**
164
169
* @inheritdoc
170
+ * @throws JobQueueException
165
171
*/
166
- public function finish ($ messageId )
172
+ public function finish (string $ messageId ): bool
167
173
{
168
174
$ this ->checkClientConnection ();
169
175
$ numberOfRemoved = $ this ->client ->lRem ("queue: {$ this ->name }:processing " , $ messageId , 0 );
@@ -174,8 +180,9 @@ public function finish($messageId)
174
180
175
181
/**
176
182
* @inheritdoc
183
+ * @throws JobQueueException
177
184
*/
178
- public function peek ($ limit = 1 )
185
+ public function peek (int $ limit = 1 ): array
179
186
{
180
187
$ this ->checkClientConnection ();
181
188
$ result = $ this ->client ->lRange ("queue: {$ this ->name }:messages " , -($ limit ), -1 );
@@ -192,6 +199,7 @@ public function peek($limit = 1)
192
199
193
200
/**
194
201
* @inheritdoc
202
+ * @throws JobQueueException
195
203
*/
196
204
public function countReady (): int
197
205
{
@@ -201,6 +209,7 @@ public function countReady(): int
201
209
202
210
/**
203
211
* @inheritdoc
212
+ * @throws JobQueueException
204
213
*/
205
214
public function countReserved (): int
206
215
{
@@ -210,6 +219,7 @@ public function countReserved(): int
210
219
211
220
/**
212
221
* @inheritdoc
222
+ * @throws JobQueueException
213
223
*/
214
224
public function countFailed (): int
215
225
{
@@ -221,15 +231,16 @@ public function countFailed(): int
221
231
* @return void
222
232
* @throws JobQueueException
223
233
*/
224
- public function setUp ()
234
+ public function setUp (): void
225
235
{
226
236
$ this ->checkClientConnection ();
227
237
}
228
238
229
239
/**
230
240
* @inheritdoc
241
+ * @throws JobQueueException
231
242
*/
232
- public function flush ()
243
+ public function flush (): void
233
244
{
234
245
$ this ->checkClientConnection ();
235
246
$ this ->client ->flushDB ();
@@ -239,7 +250,7 @@ public function flush()
239
250
* @param string $messageId
240
251
* @return Message
241
252
*/
242
- protected function getMessageById ($ messageId )
253
+ protected function getMessageById (string $ messageId ): ? Message
243
254
{
244
255
if (!is_string ($ messageId )) {
245
256
return null ;
0 commit comments