Skip to content

CompositeErrorReporter

github-actions edited this page Mar 26, 2026 · 1 revision

Aggregates multiple error reporters and delegates error reporting to all of them.

This class MUST be used when you want to ensure that all registered reporters are notified of an error. If any reporter throws an exception, this class SHALL log the failure using error_log and MUST continue reporting to the remaining reporters.


  • Full name: \FastForward\Defer\ErrorReporter\CompositeErrorReporter
  • This class is marked as final and can't be subclassed
  • This class implements: \FastForward\Defer\ErrorReporterInterface, Countable
  • This class is a Final class

Methods

__construct

Constructs a new CompositeErrorReporter instance.

public __construct(\FastForward\Defer\ErrorReporterInterface $reporters): mixed

This constructor SHALL accept any number of ErrorReporterInterface implementations. The reporters MUST be stored in the order provided.

Parameters:

Parameter Type Description
$reporters \FastForward\Defer\ErrorReporterInterface One or more error reporters to aggregate.

report

Reports a throwable to all registered reporters.

public report(\Throwable $throwable, callable|null $callback = null, array $args = []): void

This method MUST attempt to report the throwable to each reporter in sequence. If a reporter throws an exception, the failure MUST be logged using error_log, and reporting SHALL continue for the remaining reporters.

Parameters:

Parameter Type Description
$throwable \Throwable the exception or error to report
$callback callable|null the related callback, if available
$args array arguments passed to the callback, if any

add

Adds a new reporter to the composite.

public add(\FastForward\Defer\ErrorReporterInterface $reporter): self

This method MUST append the reporter to the internal list. The reporter MUST implement ErrorReporterInterface.

Parameters:

Parameter Type Description
$reporter \FastForward\Defer\ErrorReporterInterface the reporter to add

Return Value:

returns the current instance for chaining


isEmpty

Determines if the composite contains no reporters.

public isEmpty(): bool

This method MUST return true if no reporters are registered, and false otherwise.

Return Value:

true if no reporters are registered; otherwise, false


count

Returns the number of registered reporters.

public count(): int

This method MUST return the count of reporters currently registered in the composite.

Return Value:

the number of reporters


Clone this wiki locally