1 | <?php |
||
25 | abstract class AbstractQueue extends Component implements QueueInterface |
||
26 | { |
||
27 | /** |
||
28 | * Event executed before a job is posted to the queue. |
||
29 | */ |
||
30 | const EVENT_BEFORE_POST = 'beforePost'; |
||
31 | |||
32 | /** |
||
33 | * Event executed before a job is posted to the queue. |
||
34 | */ |
||
35 | const EVENT_AFTER_POST = 'afterPost'; |
||
36 | |||
37 | /** |
||
38 | * Event executed before a job is being fetched from the queue. |
||
39 | */ |
||
40 | const EVENT_BEFORE_FETCH = 'beforeFetch'; |
||
41 | |||
42 | /** |
||
43 | * Event executed after a job is being fetched from the queue. |
||
44 | */ |
||
45 | const EVENT_AFTER_FETCH = 'afterFetch'; |
||
46 | |||
47 | /** |
||
48 | * Event executed before a job is being deleted from the queue. |
||
49 | */ |
||
50 | const EVENT_BEFORE_DELETE = 'beforeDelete'; |
||
51 | |||
52 | /** |
||
53 | * Event executed after a job is being deleted from the queue. |
||
54 | */ |
||
55 | const EVENT_AFTER_DELETE = 'afterDelete'; |
||
56 | |||
57 | /** |
||
58 | * Event executed before a job is being released from the queue. |
||
59 | */ |
||
60 | const EVENT_BEFORE_RELEASE = 'beforeRelease'; |
||
61 | |||
62 | /** |
||
63 | * Event executed after a job is being released from the queue. |
||
64 | */ |
||
65 | const EVENT_AFTER_RELEASE = 'afterRelease'; |
||
66 | |||
67 | /** |
||
68 | * Event executed before a job is being executed. |
||
69 | */ |
||
70 | const EVENT_BEFORE_RUN = 'beforeRun'; |
||
71 | |||
72 | /** |
||
73 | * Event executed after a job is being executed. |
||
74 | */ |
||
75 | const EVENT_AFTER_RUN = 'afterRun'; |
||
76 | |||
77 | /** |
||
78 | * This will release automatically on execution failure. i.e. when |
||
79 | * the `run` method returns false or catch exception. |
||
80 | * |
||
81 | * @var bool |
||
82 | */ |
||
83 | public $releaseOnFailure = true; |
||
84 | |||
85 | /** |
||
86 | * @inheritdoc |
||
87 | */ |
||
88 | public function post(JobInterface $job): bool |
||
110 | |||
111 | /** |
||
112 | * Post new job to the queue. Override this for queue implementation. |
||
113 | * |
||
114 | * @param JobInterface $job |
||
115 | * @return bool |
||
116 | */ |
||
117 | abstract protected function postJob(JobInterface $job): bool; |
||
118 | |||
119 | /** |
||
120 | * @inheritdoc |
||
121 | */ |
||
122 | public function fetch() |
||
137 | |||
138 | /** |
||
139 | * Return next job from the queue. Override this for queue implementation. |
||
140 | * |
||
141 | * @return JobInterface|bool |
||
142 | */ |
||
143 | abstract protected function fetchJob(); |
||
144 | |||
145 | /** |
||
146 | * @inheritdoc |
||
147 | */ |
||
148 | public function run(JobInterface $job) |
||
198 | |||
199 | /** |
||
200 | * @inheritdoc |
||
201 | */ |
||
202 | public function delete(JobInterface $job): bool |
||
223 | |||
224 | /** |
||
225 | * Delete the job. Override this for the queue implementation. |
||
226 | * |
||
227 | * @param JobInterface $job |
||
228 | * @return bool |
||
229 | */ |
||
230 | abstract protected function deleteJob(JobInterface $job): bool; |
||
231 | |||
232 | /** |
||
233 | * @inheritdoc |
||
234 | */ |
||
235 | public function release(JobInterface $job): bool |
||
256 | |||
257 | /** |
||
258 | * Release the job. Override this for the queue implementation. |
||
259 | * |
||
260 | * @param JobInterface $job |
||
261 | * @return bool |
||
262 | */ |
||
263 | abstract protected function releaseJob(JobInterface $job): bool; |
||
264 | |||
265 | /** |
||
266 | * @param string $message |
||
267 | * @return JobInterface |
||
268 | * @throws Exception |
||
269 | */ |
||
270 | protected function deserialize($message): JobInterface |
||
283 | |||
284 | /** |
||
285 | * @param JobInterface $job The job to serialize. |
||
286 | * @return string JSON string. |
||
287 | */ |
||
288 | protected function serialize(JobInterface $job) |
||
294 | } |
||
295 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: