Reporter API
This reference lists reporter and output contracts.
These signatures are the public API.
Output
Namespace: Greenlight\Reporting
A destination for reporter text.
write() sends the exact text to the destination. It does not add, escape,
or buffer text.
interface Output
write()
public function write(string $text): void;
PHPDoc:
@throws ReportGenerationFailed when the destination cannot accept the text
Reporter
Namespace: Greenlight\Reporting
Converts the run event stream to an output format.
A reporter receives each event in stream order. The stream contains run,
test-class, test, and worker events. Greenlight calls finish() one time
after the final event.
interface Reporter
onEvent()
public function onEvent(Event $event): void;
PHPDoc:
@throws ReportGenerationFailed when the event cannot be rendered or delivered
finish()
Greenlight calls this method exactly one time after the final event. Reporters with buffers write their buffered text here.
public function finish(): void;
PHPDoc:
@throws ReportGenerationFailed when the output cannot be rendered or delivered
ReporterDefinition
Namespace: Greenlight\Reporting
Defines one command-line reporter name and its factory.
The name starts with a lowercase ASCII letter. The remaining characters are lowercase ASCII letters, digits, or hyphens.
final readonly class ReporterDefinition
$name
public string $name
$factory
public \Closure $factory
__construct()
public function __construct(
public string $name,
public \Closure $factory,
)
PHPDoc:
@param non-empty-string $name@param \Closure(Output): Reporter $factory Return a new reporter for each call. Greenlight owns the supplied output.@throws \InvalidArgumentException if the reporter name is invalid
ReportGenerationFailed
Namespace: Greenlight\Reporting
A reporter could not render or deliver its required output.
final class ReportGenerationFailed extends \RuntimeException
because()
Creates a failure for a reporter implementation.
public static function because(string $reason, ?\Throwable $previous = null): self
PHPDoc:
@param non-empty-string $reason@throws \InvalidArgumentException