> $promise */ public function __construct( PromiseResolver $promise ){ $this->storeLocal(self::TLS_KEY_PROMISE, $promise); } public function onRun() : void{ //this only works in pthreads 5.1+ and pmmpthread //in prior versions the ThreadSafe would be destroyed before onCompletion is called $result = new ThreadSafeArray(); $result[] = "foo"; $this->setResult($result); } public function onCompletion() : void{ /** @var PromiseResolver> $promise */ $promise = $this->fetchLocal(self::TLS_KEY_PROMISE); /** @var ThreadSafeArray $result */ $result = $this->getResult(); $promise->resolve($result); } }