Skip to content

ProcessBuilder

github-actions edited this page Apr 17, 2026 · 1 revision

Builds immutable process definitions from a command and a collection of arguments.

This builder SHALL preserve previously supplied arguments by returning a new instance on each mutation-like operation. Implementations of this concrete builder MUST keep argument ordering stable so that the generated process reflects the exact sequence in which arguments were provided.


Methods

__construct

Creates a new immutable process builder instance.

public __construct(list<string> $arguments = []): mixed

The provided arguments SHALL be stored in the same order in which they are received and MUST be used when building the final process instance.

Parameters:

Parameter Type Description
$arguments list the arguments already collected by the builder

withArgument

Returns a new builder instance with an additional argument appended.

public withArgument(string $argument, string|null $value = null): \FastForward\DevTools\Process\ProcessBuilderInterface

When a value is provided, the argument SHALL be normalized to the "{argument}={value}" format before being appended. When no value is provided, the raw argument token MUST be appended as-is.

This method MUST NOT mutate the current builder instance and SHALL return a new instance containing the accumulated arguments.

Parameters:

Parameter Type Description
$argument string the argument name or token to append
$value string|null the optional value associated with the argument

Return Value:

a new builder instance containing the appended argument


getArguments

Returns the arguments currently collected by the builder.

public getArguments(): list<string>

The returned list SHALL preserve insertion order and MAY be used for inspection, debugging, or testing purposes.

Return Value:

the collected process arguments


build

Builds a process instance for the specified command.

public build(string $command): \Symfony\Component\Process\Process

The command string SHALL be split into tokens using a space separator and combined with all previously collected builder arguments. The resulting process MUST preserve the final token order exactly as assembled by this method.

Parameters:

Parameter Type Description
$command string the base command used to initialize the process

Return Value:

the configured process instance ready for execution


Clone this wiki locally