44 public function onCompletion(\Closure $onSuccess, \Closure $onFailure) : void{
45 $state = $this->shared->state;
47 $onSuccess($this->shared->result);
48 }elseif($state ===
false){
51 $this->shared->onSuccess[spl_object_id($onSuccess)] = $onSuccess;
52 $this->shared->onFailure[spl_object_id($onFailure)] = $onFailure;
79 if(count($promises) === 0){
80 $resolver->resolve([]);
81 return $resolver->getPromise();
84 $toResolve = count($promises);
87 foreach($promises as $key => $promise){
88 $promise->onCompletion(
89 function(mixed $value) use ($resolver, $key, $toResolve, &$values) :
void{
90 $values[$key] = $value;
92 if(count($values) === $toResolve){
93 $resolver->resolve($values);
96 function() use ($resolver, &$continue) : void{
109 return $resolver->getPromise();