ColorPreservingProcessEnvironmentConfigurator
Keeps nested process output color-friendly without requiring PTY support.
Interfaces
Configures subprocess environment variables before queued execution.
Properties
Methods
Configures color-related environment variables for nested commands.
Determines whether the process or parent environment opted out of color.
Determines whether an environment flag is set to a truthy value.
Sets an environment default while preserving caller-provided values.
Determines whether child processes should be nudged toward ANSI output.
private
EnvironmentInterface
$environment
private
OutputCapabilityDetectorInterface
$outputCapabilityDetector
public
__construct(EnvironmentInterface
$environment, OutputCapabilityDetectorInterface
$outputCapabilityDetector) : mixed
Parameters
Description
reads parent process environment variables
Description
detects TTY/decorated output capabilities
Configures color-related environment variables for nested commands.
public
configure(Process
$process, OutputInterface
$output) : void
Parameters
$process
:
Process
Description
the queued process that will be started
$output
:
OutputInterface
Description
the parent output used to infer console capabilities
Determines whether the process or parent environment opted out of color.
private
hasNoColorOptOut(
array<string|int, string|Stringable>
$env) : bool
Parameters
$env
:
array<string|int, string|Stringable>
Description
the process-specific environment variables
Return values
Description
true when NO_COLOR is present
Determines whether an environment flag is set to a truthy value.
private
isTruthyEnvironmentFlag(
string
$name) : bool
Parameters
$name
:
string
Description
the environment variable name
Return values
Description
true when the environment variable is truthy
Sets an environment default while preserving caller-provided values.
private
setDefault(
array<string|int, string|Stringable>
&$env,
string
$name,
string
$value) : bool
Parameters
$env
:
array<string|int, string|Stringable>
Description
the environment map to update
$name
:
string
Description
the environment variable name
$value
:
string
Description
the default value
Return values
Description
true when the environment map changed
Determines whether child processes should be nudged toward ANSI output.
private
shouldForceColor(OutputInterface
$output) : bool
Parameters
$output
:
OutputInterface
Description
the parent process output
Return values
Description
true when color should be forced for child processes