Skip to content

Commit

Permalink
Update Promise.php
Browse files Browse the repository at this point in the history
  • Loading branch information
VennDev authored Aug 20, 2024
1 parent e918e70 commit 21c6d98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vennv/vapm/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ public function finally(callable $callback): Promise
*/
public function useCallbacks(): void
{
$hasCallbacks = false;
$result = $this->result;

if ($this->isResolved()) {
Expand All @@ -410,6 +411,7 @@ public function useCallbacks(): void
}

if (count($callbacks) > 0) {
$hasCallbacks = true;
/** @var callable $callback */
$callback = $callbacks[0];
$resultFirstCallback = call_user_func($callback, $this->result);
Expand All @@ -420,6 +422,7 @@ public function useCallbacks(): void
} else if ($this->isRejected()) {
if (is_callable($this->callbackReject)) $this->result = call_user_func($this->callbackReject, $result);
}
if (!$hasCallbacks && is_callable($this->callbackFinally)) call_user_func($this->callbackFinally);
}

/**
Expand Down Expand Up @@ -650,4 +653,4 @@ public static function race(array $promises): Promise
return $promise;
}

}
}

0 comments on commit 21c6d98

Please sign in to comment.