Skip to content

Commit

Permalink
Remove code that is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 19, 2024
1 parent 1c640d4 commit 4d4375a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 91 deletions.
18 changes: 2 additions & 16 deletions src/Event/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

use function assert;
use function interface_exists;
use function version_compare;
use PHPUnit\Event\Telemetry\HRTime;
use PHPUnit\Event\Telemetry\Php81GarbageCollectorStatusProvider;
use PHPUnit\Event\Telemetry\Php83GarbageCollectorStatusProvider;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -96,7 +93,7 @@ public function initForIsolation(HRTime $offset): CollectingDispatcher
new Telemetry\System(
new Telemetry\SystemStopWatchWithOffset($offset),
new Telemetry\SystemMemoryMeter,
$this->garbageCollectorStatusProvider(),
new Telemetry\SystemGarbageCollectorStatusProvider,
),
);

Expand Down Expand Up @@ -136,7 +133,7 @@ private function createTelemetrySystem(): Telemetry\System
return new Telemetry\System(
new Telemetry\SystemStopWatch,
new Telemetry\SystemMemoryMeter,
$this->garbageCollectorStatusProvider(),
new Telemetry\SystemGarbageCollectorStatusProvider,
);
}

Expand Down Expand Up @@ -246,15 +243,4 @@ private function registerDefaultTypes(TypeMap $typeMap): void
$typeMap->addMapping($subscriberInterface, $eventClass);
}
}

private function garbageCollectorStatusProvider(): Telemetry\GarbageCollectorStatusProvider
{
if (version_compare(PHP_VERSION, '8.3.0', '>=')) {
return new Php83GarbageCollectorStatusProvider;
}

// @codeCoverageIgnoreStart
return new Php81GarbageCollectorStatusProvider;
// @codeCoverageIgnoreEnd
}
}
46 changes: 0 additions & 46 deletions src/Event/Value/Telemetry/Php83GarbageCollectorStatusProvider.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*
* @codeCoverageIgnore
*/
final readonly class Php81GarbageCollectorStatusProvider implements GarbageCollectorStatusProvider
final readonly class SystemGarbageCollectorStatusProvider implements GarbageCollectorStatusProvider
{
public function status(): GarbageCollectorStatus
{
Expand All @@ -27,14 +25,14 @@ public function status(): GarbageCollectorStatus
$status['collected'],
$status['threshold'],
$status['roots'],
null,
null,
null,
null,
null,
null,
null,
null,
$status['application_time'],
$status['collector_time'],
$status['destructor_time'],
$status['free_time'],
$status['running'],
$status['protected'],
$status['full'],
$status['buffer_size'],
);
}
}
12 changes: 2 additions & 10 deletions tests/unit/Event/Emitter/DispatchingEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
use function array_values;
use function explode;
use function get_class_methods;
use function version_compare;
use Exception;
use PHPUnit\Event\Code\TestCollection;
use PHPUnit\Event\Code\TestDoxBuilder;
use PHPUnit\Event\Code\ThrowableBuilder;
use PHPUnit\Event\Telemetry\Php81GarbageCollectorStatusProvider;
use PHPUnit\Event\Telemetry\Php83GarbageCollectorStatusProvider;
use PHPUnit\Event\Telemetry\SystemGarbageCollectorStatusProvider;
use PHPUnit\Event\TestData\TestDataCollection;
use PHPUnit\Event\TestRunner\ExecutionStarted;
use PHPUnit\Event\TestRunner\ExecutionStartedSubscriber;
Expand Down Expand Up @@ -1385,16 +1383,10 @@ private function dispatcherWithRegisteredSubscribers(string $subscriberInterface

private function telemetrySystem(): Telemetry\System
{
if (version_compare('8.3.0', PHP_VERSION, '>')) {
$garbageCollectorStatusProvider = new Php81GarbageCollectorStatusProvider;
} else {
$garbageCollectorStatusProvider = new Php83GarbageCollectorStatusProvider;
}

return new Telemetry\System(
new Telemetry\SystemStopWatch,
new Telemetry\SystemMemoryMeter,
$garbageCollectorStatusProvider,
new SystemGarbageCollectorStatusProvider,
);
}

Expand Down
9 changes: 1 addition & 8 deletions tests/unit/Event/Value/Telemetry/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
namespace PHPUnit\Event\Telemetry;

use function version_compare;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -81,16 +80,10 @@ private function info(): Info

private function telemetrySystem(): System
{
if (version_compare('8.3.0', PHP_VERSION, '>')) {
$garbageCollectorStatusProvider = new Php81GarbageCollectorStatusProvider;
} else {
$garbageCollectorStatusProvider = new Php83GarbageCollectorStatusProvider;
}

return new System(
new SystemStopWatch,
new SystemMemoryMeter,
$garbageCollectorStatusProvider,
new SystemGarbageCollectorStatusProvider,
);
}
}

0 comments on commit 4d4375a

Please sign in to comment.