Skip to content

AbstractArrayFormatDriver

Shared parent-chain and imports resolution for array-shaped formats (PHP arrays, YAML).

Each format only has to implement parse(): raw array in, everything else — directive expansion, imports, parent — behaves identically regardless of which format produced the array.

Unlike XmlFormatDriver, $environment/$context are not applied here: PHP-array/YAML files have no native equivalent of XML’s <ae:configuration environment="..."> filtering. A config author who needs environment-conditional values in a PHP-array file can already express that directly (Config::getNullableString('core.environment') === 'test' inside the returned array’s construction) — that’s a deliberate scope limit, not an oversight.

abstract class AbstractArrayFormatDriver implements FormatDriverInterface

ImplementsFormatDriverInterface
Since1.0.0
SourceConfig/Format/AbstractArrayFormatDriver.php

public function __construct(ArrayMergeStrategy $merger = new ArrayMergeStrategy(…), DirectiveExpander $expander = new DirectiveExpander(…)): mixed

ParameterTypeDescription
$mergerArrayMergeStrategy
$expanderDirectiveExpander

Returns mixed

MethodDescription
[`load(string $path, string $environment, stringnull $context = null): array<string, mixed>`](#load)
parse(string $path): array<string, mixed>
setRegistry(FormatDriverRegistry $registry): voidCalled by FormatDriverRegistry when this driver is registered, so parent/imports references can be resolved through any registered format, not just this driver’s own.

public function load(string $path, string $environment, string|null $context = null): array<string, mixed>

The active context name, if any.

ParameterTypeDescription
$pathstring
$environmentstringThe active environment name (only meaningful to drivers whose format has a native environment-filtering concept, e.g. XmlFormatDriver; array/YAML drivers ignore it today — see class docs).
$context`string““null`

Returns array``<``string``, ``mixed``> — The resolved, parent-chain-merged, directive-expanded config data.

abstract protected function parse(string $path): array<string, mixed>

ParameterTypeDescription
$pathstring

Returns array``<``string``, ``mixed``> — The raw, un-expanded array as read from $path (e.g. the value required from a PHP file, or the parsed YAML document). May contain ‘parent’ and/or ‘imports’ keys, which load() strips before returning.

public function setRegistry(FormatDriverRegistry $registry): void

Called by FormatDriverRegistry when this driver is registered, so parent/imports references can be resolved through any registered format, not just this driver’s own.

ParameterTypeDescription
$registryFormatDriverRegistry

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
supports()FormatDriverInterfaceWhether this driver can handle the given path, based on its extension.