ColorPreservingProcessEnvironmentConfigurator

Class
Read only: Yes Final: Yes

Keeps nested process output color-friendly without requiring PTY support.

Table of Contents

Interfaces

ProcessEnvironmentConfiguratorInterface

Configures subprocess environment variables before queued execution.

Properties

Methods

 : mixed
configure()

Configures color-related environment variables for nested commands.

 : void
hasNoColorOptOut()

Determines whether the process or parent environment opted out of color.

 : bool
isTruthyEnvironmentFlag()

Determines whether an environment flag is set to a truthy value.

 : bool
setDefault()

Sets an environment default while preserving caller-provided values.

 : bool
shouldForceColor()

Determines whether child processes should be nudged toward ANSI output.

 : bool
Properties
Methods

configure()

Public

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

hasNoColorOptOut()

Private

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
bool

Description

true when NO_COLOR is present

isTruthyEnvironmentFlag()

Private

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
bool

Description

true when the environment variable is truthy

setDefault()

Private

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
bool

Description

true when the environment map changed

shouldForceColor()

Private

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
bool

Description

true when color should be forced for child processes