1 | <?php |
||
81 | class Async extends Component |
||
82 | { |
||
83 | |||
84 | /** |
||
85 | * @event SuccessEvent an event that is triggered when task done. |
||
86 | */ |
||
87 | const EVENT_SUCCESS = 'success'; |
||
88 | |||
89 | /** |
||
90 | * @event ErrorEvent an event that is triggered when task error. |
||
91 | */ |
||
92 | const EVENT_ERROR = 'error'; |
||
93 | |||
94 | /** |
||
95 | * @event \yii\base\Event an event that is triggered when task timeout. |
||
96 | */ |
||
97 | const EVENT_TIMEOUT = 'timeout'; |
||
98 | |||
99 | /** |
||
100 | * @var Pool handling tasks. |
||
101 | */ |
||
102 | protected $pool; |
||
103 | |||
104 | /** |
||
105 | * @var string a file config of an application run in child process. |
||
106 | * Note: If an autoload file's set, it will not affect, you need to invoke an app in your autoload if needed. |
||
107 | */ |
||
108 | protected $appConfigFile; |
||
109 | |||
110 | /** |
||
111 | * Async constructor. |
||
112 | * |
||
113 | * @param array $config |
||
114 | * @throws \yii\base\InvalidConfigException |
||
115 | */ |
||
116 | 8 | public function __construct($config = []) |
|
123 | |||
124 | /** |
||
125 | * Execute async task. |
||
126 | * |
||
127 | * @param callable|\Spatie\Async\Task|Task $callable need to execute. |
||
128 | * @param array $callbacks event. Have key is an event name, value is a callable triggered when event happen, |
||
129 | * have three events `error`, `success`, `timeout`. |
||
130 | * @return static |
||
131 | */ |
||
132 | 8 | public function run($callable, array $callbacks = []): self |
|
164 | |||
165 | /** |
||
166 | * This method is called when task executed success. |
||
167 | * When overriding this method, make sure you call the parent implementation to ensure the |
||
168 | * event is triggered. |
||
169 | * |
||
170 | * @param mixed $output of task executed. |
||
171 | * @throws \yii\base\InvalidConfigException |
||
172 | */ |
||
173 | 3 | public function success($output): void |
|
182 | |||
183 | /** |
||
184 | * This method is called when task executed error. |
||
185 | * When overriding this method, make sure you call the parent implementation to ensure the |
||
186 | * event is triggered. |
||
187 | * |
||
188 | * @param Throwable $throwable when executing task. |
||
189 | * @throws \yii\base\InvalidConfigException |
||
190 | */ |
||
191 | 1 | public function error(Throwable $throwable): void |
|
200 | |||
201 | /** |
||
202 | * This method is called when task executed timeout. |
||
203 | * When overriding this method, make sure you call the parent implementation to ensure the |
||
204 | * event is triggered. |
||
205 | * |
||
206 | * @throws \yii\base\InvalidConfigException |
||
207 | */ |
||
208 | 2 | public function timeout(): void |
|
214 | |||
215 | /** |
||
216 | * Wait until all tasks done. |
||
217 | */ |
||
218 | 7 | public function wait(): void |
|
222 | |||
223 | /** |
||
224 | * Set concurrency process do tasks. |
||
225 | * |
||
226 | * @param int $concurrency |
||
227 | */ |
||
228 | public function setConcurrency(int $concurrency): void |
||
232 | |||
233 | /** |
||
234 | * Set timeout of task when execute. |
||
235 | * |
||
236 | * @param int $timeout |
||
237 | */ |
||
238 | 8 | public function setTimeout(int $timeout): void |
|
242 | |||
243 | /** |
||
244 | * Set sleep time when wait tasks execute. |
||
245 | * |
||
246 | * @param int $sleepTimeWait |
||
247 | */ |
||
248 | public function setSleepTimeWait(int $sleepTimeWait): void |
||
252 | |||
253 | /** |
||
254 | * Set autoload for environment tasks execute. |
||
255 | * @param string $autoload it can use at an alias. |
||
256 | */ |
||
257 | public function setAutoload(string $autoload): void |
||
261 | |||
262 | /** |
||
263 | * Set an application config file for invoke in child runtime process. |
||
264 | * |
||
265 | * @param string $appConfigFile it can use at an alias. |
||
266 | */ |
||
267 | 8 | public function setAppConfigFile(string $appConfigFile): void |
|
271 | |||
272 | /** |
||
273 | * Create an async process. |
||
274 | * |
||
275 | * @param callable|\Spatie\Async\Task|Task $callable need to execute. |
||
276 | * @return Runnable process. |
||
277 | */ |
||
278 | 8 | protected function createProcess($callable): Runnable |
|
282 | |||
283 | } |
||
284 |
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: