Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8
Forces collection of any existing garbage cycles
<?php gc_collect_cycles(): int
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = new Promise(function ($resolve) {
$resolve(42);
<?php $await($promise);
unset($promise);
$this->assertEquals(0, gc_collect_cycles());
}
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = new Promise(function () {
throw new \RuntimeException();
<?php }
unset($promise, $e);
$this->assertEquals(0, gc_collect_cycles());
}
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = new Promise(function ($_, $reject) {
$reject(null);
<?php }
unset($promise, $e);
$this->assertEquals(0, gc_collect_cycles());
}
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
gc_collect_cycles();
$promise = coroutine(function () {
<?php }
gc_collect_cycles();
gc_collect_cycles();
$promise = coroutine(function () {
if (false) {
<?php unset($promise);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCoroutineShouldNotCreateAnyGarbageReferencesForPromiseRejectedWithExceptionImmediately()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = coroutine(function () {
yield new Promise(function () {
<?php unset($promise);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCoroutineShouldNotCreateAnyGarbageReferencesForPromiseRejectedWithExceptionOnCancellation()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = coroutine(function () {
yield new Promise(function () { }, function () {
<?php $promise->cancel();
unset($promise);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorThrowsBeforeFirstYield()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$promise = coroutine(function () {
throw new \RuntimeException('Failed', 42);
<?php unset($promise);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorYieldsInvalidValue()