Skip to content

Commit

Permalink
fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
VennDev authored Aug 30, 2024
1 parent bfd0993 commit 13cc0ba
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/vennv/vapm/Async.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,25 @@ public function getId(): int
*/
public static function await(mixed $await): mixed
{
$isPromiseOrAsync = $await instanceof Promise || $await instanceof Async;
if (!$isPromiseOrAsync && !Utils::isClass(Async::class)) {
throw new RuntimeException(Error::ASYNC_AWAIT_MUST_CALL_IN_ASYNC_FUNCTION);
if (!$await instanceof Promise && !$await instanceof Async) {
if (!Utils::isClass(Async::class)) {
throw new RuntimeException(Error::ASYNC_AWAIT_MUST_CALL_IN_ASYNC_FUNCTION);
}
if (is_callable($await)) {
$await = new Async($await);
} else {
return $await;
}
}

$result = $await;

if (is_callable($await)) $await = new Async($await);
if ($isPromiseOrAsync) {
do {
$return = EventLoop::getReturn($await->getId());
while ($return === null) {
$return = EventLoop::getReturn($await->getId());
if ($return === null) {
FiberManager::wait();
}
if ($return instanceof Promise) {
$result = $return->getResult();
}
}
} while ($return === null);

return $result;
return $return instanceof Promise ? $return->getResult() : $return;

Check failure on line 85 in src/vennv/vapm/Async.php

View workflow job for this annotation

GitHub Actions / Jobs (8.2)

Else branch is unreachable because ternary operator condition is always true.
}

}

0 comments on commit 13cc0ba

Please sign in to comment.