@@ -78,13 +78,15 @@ will still be blocked, but everything outside this function can be executed
78
78
asynchronously without blocking:
79
79
80
80
``` php
81
- Loop::addTimer(0.5, React\Async\async(function() {
81
+ Loop::addTimer(0.5, React\Async\async(function () {
82
82
echo 'a';
83
- React\async \await(React\Promise\Timer\sleep(1.0));
83
+ React\Async \await(React\Promise\Timer\sleep(1.0));
84
84
echo 'c';
85
85
}));
86
86
87
- Loop::addTimer(1.0, fn() => echo 'b');
87
+ Loop::addTimer(1.0, function () {
88
+ echo 'b';
89
+ });
88
90
89
91
// prints "a" at t=0.5s
90
92
// prints "b" at t=1.0s
@@ -98,13 +100,15 @@ In particular, this function does not "magically" make any blocking function
98
100
non-blocking:
99
101
100
102
``` php
101
- Loop::addTimer(0.5, React\Async\async(function() {
103
+ Loop::addTimer(0.5, React\Async\async(function () {
102
104
echo 'a';
103
105
sleep(1); // broken: using PHP's blocking sleep() for demonstration purposes
104
106
echo 'c';
105
107
}));
106
108
107
- Loop::addTimer(1.0, fn() => echo 'b');
109
+ Loop::addTimer(1.0, function () {
110
+ echo 'b';
111
+ });
108
112
109
113
// prints "a" at t=0.5s
110
114
// prints "c" at t=1.5s: Correct timing, but wrong order
@@ -216,7 +220,7 @@ that bubbles up through the fibers.
216
220
``` php
217
221
$promise = async(static function (): int {
218
222
echo 'a';
219
- await(async(static function(): void {
223
+ await(async(static function (): void {
220
224
echo 'b';
221
225
await(React\Promise\Timer\sleep(2));
222
226
echo 'c';
@@ -247,13 +251,15 @@ call. Everything inside this function will still be blocked, but everything
247
251
outside this function can be executed asynchronously without blocking:
248
252
249
253
``` php
250
- Loop::addTimer(0.5, React\Async\async(function() {
254
+ Loop::addTimer(0.5, React\Async\async(function () {
251
255
echo 'a';
252
- React\async \await(React\Promise\Timer\sleep(1.0));
256
+ React\Async \await(React\Promise\Timer\sleep(1.0));
253
257
echo 'c';
254
258
}));
255
259
256
- Loop::addTimer(1.0, fn() => echo 'b');
260
+ Loop::addTimer(1.0, function () {
261
+ echo 'b';
262
+ });
257
263
258
264
// prints "a" at t=0.5s
259
265
// prints "b" at t=1.0s
0 commit comments