Skip to content

Commit

Permalink
Improve selection of garbage collector status provider
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 20, 2023
1 parent 0a012a2 commit e62c274
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<ArgumentTypeCoercion>
<code><![CDATA[$eventClass . 'Subscriber']]></code>
</ArgumentTypeCoercion>
<InvalidArrayOffset>
<code><![CDATA[gc_status()['running']]]></code>
</InvalidArrayOffset>
</file>
<file src="src/Event/Value/Runtime/PHP.php">
<ImpureFunctionCall>
Expand Down
4 changes: 2 additions & 2 deletions src/Event/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
namespace PHPUnit\Event;

use function version_compare;
use function gc_status;
use PHPUnit\Event\Telemetry\HRTime;
use PHPUnit\Event\Telemetry\Php81GarbageCollectorStatusProvider;
use PHPUnit\Event\Telemetry\Php83GarbageCollectorStatusProvider;
Expand Down Expand Up @@ -247,7 +247,7 @@ private function registerDefaultTypes(TypeMap $typeMap): void

private function garbageCollectorStatusProvider(): Telemetry\GarbageCollectorStatusProvider
{
if (version_compare('8.3.0', PHP_VERSION, '>')) {
if (!isset(gc_status()['running'])) {
return new Php81GarbageCollectorStatusProvider;
}

Expand Down

0 comments on commit e62c274

Please sign in to comment.