45 public function onCompletion(\Closure $onSuccess, \Closure $onFailure) : void{
46 $state = $this->shared->state;
48 $onSuccess($this->shared->result);
49 }elseif($state ===
false){
52 $this->shared->onSuccess[spl_object_id($onSuccess)] = $onSuccess;
53 $this->shared->onFailure[spl_object_id($onFailure)] = $onFailure;
80 if(count($promises) === 0){
81 $resolver->resolve([]);
82 return $resolver->getPromise();
85 $toResolve = count($promises);
88 foreach(Utils::promoteKeys($promises) as $key => $promise){
89 $promise->onCompletion(
90 function(mixed $value) use ($resolver, $key, $toResolve, &$values) :
void{
91 $values[$key] = $value;
93 if(count($values) === $toResolve){
94 $resolver->resolve($values);
97 function() use ($resolver, &$continue) : void{
110 return $resolver->getPromise();