@@ -126,8 +126,9 @@ public function testCancellingPendingConnectionWithoutTimeoutShouldNotCreateAnyG
126126
127127 $ connector = new Connector (array ('timeout ' => false ));
128128
129- gc_collect_cycles ();
130- gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
129+ while (gc_collect_cycles ()) {
130+ // collect all garbage cycles
131+ }
131132
132133 $ promise = $ connector ->connect ('8.8.8.8:80 ' );
133134 $ promise ->cancel ();
@@ -144,7 +145,10 @@ public function testCancellingPendingConnectionShouldNotCreateAnyGarbageReferenc
144145
145146 $ connector = new Connector (array ());
146147
147- gc_collect_cycles ();
148+ while (gc_collect_cycles ()) {
149+ // collect all garbage cycles
150+ }
151+
148152 $ promise = $ connector ->connect ('8.8.8.8:80 ' );
149153 $ promise ->cancel ();
150154 unset($ promise );
@@ -167,7 +171,9 @@ public function testWaitingForRejectedConnectionShouldNotCreateAnyGarbageReferen
167171
168172 $ connector = new Connector (array ('timeout ' => false ));
169173
170- gc_collect_cycles ();
174+ while (gc_collect_cycles ()) {
175+ // collect all garbage cycles
176+ }
171177
172178 $ wait = true ;
173179 $ promise = $ connector ->connect ('127.0.0.1:1 ' )->then (
@@ -201,7 +207,9 @@ public function testWaitingForConnectionTimeoutDuringDnsLookupShouldNotCreateAny
201207
202208 $ connector = new Connector (array ('timeout ' => 0.001 ));
203209
204- gc_collect_cycles ();
210+ while (gc_collect_cycles ()) {
211+ // collect all garbage cycles
212+ }
205213
206214 $ wait = true ;
207215 $ promise = $ connector ->connect ('google.com:80 ' )->then (
@@ -232,7 +240,9 @@ public function testWaitingForConnectionTimeoutDuringTcpConnectionShouldNotCreat
232240
233241 $ connector = new Connector (array ('timeout ' => 0.000001 ));
234242
235- gc_collect_cycles ();
243+ while (gc_collect_cycles ()) {
244+ // collect all garbage cycles
245+ }
236246
237247 $ wait = true ;
238248 $ promise = $ connector ->connect ('8.8.8.8:53 ' )->then (
@@ -263,7 +273,9 @@ public function testWaitingForInvalidDnsConnectionShouldNotCreateAnyGarbageRefer
263273
264274 $ connector = new Connector (array ('timeout ' => false ));
265275
266- gc_collect_cycles ();
276+ while (gc_collect_cycles ()) {
277+ // collect all garbage cycles
278+ }
267279
268280 $ wait = true ;
269281 $ promise = $ connector ->connect ('example.invalid:80 ' )->then (
@@ -304,7 +316,9 @@ public function testWaitingForInvalidTlsConnectionShouldNotCreateAnyGarbageRefer
304316 )
305317 ));
306318
307- gc_collect_cycles ();
319+ while (gc_collect_cycles ()) {
320+ // collect all garbage cycles
321+ }
308322
309323 $ wait = true ;
310324 $ promise = $ connector ->connect ('tls://self-signed.badssl.com:443 ' )->then (
@@ -338,7 +352,10 @@ public function testWaitingForSuccessfullyClosedConnectionShouldNotCreateAnyGarb
338352
339353 $ connector = new Connector (array ('timeout ' => false ));
340354
341- gc_collect_cycles ();
355+ while (gc_collect_cycles ()) {
356+ // collect all garbage cycles
357+ }
358+
342359 $ promise = $ connector ->connect ('google.com:80 ' )->then (
343360 function ($ conn ) {
344361 $ conn ->close ();
0 commit comments