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 34
static void flushUsing(string $name, callable $callback)

Register a callback to flush test state after every test.

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 45
static void runCallbacks()

Run registered callbacks.

Return Value

void

Exceptions

Throwable

at line 69
static void forget(string $name)

Forget a registered callback by name.

This removes one process-local cleanup registration from the current PHPUnit worker.

Parameters

string $name

Return Value

void

at line 82
static void forgetCallbacks()

Forget all registered callbacks.

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

Return Value

void