Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8
Forces collection of any existing garbage cycles
<?php gc_collect_cycles(): int
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException()
{
gc_collect_cycles();
$deferred = new Deferred(function ($resolve, $reject) {
$reject(new \Exception('foo'));
});
<?php $deferred->promise()->cancel();
unset($deferred);
$this->assertSame(0, gc_collect_cycles());
}
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException()
{
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$deferred = new Deferred(function ($resolve, $reject) {
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException()
{
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$deferred = new Deferred(function ($resolve, $reject) {
$reject(new \Exception('foo'));
<?php $deferred->promise()->then()->cancel();
unset($deferred);
$this->assertSame(0, gc_collect_cycles());
}
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException()
{
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$deferred = new Deferred(function () use (&$deferred) { });
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException()
{
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$deferred = new Deferred(function () use (&$deferred) { });
$deferred->reject(new \Exception('foo'));
<?php $deferred->reject(new \Exception('foo'));
unset($deferred);
$this->assertSame(0, gc_collect_cycles());
}
}
<?php public function shouldResolveWithoutCreatingGarbageCyclesIfResolverResolvesWithException()
{
gc_collect_cycles();
$promise = new Promise(function ($resolve) {
$resolve(new \Exception('foo'));
});
<?php });
unset($promise);
$this->assertSame(0, gc_collect_cycles());
}
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfResolverThrowsExceptionWithoutResolver()
{
gc_collect_cycles();
$promise = new Promise(function () {
throw new \Exception('foo');
});
<?php });
unset($promise);
$this->assertSame(0, gc_collect_cycles());
}
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfResolverRejectsWithException()
{
gc_collect_cycles();
$promise = new Promise(function ($resolve, $reject) {
$reject(new \Exception('foo'));
});
<?php });
unset($promise);
$this->assertSame(0, gc_collect_cycles());
}
<?php public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException()
{
gc_collect_cycles();
$promise = new Promise(function ($resolve, $reject) { }, function ($resolve, $reject) {
$reject(new \Exception('foo'));
});