Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); namespace Pest\Subscribers; use PHPUnit\Event\TestRunner..

Decoded Output download

<?php

declare(strict_types=1);

namespace Pest\Subscribers;

use PHPUnit\Event\TestRunner\Started;
use PHPUnit\Event\TestRunner\StartedSubscriber;
use PHPUnit\Event\TestRunner\WarningTriggered;
use PHPUnit\TestRunner\TestResult\Collector;
use PHPUnit\TestRunner\TestResult\Facade;
use ReflectionClass;

/**
 * @internal
 */
final class EnsureIgnorableTestCasesAreIgnored implements StartedSubscriber
{
    /**
     * Runs the subscriber.
     */
    public function notify(Started $event): void
    {
        $reflection = new ReflectionClass(Facade::class);
        $property = $reflection->getProperty('collector');
        $property->setAccessible(true);
        $collector = $property->getValue();

        assert($collector instanceof Collector);

        $reflection = new ReflectionClass($collector);
        $property = $reflection->getProperty('testRunnerTriggeredWarningEvents');
        $property->setAccessible(true);

        /** @var array<int, WarningTriggered> $testRunnerTriggeredWarningEvents */
        $testRunnerTriggeredWarningEvents = $property->getValue($collector);

        $testRunnerTriggeredWarningEvents = array_values(array_filter($testRunnerTriggeredWarningEvents, fn (WarningTriggered $event): bool => $event->message() !== 'No tests found in class "Pest\TestCases\IgnorableTestCase".'));

        $property->setValue($collector, $testRunnerTriggeredWarningEvents);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace Pest\Subscribers;

use PHPUnit\Event\TestRunner\Started;
use PHPUnit\Event\TestRunner\StartedSubscriber;
use PHPUnit\Event\TestRunner\WarningTriggered;
use PHPUnit\TestRunner\TestResult\Collector;
use PHPUnit\TestRunner\TestResult\Facade;
use ReflectionClass;

/**
 * @internal
 */
final class EnsureIgnorableTestCasesAreIgnored implements StartedSubscriber
{
    /**
     * Runs the subscriber.
     */
    public function notify(Started $event): void
    {
        $reflection = new ReflectionClass(Facade::class);
        $property = $reflection->getProperty('collector');
        $property->setAccessible(true);
        $collector = $property->getValue();

        assert($collector instanceof Collector);

        $reflection = new ReflectionClass($collector);
        $property = $reflection->getProperty('testRunnerTriggeredWarningEvents');
        $property->setAccessible(true);

        /** @var array<int, WarningTriggered> $testRunnerTriggeredWarningEvents */
        $testRunnerTriggeredWarningEvents = $property->getValue($collector);

        $testRunnerTriggeredWarningEvents = array_values(array_filter($testRunnerTriggeredWarningEvents, fn (WarningTriggered $event): bool => $event->message() !== 'No tests found in class "Pest\TestCases\IgnorableTestCase".'));

        $property->setValue($collector, $testRunnerTriggeredWarningEvents);
    }
}

Function Calls

None

Variables

None

Stats

MD5 8c45707975cab00c00db6179657fb4dd
Eval Count 0
Decode Time 99 ms