11<?php
22
3+ declare (strict_types=1 );
4+
35namespace React \Promise ;
46
57use React \Promise \PromiseAdapter \CallbackPromiseAdapter ;
@@ -8,7 +10,7 @@ class DeferredTest extends TestCase
810{
911 use PromiseTest \FullTestTrait;
1012
11- public function getPromiseTestAdapter (callable $ canceller = null )
13+ public function getPromiseTestAdapter (? callable $ canceller = null )
1214 {
1315 $ d = new Deferred ($ canceller );
1416
@@ -21,8 +23,8 @@ public function getPromiseTestAdapter(callable $canceller = null)
2123 ]);
2224 }
2325
24- /** @test */
25- public function progressIsAnAliasForNotify ()
26+ #[\ PHPUnit \ Framework \ Attributes \Test]
27+ public function progressIsAnAliasForNotify (): void
2628 {
2729 $ deferred = new Deferred ();
2830
@@ -40,77 +42,77 @@ public function progressIsAnAliasForNotify()
4042 $ deferred ->progress ($ sentinel );
4143 }
4244
43- /** @test */
44- public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException ()
45+ #[\ PHPUnit \ Framework \ Attributes \Test]
46+ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException (): void
4547 {
46- gc_collect_cycles ();
47- gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
48+ \ gc_collect_cycles ();
49+ \ gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
4850
49- $ deferred = new Deferred (function ($ resolve , $ reject ) {
51+ $ deferred = new Deferred (static function ($ resolve , $ reject ): void {
5052 $ reject (new \Exception ('foo ' ));
5153 });
5254 $ deferred ->promise ()->cancel ();
5355 unset($ deferred );
5456
55- $ this ->assertSame (0 , gc_collect_cycles ());
57+ $ this ->assertSame (0 , \ gc_collect_cycles ());
5658 }
5759
58- /** @test */
59- public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException ()
60+ #[\ PHPUnit \ Framework \ Attributes \Test]
61+ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException (): void
6062 {
61- gc_collect_cycles ();
62- gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
63+ \ gc_collect_cycles ();
64+ \ gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
6365
64- $ deferred = new Deferred (function ($ resolve , $ reject ) {
66+ $ deferred = new Deferred (static function ($ resolve , $ reject ): void {
6567 $ reject (new \Exception ('foo ' ));
6668 });
6769 $ deferred ->promise ()->then ()->cancel ();
6870 unset($ deferred );
6971
70- $ this ->assertSame (0 , gc_collect_cycles ());
72+ $ this ->assertSame (0 , \ gc_collect_cycles ());
7173 }
7274
73- /** @test */
74- public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException ()
75+ #[\ PHPUnit \ Framework \ Attributes \Test]
76+ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException (): void
7577 {
76- gc_collect_cycles ();
77- $ deferred = new Deferred (function () use (&$ deferred ) { });
78+ \ gc_collect_cycles ();
79+ $ deferred = new Deferred (static function () use (&$ deferred ): void { });
7880 $ deferred ->reject (new \Exception ('foo ' ));
7981 unset($ deferred );
8082
81- $ this ->assertSame (0 , gc_collect_cycles ());
83+ $ this ->assertSame (0 , \ gc_collect_cycles ());
8284 }
8385
84- /** @test */
85- public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferred ()
86+ #[\ PHPUnit \ Framework \ Attributes \Test]
87+ public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferred (): void
8688 {
87- gc_collect_cycles ();
89+ \ gc_collect_cycles ();
8890 $ deferred = new Deferred ();
8991 $ deferred ->promise ();
9092 unset($ deferred );
9193
92- $ this ->assertSame (0 , gc_collect_cycles ());
94+ $ this ->assertSame (0 , \ gc_collect_cycles ());
9395 }
9496
95- /** @test */
96- public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferredWithUnusedCanceller ()
97+ #[\ PHPUnit \ Framework \ Attributes \Test]
98+ public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferredWithUnusedCanceller (): void
9799 {
98- gc_collect_cycles ();
99- $ deferred = new Deferred (function () { });
100+ \ gc_collect_cycles ();
101+ $ deferred = new Deferred (static function (): void { });
100102 $ deferred ->promise ();
101103 unset($ deferred );
102104
103- $ this ->assertSame (0 , gc_collect_cycles ());
105+ $ this ->assertSame (0 , \ gc_collect_cycles ());
104106 }
105107
106- /** @test */
107- public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferredWithNoopCanceller ()
108+ #[\ PHPUnit \ Framework \ Attributes \Test]
109+ public function shouldNotLeaveGarbageCyclesWhenRemovingLastReferenceToPendingDeferredWithNoopCanceller (): void
108110 {
109- gc_collect_cycles ();
110- $ deferred = new Deferred (function () { });
111+ \ gc_collect_cycles ();
112+ $ deferred = new Deferred (static function (): void { });
111113 $ deferred ->promise ()->cancel ();
112114 unset($ deferred );
113115
114- $ this ->assertSame (0 , gc_collect_cycles ());
116+ $ this ->assertSame (0 , \ gc_collect_cycles ());
115117 }
116118}
0 commit comments