@@ -78,13 +78,15 @@ will still be blocked, but everything outside this function can be executed
7878asynchronously without blocking:
7979
8080``` php
81- Loop::addTimer(0.5, React\Async\async(function() {
81+ Loop::addTimer(0.5, React\Async\async(function () {
8282 echo 'a';
83- React\async \await(React\Promise\Timer\sleep(1.0));
83+ React\Async \await(React\Promise\Timer\sleep(1.0));
8484 echo 'c';
8585}));
8686
87- Loop::addTimer(1.0, fn() => echo 'b');
87+ Loop::addTimer(1.0, function () {
88+ echo 'b';
89+ });
8890
8991// prints "a" at t=0.5s
9092// prints "b" at t=1.0s
@@ -98,13 +100,15 @@ In particular, this function does not "magically" make any blocking function
98100non-blocking:
99101
100102``` php
101- Loop::addTimer(0.5, React\Async\async(function() {
103+ Loop::addTimer(0.5, React\Async\async(function () {
102104 echo 'a';
103105 sleep(1); // broken: using PHP's blocking sleep() for demonstration purposes
104106 echo 'c';
105107}));
106108
107- Loop::addTimer(1.0, fn() => echo 'b');
109+ Loop::addTimer(1.0, function () {
110+ echo 'b';
111+ });
108112
109113// prints "a" at t=0.5s
110114// prints "c" at t=1.5s: Correct timing, but wrong order
@@ -216,7 +220,7 @@ that bubbles up through the fibers.
216220``` php
217221$promise = async(static function (): int {
218222 echo 'a';
219- await(async(static function(): void {
223+ await(async(static function (): void {
220224 echo 'b';
221225 await(React\Promise\Timer\sleep(2));
222226 echo 'c';
@@ -247,13 +251,15 @@ call. Everything inside this function will still be blocked, but everything
247251outside this function can be executed asynchronously without blocking:
248252
249253``` php
250- Loop::addTimer(0.5, React\Async\async(function() {
254+ Loop::addTimer(0.5, React\Async\async(function () {
251255 echo 'a';
252- React\async \await(React\Promise\Timer\sleep(1.0));
256+ React\Async \await(React\Promise\Timer\sleep(1.0));
253257 echo 'c';
254258}));
255259
256- Loop::addTimer(1.0, fn() => echo 'b');
260+ Loop::addTimer(1.0, function () {
261+ echo 'b';
262+ });
257263
258264// prints "a" at t=0.5s
259265// prints "b" at t=1.0s
0 commit comments