1414
1515class AsyncTest extends TestCase
1616{
17- public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsValue ()
17+ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsValue (): void
1818 {
1919 $ promise = async (function () {
2020 return 42 ;
@@ -28,7 +28,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsV
2828 $ this ->assertEquals (42 , $ value );
2929 }
3030
31- public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsPromiseThatFulfillsWithValue ()
31+ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsPromiseThatFulfillsWithValue (): void
3232 {
3333 $ promise = async (function () {
3434 return resolve (42 );
@@ -42,7 +42,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsP
4242 $ this ->assertEquals (42 , $ value );
4343 }
4444
45- public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrows ()
45+ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrows (): void
4646 {
4747 $ promise = async (function () {
4848 throw new \RuntimeException ('Foo ' , 42 );
@@ -59,7 +59,7 @@ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrow
5959 $ this ->assertEquals (42 , $ exception ->getCode ());
6060 }
6161
62- public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackReturnsPromiseThatRejectsWithException ()
62+ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackReturnsPromiseThatRejectsWithException (): void
6363 {
6464 $ promise = async (function () {
6565 return reject (new \RuntimeException ('Foo ' , 42 ));
@@ -76,7 +76,7 @@ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackRetur
7676 $ this ->assertEquals (42 , $ exception ->getCode ());
7777 }
7878
79- public function testAsyncReturnsPendingPromiseWhenCallbackReturnsPendingPromise ()
79+ public function testAsyncReturnsPendingPromiseWhenCallbackReturnsPendingPromise (): void
8080 {
8181 $ promise = async (function () {
8282 return new Promise (function () { });
@@ -85,7 +85,7 @@ public function testAsyncReturnsPendingPromiseWhenCallbackReturnsPendingPromise(
8585 $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
8686 }
8787
88- public function testAsyncWithAwaitReturnsReturnsPromiseFulfilledWithValueImmediatelyWhenPromiseIsFulfilled ()
88+ public function testAsyncWithAwaitReturnsReturnsPromiseFulfilledWithValueImmediatelyWhenPromiseIsFulfilled (): void
8989 {
9090 $ deferred = new Deferred ();
9191
@@ -105,7 +105,7 @@ public function testAsyncWithAwaitReturnsReturnsPromiseFulfilledWithValueImmedia
105105 $ this ->assertEquals (42 , $ return );
106106 }
107107
108- public function testAsyncWithAwaitReturnsPromiseRejectedWithExceptionImmediatelyWhenPromiseIsRejected ()
108+ public function testAsyncWithAwaitReturnsPromiseRejectedWithExceptionImmediatelyWhenPromiseIsRejected (): void
109109 {
110110 $ deferred = new Deferred ();
111111
@@ -122,13 +122,13 @@ public function testAsyncWithAwaitReturnsPromiseRejectedWithExceptionImmediately
122122
123123 $ deferred ->reject (new \RuntimeException ('Test ' , 42 ));
124124
125+ /** @var \RuntimeException $exception */
125126 $ this ->assertInstanceof (\RuntimeException::class, $ exception );
126- assert ($ exception instanceof \RuntimeException);
127127 $ this ->assertEquals ('Test ' , $ exception ->getMessage ());
128128 $ this ->assertEquals (42 , $ exception ->getCode ());
129129 }
130130
131- public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsAfterAwaitingPromise ()
131+ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsAfterAwaitingPromise (): void
132132 {
133133 $ promise = async (function () {
134134 $ promise = new Promise (function ($ resolve ) {
@@ -143,23 +143,23 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
143143 $ this ->assertEquals (42 , $ value );
144144 }
145145
146- public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrowsAfterAwaitingPromise ()
146+ public function testAsyncReturnsPromiseThatRejectsWithExceptionWhenCallbackThrowsAfterAwaitingPromise (): void
147147 {
148148 $ promise = async (function () {
149149 $ promise = new Promise (function ($ _ , $ reject ) {
150150 Loop::addTimer (0.001 , fn () => $ reject (new \RuntimeException ('Foo ' , 42 )));
151151 });
152152
153153 return await ($ promise );
154- })();
154+ })(42 );
155155
156156 $ this ->expectException (\RuntimeException::class);
157157 $ this ->expectExceptionMessage ('Foo ' );
158158 $ this ->expectExceptionCode (42 );
159159 await ($ promise );
160160 }
161161
162- public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsAfterAwaitingTwoConcurrentPromises ()
162+ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsAfterAwaitingTwoConcurrentPromises (): void
163163 {
164164 $ promise1 = async (function () {
165165 $ promise = new Promise (function ($ resolve ) {
@@ -174,6 +174,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
174174 Loop::addTimer (0.11 , fn () => $ resolve ($ theAnswerToLifeTheUniverseAndEverything ));
175175 });
176176
177+ /** @var int */
177178 return await ($ promise );
178179 })(42 );
179180
@@ -186,7 +187,7 @@ public function testAsyncReturnsPromiseThatFulfillsWithValueWhenCallbackReturnsA
186187 $ this ->assertLessThan (0.12 , $ time );
187188 }
188189
189- public function testCancelAsyncWillReturnRejectedPromiseWhenCancellingPendingPromiseRejects ()
190+ public function testCancelAsyncWillReturnRejectedPromiseWhenCancellingPendingPromiseRejects (): void
190191 {
191192 $ promise = async (function () {
192193 await (new Promise (function () { }, function () {
@@ -200,7 +201,7 @@ public function testCancelAsyncWillReturnRejectedPromiseWhenCancellingPendingPro
200201 $ promise ->then (null , $ this ->expectCallableOnceWith (new \RuntimeException ('Operation cancelled ' )));
201202 }
202203
203- public function testCancelAsyncWillReturnFulfilledPromiseWhenCancellingPendingPromiseRejectsInsideCatchThatReturnsValue ()
204+ public function testCancelAsyncWillReturnFulfilledPromiseWhenCancellingPendingPromiseRejectsInsideCatchThatReturnsValue (): void
204205 {
205206 $ promise = async (function () {
206207 try {
@@ -218,7 +219,7 @@ public function testCancelAsyncWillReturnFulfilledPromiseWhenCancellingPendingPr
218219 $ promise ->then ($ this ->expectCallableOnceWith (42 ));
219220 }
220221
221- public function testCancelAsycWillReturnPendigPromiseWhenCancellingFirstPromiseRejectsInsideCatchThatAwaitsSecondPromise ()
222+ public function testCancelAsycWillReturnPendigPromiseWhenCancellingFirstPromiseRejectsInsideCatchThatAwaitsSecondPromise (): void
222223 {
223224 $ promise = async (function () {
224225 try {
@@ -238,7 +239,7 @@ public function testCancelAsycWillReturnPendigPromiseWhenCancellingFirstPromiseR
238239 $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableNever ());
239240 }
240241
241- public function testCancelAsyncWillCancelNestedAwait ()
242+ public function testCancelAsyncWillCancelNestedAwait (): void
242243 {
243244 self ::expectOutputString ('abc ' );
244245 $ this ->expectException (\RuntimeException::class);
0 commit comments