1 | <?php |
||
21 | class Async |
||
22 | { |
||
23 | /** |
||
24 | * A pool manage async processes. |
||
25 | * |
||
26 | * @var Pool |
||
27 | */ |
||
28 | protected $pool; |
||
29 | |||
30 | /** |
||
31 | * Event dispatcher manage async events. |
||
32 | * |
||
33 | * @var EventDispatcher |
||
34 | */ |
||
35 | protected $events; |
||
36 | |||
37 | /** |
||
38 | * Create a new Async instance. |
||
39 | * |
||
40 | * @param \VXM\Async\Pool $pool |
||
41 | * @param \Illuminate\Contracts\Events\Dispatcher $events |
||
42 | */ |
||
43 | public function __construct(Pool $pool, EventDispatcher $events) |
||
48 | |||
49 | /** |
||
50 | * Execute async job. |
||
51 | * |
||
52 | * @param callable|string|object $job need to execute. |
||
53 | * @param array $events event. Have key is an event name, value is a callable triggered when event |
||
54 | * happen, have three events `error`, `success`, `timeout`. |
||
55 | * |
||
56 | * @return static |
||
57 | */ |
||
58 | public function run($job, array $events = []): self |
||
69 | |||
70 | /** |
||
71 | * Batch execute async jobs. |
||
72 | * |
||
73 | * @param array $jobs |
||
74 | * @return static |
||
75 | * @see run() |
||
76 | * @since 2.0.0 |
||
77 | */ |
||
78 | public function batchRun(...$jobs): self |
||
92 | |||
93 | /** |
||
94 | * Wait until all async jobs done and return job results. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public function wait() |
||
105 | |||
106 | /** |
||
107 | * Make async job. |
||
108 | * |
||
109 | * @param $job |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | protected function makeJob($job) |
||
121 | |||
122 | /** |
||
123 | * Create class and method job. |
||
124 | * |
||
125 | * @param string $job |
||
126 | * |
||
127 | * @return Closure |
||
128 | */ |
||
129 | protected function createClassJob(string $job): Closure |
||
137 | |||
138 | /** |
||
139 | * Listen events of process given. |
||
140 | * |
||
141 | * @param array $events |
||
142 | * @param Runnable $process |
||
143 | */ |
||
144 | protected function addProcessListeners(array $events, Runnable $process): void |
||
150 | |||
151 | /** |
||
152 | * Make a base listener for integration with [[EventDispatcher]]. |
||
153 | * |
||
154 | * @param string $event |
||
155 | * @param Runnable $process |
||
156 | * |
||
157 | * @return callable |
||
158 | */ |
||
159 | protected function makeProcessListener(string $event, Runnable $process): callable |
||
167 | |||
168 | /** |
||
169 | * Create a new process for run a job. |
||
170 | * |
||
171 | * @param callable $job need to execute. |
||
172 | * |
||
173 | * @return Runnable process. |
||
174 | */ |
||
175 | protected function createProcess($job): Runnable |
||
179 | } |
||
180 |
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: