Skip to content
PHP Ecosystem
Explore

InstrumentationGuard

API reference › Debug Core › Instrumentation › InstrumentationGuard

final readonly classPHPForge\Debug\Instrumentation\InstrumentationGuard
Sourcesrc/Instrumentation/InstrumentationGuard.php

Executes diagnostic observers without allowing their failures to alter application behavior.

MethodDescriptionDefined by
__construct()Creates a guard around an optional diagnostic failure observer.InstrumentationGuard
observe()Runs one diagnostic observer and reports, but never propagates, its failure.InstrumentationGuard
report()Reports a failure that was already caught, keeping the handler itself fail-open.InstrumentationGuard
public function __construct(callable(Throwable): void|null $failureHandler = null)

Creates a guard around an optional diagnostic failure observer.

Parameters

ParameterTypeDescription
$failureHandlercallable(Throwable): void|nullOptional observer for suppressed instrumentation errors.
public function observe(callable(): void $observer): void

Runs one diagnostic observer and reports, but never propagates, its failure.

Parameters

ParameterTypeDescription
$observercallable(): voidDiagnostic side effect.
public function report(Throwable $failure): void

Reports a failure that was already caught, keeping the handler itself fail-open.

Parameters

ParameterTypeDescription
$failureThrowableSuppressed instrumentation failure.