@@ -15,7 +15,7 @@ public function testAsyncReturnsPendingPromise()
1515 {
1616 $ promise = async (function () {
1717 return 42 ;
18- });
18+ })() ;
1919
2020 $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
2121 }
@@ -24,7 +24,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturns(
2424 {
2525 $ promise = async (function () {
2626 return 42 ;
27- });
27+ })() ;
2828
2929 $ value = await ($ promise );
3030
@@ -35,7 +35,7 @@ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrow
3535 {
3636 $ promise = async (function () {
3737 throw new \RuntimeException ('Foo ' , 42 );
38- });
38+ })() ;
3939
4040 $ this ->expectException (\RuntimeException::class);
4141 $ this ->expectExceptionMessage ('Foo ' );
@@ -51,7 +51,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
5151 });
5252
5353 return await ($ promise );
54- });
54+ })() ;
5555
5656 $ value = await ($ promise );
5757
@@ -66,15 +66,15 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
6666 });
6767
6868 return await ($ promise );
69- });
69+ })() ;
7070
71- $ promise2 = async (function () {
72- $ promise = new Promise (function ($ resolve ) {
73- Loop::addTimer (0.11 , fn () => $ resolve (42 ));
71+ $ promise2 = async (function (int $ theAnswerToLifeTheUniverseAndEverything ): int {
72+ $ promise = new Promise (function ($ resolve ) use ( $ theAnswerToLifeTheUniverseAndEverything ): void {
73+ Loop::addTimer (0.11 , fn () => $ resolve ($ theAnswerToLifeTheUniverseAndEverything ));
7474 });
7575
7676 return await ($ promise );
77- });
77+ })( 42 ) ;
7878
7979 $ time = microtime (true );
8080 $ values = await (all ([$ promise1 , $ promise2 ]));
0 commit comments