Skip to content

Commit ecd5cef

Browse files
authored
Merge pull request #78 from clue-labs/delay-docs-v4
Minor documentation improvements
2 parents 5c7e785 + b64af2c commit ecd5cef

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ $promise->then(function (int $bytes) {
392392
});
393393
```
394394

395-
## delay()
395+
### delay()
396396

397397
The `delay(float $seconds): void` function can be used to
398398
delay program execution for duration given in `$seconds`.
@@ -421,7 +421,7 @@ same loop until the delay returns:
421421

422422
```php
423423
echo 'a';
424-
Loop::addTimer(1.0, function () {
424+
Loop::addTimer(1.0, function (): void {
425425
echo 'b';
426426
});
427427
React\Async\delay(3.0);
@@ -453,13 +453,13 @@ Everything inside this function will still be blocked, but everything outside
453453
this function can be executed asynchronously without blocking:
454454

455455
```php
456-
Loop::addTimer(0.5, React\Async\async(function () {
456+
Loop::addTimer(0.5, React\Async\async(function (): void {
457457
echo 'a';
458458
React\Async\delay(1.0);
459459
echo 'c';
460460
}));
461461

462-
Loop::addTimer(1.0, function () {
462+
Loop::addTimer(1.0, function (): void {
463463
echo 'b';
464464
});
465465

@@ -481,13 +481,13 @@ promise will clean up any pending timers and throw a `RuntimeException` from
481481
the pending delay which in turn would reject the resulting promise.
482482

483483
```php
484-
$promise = async(function () {
484+
$promise = async(function (): void {
485485
echo 'a';
486486
delay(3.0);
487487
echo 'b';
488-
});
488+
})();
489489

490-
Loop::addTimer(2.0, function () use ($promise) {
490+
Loop::addTimer(2.0, function () use ($promise): void {
491491
$promise->cancel();
492492
});
493493

src/functions.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
384384
*
385385
* ```php
386386
* echo 'a';
387-
* Loop::addTimer(1.0, function () {
387+
* Loop::addTimer(1.0, function (): void {
388388
* echo 'b';
389389
* });
390390
* React\Async\delay(3.0);
@@ -416,13 +416,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
416416
* this function can be executed asynchronously without blocking:
417417
*
418418
* ```php
419-
* Loop::addTimer(0.5, React\Async\async(function () {
419+
* Loop::addTimer(0.5, React\Async\async(function (): void {
420420
* echo 'a';
421421
* React\Async\delay(1.0);
422422
* echo 'c';
423423
* }));
424424
*
425-
* Loop::addTimer(1.0, function () {
425+
* Loop::addTimer(1.0, function (): void {
426426
* echo 'b';
427427
* });
428428
*
@@ -444,13 +444,13 @@ function (mixed $throwable) use (&$rejected, &$rejectedThrowable, &$fiber, $lowL
444444
* the pending delay which in turn would reject the resulting promise.
445445
*
446446
* ```php
447-
* $promise = async(function () {
447+
* $promise = async(function (): void {
448448
* echo 'a';
449449
* delay(3.0);
450450
* echo 'b';
451-
* });
451+
* })();
452452
*
453-
* Loop::addTimer(2.0, function () use ($promise) {
453+
* Loop::addTimer(2.0, function () use ($promise): void {
454454
* $promise->cancel();
455455
* });
456456
*

0 commit comments

Comments
 (0)