From b64af2c8ef02a41f89be5aa711c7ee3810f2023d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 15 Apr 2023 12:30:39 +0200 Subject: [PATCH] Minor documentation improvements --- README.md | 14 +++++++------- src/functions.php | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 523dd67..ef66aa0 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ $promise->then(function (int $bytes) { }); ``` -## delay() +### delay() The `delay(float $seconds): void` function can be used to delay program execution for duration given in `$seconds`. @@ -421,7 +421,7 @@ same loop until the delay returns: ```php echo 'a'; -Loop::addTimer(1.0, function () { +Loop::addTimer(1.0, function (): void { echo 'b'; }); React\Async\delay(3.0); @@ -453,13 +453,13 @@ Everything inside this function will still be blocked, but everything outside this function can be executed asynchronously without blocking: ```php -Loop::addTimer(0.5, React\Async\async(function () { +Loop::addTimer(0.5, React\Async\async(function (): void { echo 'a'; React\Async\delay(1.0); echo 'c'; })); -Loop::addTimer(1.0, function () { +Loop::addTimer(1.0, function (): void { echo 'b'; }); @@ -481,13 +481,13 @@ promise will clean up any pending timers and throw a `RuntimeException` from the pending delay which in turn would reject the resulting promise. ```php -$promise = async(function () { +$promise = async(function (): void { echo 'a'; delay(3.0); echo 'b'; -}); +})(); -Loop::addTimer(2.0, function () use ($promise) { +Loop::addTimer(2.0, function () use ($promise): void { $promise->cancel(); }); diff --git a/src/functions.php b/src/functions.php index a3ce111..5a02406 100644 --- a/src/functions.php +++ b/src/functions.php @@ -384,7 +384,7 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL * * ```php * echo 'a'; - * Loop::addTimer(1.0, function () { + * Loop::addTimer(1.0, function (): void { * echo 'b'; * }); * React\Async\delay(3.0); @@ -416,13 +416,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL * this function can be executed asynchronously without blocking: * * ```php - * Loop::addTimer(0.5, React\Async\async(function () { + * Loop::addTimer(0.5, React\Async\async(function (): void { * echo 'a'; * React\Async\delay(1.0); * echo 'c'; * })); * - * Loop::addTimer(1.0, function () { + * Loop::addTimer(1.0, function (): void { * echo 'b'; * }); * @@ -444,13 +444,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL * the pending delay which in turn would reject the resulting promise. * * ```php - * $promise = async(function () { + * $promise = async(function (): void { * echo 'a'; * delay(3.0); * echo 'b'; - * }); + * })(); * - * Loop::addTimer(2.0, function () use ($promise) { + * Loop::addTimer(2.0, function () use ($promise): void { * $promise->cancel(); * }); *