class EnvironmentSnapshot

internal  
 

The environment variables as the process received them, before the application boots.

Booting loads the environment file into $_SERVER, $_ENV and putenv(). PHPStan compares cached values in the main process before anything boots, and records new ones in workers after they boot, so both must read the variables as they were before booting.

Properties

static protected null|array{server: array<array-key, mixed>, env: array<array-key, mixed>, process: array<string, string>} $captured

The variables captured before boot, as each default environment adapter reads them.

Methods

static void
capture()

Capture the variables before the application boots.

static string|null
get(string $name)

Get the value of a variable as the environment repository reads it, or null when it is not set.

static string
digest(array $names, array $patterns)

Get a digest of the named variables and of every variable matching one of the patterns.

static void
flushState()

Flush all static state.

static array
variables()

Get the captured variables, or the current ones before anything has booted.

static string|null
scalar(array $variables, string $name)

Read a variable from a superglobal as dotenv's constant adapters do.

Details

at line 40
static void capture()

Capture the variables before the application boots.

Return Value

void

at line 48
static string|null get(string $name)

Get the value of a variable as the environment repository reads it, or null when it is not set.

Parameters

string $name

Return Value

string|null

at line 65
static string digest(array $names, array $patterns)

Get a digest of the named variables and of every variable matching one of the patterns.

Each variable is digested as each default adapter reads it (ServerConstAdapter, EnvConstAdapter, PutenvAdapter), keeping an unset variable distinct from an empty one, so the digest changes whichever adapters the application enables.

Parameters

array $names
array $patterns

fnmatch() patterns matched against the set variable names

Return Value

string

at line 112
static void flushState()

Flush all static state.

Return Value

void

at line 122
static protected array variables()

Get the captured variables, or the current ones before anything has booted.

Return Value

array

at line 136
static protected string|null scalar(array $variables, string $name)

Read a variable from a superglobal as dotenv's constant adapters do.

Parameters

array $variables
string $name

Return Value

string|null