class AfterEachTestCleanup

Process-local after-each cleanup callbacks for apps and packages.

This class intentionally does not expose flushState() and should not be added to AfterEachTestSubscriber; callbacks are suite-level registrations that must persist for the PHPUnit worker lifetime.

Properties

static protected array<string, Closure(): void> $callbacks

The registered after-each cleanup callbacks.

Methods

static void
flushUsing(string $name, callable $callback)

Register a callback to flush test state after every test.

static void
runCallbacks()

Run registered callbacks.

static void
forget(string $name)

Forget a registered callback by name.

static void
forgetCallbacks()

Forget all registered callbacks.

Details

at line 32
static void flushUsing(string $name, callable $callback)

Register a callback to flush test state after every test.

Boot or tests only. The callback persists in static state for the PHPUnit worker lifetime and runs after every subsequent test.

Parameters

string $name
callable $callback

Return Value

void

at line 42
static void runCallbacks()

Run registered callbacks.

Return Value

void

Exceptions

Throwable

at line 67
static void forget(string $name)

Forget a registered callback by name.

Boot or tests only. This removes one process-local cleanup registration from the current PHPUnit worker.

Parameters

string $name

Return Value

void

at line 79
static void forgetCallbacks()

Forget all registered callbacks.

Boot or tests only. This removes process-local cleanup registrations for the current PHPUnit worker, including callbacks discovered from app and package metadata.

Return Value

void