EnvReference
in package
One `${NAME}` written as a value, as the `envValue` load option sees it (see `Cooper`): the name it reads and everything written around it.
It exists for a host that resolves the environment later than the
load -- a framework compiling configuration into a cache, which must
keep ${DB_PASSWORD} a runtime placeholder rather than bake the
value the build machine happened to have. The option sees every
${...} resolution would read a value from, and nothing else: a
${?NAME} guard, a ${NAME} in an import path or an interpolated
key decide the document's shape, and are always read at load time.
$tag is set when the reference is written directly as a tag's
argument (!int(${PORT})): the option answers for the tagged value
as a whole, so a placeholder need not survive a tag that cannot read
it. A tag around anything else -- a string holding a reference
(!int("${PORT}")), a variable -- is applied to what the option gave
back, as to any other value.
Table of Contents
Constants
- DEFAULT : mixed = 'default'
- `${NAME:value}` -- the value when `NAME` is unset or empty.
- REQUIRED : mixed = 'required'
- `${NAME:?"message"}` -- an error saying the message when `NAME` is unset or empty.
- SUBSTITUTE : mixed = 'substitute'
- `${NAME:+value}` -- the value when `NAME` is set and not empty.
Properties
- $filters : array<string|int, mixed>
- $index : int|null
- $list : bool
- $name : string
- $suffix : string|null
- $tag : string|null
- $suffixValue : Closure
Methods
- __construct() : mixed
- suffixValue() : mixed
- The suffix's value, resolved as any other value is -- the default, the substitute, or the required-message -- or `null` without one.
Constants
DEFAULT
`${NAME:value}` -- the value when `NAME` is unset or empty.
public
mixed
DEFAULT
= 'default'
REQUIRED
`${NAME:?"message"}` -- an error saying the message when `NAME` is unset or empty.
public
mixed
REQUIRED
= 'required'
SUBSTITUTE
`${NAME:+value}` -- the value when `NAME` is set and not empty.
public
mixed
SUBSTITUTE
= 'substitute'
Properties
$filters read-only
public
array<string|int, mixed>
$filters
$index read-only
public
int|null
$index
$list read-only
public
bool
$list
$name read-only
public
string
$name
$suffix read-only
public
string|null
$suffix
$tag read-only
public
string|null
$tag
$suffixValue read-only
private
Closure
$suffixValue
Methods
__construct()
public
__construct(string $name, bool $list, int|null $index, string|null $suffix, array<int, string> $filters, string|null $tag, callable(): mixed $suffixValue) : mixed
Parameters
- $name : string
-
the variable, a built name (
${"TOKEN_@{id}"}) already resolved - $list : bool
-
the
${NAME[]}form: the value split into a list - $index : int|null
-
the
${NAME[i]}form's index - $suffix : string|null
-
DEFAULT,SUBSTITUTE,REQUIRED, ornullfor none - $filters : array<int, string>
-
the
| namefilters, in order - $tag : string|null
-
the tag written directly around the reference, without its
! - $suffixValue : callable(): mixed
-
resolves the suffix's value
suffixValue()
The suffix's value, resolved as any other value is -- the default, the substitute, or the required-message -- or `null` without one.
public
suffixValue() : mixed
Resolved only when asked for: an unused default that references something undefined is no error, as it is none in a normal load.
Tags
Return values
mixed —the resolved value