$results) : void $onCompletion */ public function __construct(array $operations, \Closure $onCompletion){ $this->operations = igbinary_serialize($operations); $this->storeLocal(self::TLS_KEY_COMPLETION_CALLBACK, $onCompletion); } public function onRun() : void{ /** * @var BulkCurlTaskOperation[] $operations * @phpstan-var list $operations */ $operations = igbinary_unserialize($this->operations); $results = []; foreach($operations as $op){ try{ $results[] = Internet::simpleCurl($op->getPage(), $op->getTimeout(), $op->getExtraHeaders(), $op->getExtraOpts()); }catch(InternetException $e){ $results[] = $e; } } $this->setResult($results); } public function onCompletion() : void{ /** * @var \Closure * @phpstan-var \Closure(list) : void */ $callback = $this->fetchLocal(self::TLS_KEY_COMPLETION_CALLBACK); /** @var InternetRequestResult[]|InternetException[] $results */ $results = $this->getResult(); $callback($results); } }