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(); * }); * pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy