class GarbageCollectionHandler
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@internal This class is not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Runner\GarbageCollection\GarbageCollectionHandler
Expanded class hierarchy of GarbageCollectionHandler
1 file declares its use of GarbageCollectionHandler
- Application.php in vendor/
phpunit/ phpunit/ src/ TextUI/ Application.php
File
-
vendor/
phpunit/ phpunit/ src/ Runner/ GarbageCollection/ GarbageCollectionHandler.php, line 24
Namespace
PHPUnit\Runner\GarbageCollectionView source
final class GarbageCollectionHandler {
private readonly Facade $facade;
private readonly int $threshold;
private int $tests = 0;
/**
* @throws EventFacadeIsSealedException
* @throws UnknownSubscriberTypeException
*/
public function __construct(Facade $facade, int $threshold) {
$this->facade = $facade;
$this->threshold = $threshold;
$this->registerSubscribers();
}
public function executionStarted() : void {
gc_disable();
$this->facade
->emitter()
->testRunnerDisabledGarbageCollection();
gc_collect_cycles();
$this->facade
->emitter()
->testRunnerTriggeredGarbageCollection();
}
public function executionFinished() : void {
gc_collect_cycles();
$this->facade
->emitter()
->testRunnerTriggeredGarbageCollection();
gc_enable();
$this->facade
->emitter()
->testRunnerEnabledGarbageCollection();
}
public function testFinished() : void {
$this->tests++;
if ($this->tests === $this->threshold) {
gc_collect_cycles();
$this->facade
->emitter()
->testRunnerTriggeredGarbageCollection();
$this->tests = 0;
}
}
/**
* @throws EventFacadeIsSealedException
* @throws UnknownSubscriberTypeException
*/
private function registerSubscribers() : void {
$this->facade
->registerSubscribers(new ExecutionStartedSubscriber($this), new ExecutionFinishedSubscriber($this), new TestFinishedSubscriber($this));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
GarbageCollectionHandler::$facade | private | property | |
GarbageCollectionHandler::$tests | private | property | |
GarbageCollectionHandler::$threshold | private | property | |
GarbageCollectionHandler::executionFinished | public | function | |
GarbageCollectionHandler::executionStarted | public | function | |
GarbageCollectionHandler::registerSubscribers | private | function | |
GarbageCollectionHandler::testFinished | public | function | |
GarbageCollectionHandler::__construct | public | function |