aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/event/lib/coroutine.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/event/lib/coroutine.php')
-rw-r--r--vendor/sabre/event/lib/coroutine.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/vendor/sabre/event/lib/coroutine.php b/vendor/sabre/event/lib/coroutine.php
index cdf2d3ecd..f664efa78 100644
--- a/vendor/sabre/event/lib/coroutine.php
+++ b/vendor/sabre/event/lib/coroutine.php
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Sabre\Event;
use Generator;
-use Throwable;
/**
* Turn asynchronous promise-based code into something that looks synchronous
@@ -42,10 +41,10 @@ use Throwable;
*
* });
*
- * @return \Sabre\Event\Promise
- *
* @psalm-template TReturn
+ *
* @psalm-param callable():\Generator<mixed, mixed, mixed, TReturn> $gen
+ *
* @psalm-return Promise<TReturn>
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
@@ -55,7 +54,7 @@ use Throwable;
function coroutine(callable $gen): Promise
{
$generator = $gen();
- if (!$generator instanceof Generator) {
+ if (!$generator instanceof \Generator) {
throw new \InvalidArgumentException('You must pass a generator function');
}
@@ -75,11 +74,11 @@ function coroutine(callable $gen): Promise
$generator->send($value);
$advanceGenerator();
},
- function (Throwable $reason) use ($generator, $advanceGenerator) {
+ function (\Throwable $reason) use ($generator, $advanceGenerator) {
$generator->throw($reason);
$advanceGenerator();
}
- )->otherwise(function (Throwable $reason) use ($promise) {
+ )->otherwise(function (\Throwable $reason) use ($promise) {
// This error handler would be called, if something in the
// generator throws an exception, and it's not caught
// locally.
@@ -104,7 +103,7 @@ function coroutine(callable $gen): Promise
if ($returnValue instanceof Promise) {
$returnValue->then(function ($value) use ($promise) {
$promise->fulfill($value);
- }, function (Throwable $reason) use ($promise) {
+ }, function (\Throwable $reason) use ($promise) {
$promise->reject($reason);
});
} else {
@@ -115,7 +114,7 @@ function coroutine(callable $gen): Promise
try {
$advanceGenerator();
- } catch (Throwable $e) {
+ } catch (\Throwable $e) {
$promise->reject($e);
}