Greenlight

Documentation

API reference

On this page

Configuration API

This reference lists the builders that configure Greenlight runs.

These signatures are the public API.

ArtifactBuilder

Namespace: Greenlight\Config

Collects the configuration for attachment output and safety limits. Size values use bytes or binary K, M, and G suffixes, with an optional final B.

final class ArtifactBuilder

View source

directory()

Sets the parent directory for retained attachments. The default is build/greenlight-artifacts, relative to the command working directory.

public function directory(string $directory): self

PHPDoc:

View source

maxAttachmentsPerTest()

Limits attachment count for one test across all attempts. The default is 32.

public function maxAttachmentsPerTest(int $count): self

PHPDoc:

View source

maxAttachmentSize()

Limits the size of one attachment. The default is 25M.

public function maxAttachmentSize(string $size): self

PHPDoc:

View source

maxTestSize()

Limits attachment bytes for one test across all attempts. The default is 100M.

public function maxTestSize(string $size): self

PHPDoc:

View source

maxRunAttachments()

Limits staged and retained attachment count for one run. The default is 10,000.

public function maxRunAttachments(int $count): self

PHPDoc:

View source

maxRunSize()

Limits staged and retained attachment bytes for one run. The default is 1G.

public function maxRunSize(string $size): self

PHPDoc:

View source

maxCompletedRuns()

Selects older completed runs for deletion when the retained run count exceeds this limit. No count-based retention limit applies by default.

public function maxCompletedRuns(int $count): self

PHPDoc:

View source

maxCompletedRunAge()

Selects completed runs for deletion after this many seconds from completion. No age-based retention limit applies by default.

public function maxCompletedRunAge(int $seconds): self

PHPDoc:

View source

maxRetainedSize()

Selects older completed runs for deletion when retained content exceeds this size. No size-based retention limit applies by default.

public function maxRetainedSize(string $size): self

PHPDoc:

View source

CoverageBuilder

Namespace: Greenlight\Config

Configures coverage collection and exports.

final class CoverageBuilder

View source

include()

Adds source paths to the coverage filter. Multiple calls add paths. Relative paths use the command working directory. An empty filter accepts all files that the driver reports.

public function include(string ...$paths): self

PHPDoc:

View source

driver()

Selects pcov or xdebug without fallback to the other driver. Omit this call for automatic selection, which tries pcov before Xdebug.

public function driver(string $driver): self

PHPDoc:

View source

minimumPercentage()

Sets the minimum accepted total line-coverage percentage.

public function minimumPercentage(float $percentage): self

PHPDoc:

View source

maximumUncoveredLines()

Sets the maximum accepted number of uncovered executable lines.

public function maximumUncoveredLines(int $lines): self

PHPDoc:

View source

requireDriver()

Fails the run when the selected coverage driver is not available.

public function requireDriver(bool $required = true): self

View source

export()

Adds a coverage export. Multiple calls add exports. The target is a directory for html and a file for other formats. Relative targets use the command working directory.

public function export(string $format, string $target): self

PHPDoc:

View source

GreenlightConfig

Namespace: Greenlight\Config

Collects the configuration that greenlight.php returns.

final class GreenlightConfig

View source

create()

public static function create(): self

View source

paths()

Replaces the base test-discovery directories. The default is ['tests']. Greenlight combines these paths with all suite paths when the command has no suite selector. Relative paths use the command working directory.

public function paths(array $tests): self

PHPDoc:

View source

suite()

Declares a named suite. Greenlight adds its paths to default discovery and makes the suite available to CLI selectors.

The configurator receives a SuiteBuilder. It must add at least one path with in(). Greenlight ignores its return value, which permits short arrow functions.

public function suite(string $name, callable $configurator): self

PHPDoc:

View source

workers()

Sets the maximum worker count. The default, auto, uses the detected CPU count. A count of one runs tests in the command process without process isolation. Process-pool execution can use fewer workers when the selected work or resource limits restrict concurrency.

public function workers(int|string $count = 'auto'): self

PHPDoc:

View source

resourceLimit()

Sets the maximum number of concurrent assignments that require the named resource.

A resource without an explicit resource limit has a limit of one.

public function resourceLimit(string $name, int $limit = 1): self

PHPDoc:

View source

coverage()

Enables coverage collection and changes its settings. Each call starts with the current configuration. Greenlight ignores the configurator return value.

public function coverage(callable $configurator): self

PHPDoc:

View source

watch()

Changes watch inputs and polling limits. Use --watch to start watch mode. Each call starts with the current configuration. Greenlight ignores the configurator return value.

public function watch(callable $configurator): self

PHPDoc:

View source

artifacts()

Changes attachment output, safety limits, and retention settings. Each call starts with the current configuration. Greenlight ignores the configurator return value.

public function artifacts(callable $configurator): self

PHPDoc:

View source

storage()

Sets directories for persistent state, caches, generated code, and temporary run data. Each call starts with the current configuration.

public function storage(callable $configurator): self

PHPDoc:

View source

failOnDeprecation()

Fails an otherwise passed test if captured output contains a deprecation. The diagnostic becomes the failure detail. Use ignoreDeprecationsMatching() to exempt known dependency messages.

public function failOnDeprecation(bool $enabled = true): self

PHPDoc:

View source

failOnNotice()

Fails an otherwise passed test if captured output contains a notice.

public function failOnNotice(bool $enabled = true): self

View source

failOnWarning()

Fails an otherwise passed test if captured output contains a warning.

public function failOnWarning(bool $enabled = true): self

View source

failOnRisky()

Fails an otherwise passed test if the test verifies no expectations. Use #[NoExpectations] to exempt a test that intentionally verifies no expectations.

public function failOnRisky(bool $enabled = true): self

View source

failOnSkipped()

Fails the run if its final summary contains a skipped test. The test keeps its skipped outcome and reason.

public function failOnSkipped(bool $enabled = true): self

View source

failOnRetriedPass()

Fails the run if a test passes after retry. The test keeps its passed outcome and attempt count.

public function failOnRetriedPass(bool $enabled = true): self

View source

ignoreDeprecationsMatching()

Exempts deprecation messages from failOnDeprecation(). A pattern matches part of a message without case sensitivity. A pattern that contains ”*” or ”?” matches the complete message. Multiple calls add patterns.

public function ignoreDeprecationsMatching(string ...$patterns): self

PHPDoc:

View source

plugins()

public function plugins(\Closure ...$plugins): self

PHPDoc:

View source

failFast()

Stops new work after the first failed or errored test. Active assignments can finish after the limit. This option is disabled by default.

public function failFast(bool $enabled = true): self

View source

randomizeOrder()

If the seed is null, Greenlight selects and prints a seed when it resolves the command.

public function randomizeOrder(?int $seed = null): self

PHPDoc:

View source

InvalidConfiguration

Namespace: Greenlight\Config

A configuration builder received an invalid value or an invalid combination. Use a named factory to create an error for a specific validation failure. The constructor is private.

final class InvalidConfiguration extends \InvalidArgumentException

View source

emptyArtifactDirectory()

public static function emptyArtifactDirectory(): self

View source

artifactDirectoryContainsNullByte()

public static function artifactDirectoryContainsNullByte(): self

View source

invalidArtifactCountPerTest()

public static function invalidArtifactCountPerTest(): self

View source

invalidArtifactCountPerRun()

public static function invalidArtifactCountPerRun(): self

View source

invalidCompletedRunCount()

public static function invalidCompletedRunCount(): self

View source

invalidCompletedRunAge()

public static function invalidCompletedRunAge(): self

View source

emptyCoveragePath()

public static function emptyCoveragePath(): self

View source

coveragePathContainsNullByte()

public static function coveragePathContainsNullByte(): self

View source

emptyCoverageDriver()

public static function emptyCoverageDriver(): self

View source

coveragePercentageOutOfRange()

public static function coveragePercentageOutOfRange(): self

View source

coveragePercentageTooPrecise()

public static function coveragePercentageTooPrecise(): self

View source

negativeUncoveredLineLimit()

public static function negativeUncoveredLineLimit(): self

View source

emptyCoverageExport()

public static function emptyCoverageExport(): self

View source

unknownCoverageFormat()

public static function unknownCoverageFormat(string $format): self

View source

coverageTargetContainsNullByte()

public static function coverageTargetContainsNullByte(): self

View source

testPathsNotAList()

public static function testPathsNotAList(): self

View source

testPathNotAString()

public static function testPathNotAString(): self

View source

emptyTestPath()

public static function emptyTestPath(): self

View source

testPathContainsNullByte()

public static function testPathContainsNullByte(): self

View source

missingTestPaths()

public static function missingTestPaths(): self

View source

emptySuiteName()

public static function emptySuiteName(): self

View source

duplicateSuite()

public static function duplicateSuite(string $name): self

View source

invalidResourceName()

public static function invalidResourceName(\InvalidArgumentException $previous): self

View source

invalidResourceLimit()

public static function invalidResourceLimit(string $name, int $limit): self

View source

duplicateResourceLimit()

public static function duplicateResourceLimit(string $name): self

View source

emptyDeprecationPattern()

public static function emptyDeprecationPattern(): self

View source

invalidPluginFactory()

public static function invalidPluginFactory(\InvalidArgumentException $previous): self

View source

negativeRandomSeed()

public static function negativeRandomSeed(int $seed): self

View source

invalidWorkerCountString()

public static function invalidWorkerCountString(string $count): self

View source

invalidMemorySizeSyntax()

public static function invalidMemorySizeSyntax(string $value): self

View source

memorySizeOverflow()

public static function memorySizeOverflow(string $value): self

View source

nonPositiveMemorySize()

public static function nonPositiveMemorySize(string $value): self

View source

emptyStoragePath()

public static function emptyStoragePath(string $name): self

View source

storagePathContainsNullByte()

public static function storagePathContainsNullByte(string $name): self

View source

emptySuitePath()

public static function emptySuitePath(string $name): self

View source

suitePathContainsNullByte()

public static function suitePathContainsNullByte(string $name): self

View source

emptySuiteTag()

public static function emptySuiteTag(string $name): self

View source

missingSuitePaths()

public static function missingSuitePaths(string $name): self

View source

suitePathsNotAList()

public static function suitePathsNotAList(string $name): self

View source

suitePathNotAString()

public static function suitePathNotAString(string $name): self

View source

suiteTagsNotAList()

public static function suiteTagsNotAList(string $name): self

View source

suiteTagNotAString()

public static function suiteTagNotAString(string $name): self

View source

invalidWatchDebounce()

public static function invalidWatchDebounce(int $milliseconds): self

View source

invalidWatchFileLimit()

public static function invalidWatchFileLimit(int $maximumFiles): self

View source

emptyWatchPath()

public static function emptyWatchPath(string $name): self

View source

watchPathContainsNullByte()

public static function watchPathContainsNullByte(string $name): self

View source

watchPathsNotAList()

public static function watchPathsNotAList(string $name): self

View source

watchPathNotANonEmptyString()

public static function watchPathNotANonEmptyString(string $name): self

View source

nonPositiveWorkerCount()

public static function nonPositiveWorkerCount(int $count): self

View source

StorageBuilder

Namespace: Greenlight\Config

Collects directory configuration for Greenlight-owned storage. Relative paths use the command working directory, including explicit area directories. Without a root or an area override, Greenlight uses the system temporary directory.

final class StorageBuilder

View source

rootDirectory()

Sets the parent for the state, cache, generated-code, and temporary directories. An explicit area directory overrides its default below this root.

public function rootDirectory(string $directory): self

PHPDoc:

View source

stateDirectory()

Sets the directory for saved failures and test-class durations.

public function stateDirectory(string $directory): self

PHPDoc:

View source

cacheDirectory()

Sets the directory for the discovery cache.

public function cacheDirectory(string $directory): self

PHPDoc:

View source

generatedCodeDirectory()

Sets the directory for generated double proxy classes.

public function generatedCodeDirectory(string $directory): self

PHPDoc:

View source

temporaryDirectory()

Sets the directory for temporary run data, sockets, and attachment staging.

public function temporaryDirectory(string $directory): self

PHPDoc:

View source

SuiteBuilder

Namespace: Greenlight\Config

Configures a named suite.

final class SuiteBuilder

View source

__construct()

public function __construct(private readonly string $name)

PHPDoc:

View source

in()

public function in(string ...$paths): self

PHPDoc:

View source

tag()

public function tag(string ...$tags): self

PHPDoc:

View source

WatchBuilder

Namespace: Greenlight\Config

Configures additional watch inputs and polling limits. The defaults are a 200 millisecond debounce, no additional paths or patterns, and a 100,000-file limit for each poll.

final class WatchBuilder

View source

debounceMilliseconds()

Sets the quiet period before a new run. The period restarts after each change. Thus, multiple consecutive saves cause one run.

public function debounceMilliseconds(int $milliseconds): self

PHPDoc:

View source

paths()

Adds file or directory inputs. Relative paths use the command working directory. Multiple calls add paths.

public function paths(string ...$paths): self

PHPDoc:

View source

include()

Selects files below additional directory inputs. Multiple calls add patterns. Exact file inputs do not require an include pattern.

public function include(string ...$patterns): self

PHPDoc:

View source

exclude()

Removes from all watch inputs each file that matches. Exclusion has precedence over an explicit path or include pattern. Multiple calls add patterns.

public function exclude(string ...$patterns): self

PHPDoc:

View source

maximumFiles()

Sets the maximum number of files that one poll can track.

public function maximumFiles(int $maximumFiles): self

PHPDoc:

View source