@@ -15,7 +15,7 @@ public function testAsyncReturnsPendingPromise()
15
15
{
16
16
$ promise = async (function () {
17
17
return 42 ;
18
- });
18
+ })() ;
19
19
20
20
$ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
21
21
}
@@ -24,7 +24,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturns(
24
24
{
25
25
$ promise = async (function () {
26
26
return 42 ;
27
- });
27
+ })() ;
28
28
29
29
$ value = await ($ promise );
30
30
@@ -35,7 +35,7 @@ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrow
35
35
{
36
36
$ promise = async (function () {
37
37
throw new \RuntimeException ('Foo ' , 42 );
38
- });
38
+ })() ;
39
39
40
40
$ this ->expectException (\RuntimeException::class);
41
41
$ this ->expectExceptionMessage ('Foo ' );
@@ -51,7 +51,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
51
51
});
52
52
53
53
return await ($ promise );
54
- });
54
+ })() ;
55
55
56
56
$ value = await ($ promise );
57
57
@@ -66,15 +66,15 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
66
66
});
67
67
68
68
return await ($ promise );
69
- });
69
+ })() ;
70
70
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 ));
74
74
});
75
75
76
76
return await ($ promise );
77
- });
77
+ })( 42 ) ;
78
78
79
79
$ time = microtime (true );
80
80
$ values = await (all ([$ promise1 , $ promise2 ]));
0 commit comments