Skip to content

XmlFormatDriver

Wraps the existing XmlConfigParser pipeline (XInclude, XSD validation, XSL normalization, parent-chain merge — all untouched, see phase 1’s “what this is NOT”) and converts its output to the canonical array via the bound handler’s toCanonicalArray().

This is what lets a FormatDriverRegistry treat an existing validators.xml/settings.xml exactly like a PHP-array or YAML source of the same canonical shape.

Bound to one handler (and therefore one config type) at construction time — see FormatDriverRegistry’s class docs for why a registry can’t mix config types through a single XML driver.

final class XmlFormatDriver implements FormatDriverInterface, PositionAwareFormatDriverInterface

ImplementsFormatDriverInterface, PositionAwareFormatDriverInterface
Since1.0.0
SourceConfig/Format/XmlFormatDriver.php

public function __construct(IArrayConfigHandler&IXmlConfigHandler $handler, array<string> $transformations = [], array<string, mixed> $validations = []): mixed

The handler’s declared XSD / RelaxNG / Schematron validations, in the same STAGE_SINGLE / STAGE_COMPILATION -> STEP_* shape config_handlers.xml produces and the DOM path already receives. Threaded through to XmlConfigParser::run() so XML reached via the FormatDriver path (e.g. as a parent/imports reference of a PHP/YAML config) is validated against the same schemas as a primary XML file.

ParameterTypeDescription
$handlerIArrayConfigHandler&IXmlConfigHandler
$transformationsarray``<``string``>XSL stylesheet paths applied in the single-file parse stage, in order (matching how config_handlers.xml lists entries for this config type today).
$validationsarray``<``string``, ``mixed``>The handler’s declared XSD / RelaxNG / Schematron validations, in the same STAGE_SINGLE / STAGE_COMPILATION -> STEP_* shape config_handlers.xml produces and the DOM path already receives. Threaded through to XmlConfigParser::run() so XML reached via the FormatDriver path (e.g. as a parent/imports reference of a PHP/YAML config) is validated against the same schemas as a primary XML file.

Returns mixed

MethodDescription
[`load(string $path, string $environment, stringnull $context = null): array<string, mixed>`](#load)
loadWithPositions(string $path, ?string $environment, ?string $context = null): array{data: array<mixed>, positions: array<string, array{file: string, line: int}>}Extension-agnostic “locating” parse mode (see VSCODE_EXTENSION_INTEGRATION.md’s config validator work item 3): same canonical array as load(), plus a key-path -> {file, line} index for whichever keys the bound handler could correlate back to a source element.
supports(string $path): boolWhether the path names an .xml file, matched case-insensitively.

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.

public function loadWithPositions(string $path, ?string $environment, ?string $context = null): array{data: array<mixed>, positions: array<string, array{file: string, line: int}>}

Extension-agnostic “locating” parse mode (see VSCODE_EXTENSION_INTEGRATION.md’s config validator work item 3): same canonical array as load(), plus a key-path -> {file, line} index for whichever keys the bound handler could correlate back to a source element.

Falls back to an empty positions map for a handler that hasn’t implemented IPositionAwareConfigHandler yet.

ParameterTypeDescription
$pathstring
$environment?``string
$context?``string

Returns array{data: array<mixed>, positions: array<string, array{file: string, line: int}>}

public function supports(string $path): bool

Whether the path names an .xml file, matched case-insensitively.

ParameterTypeDescription
$pathstring

Returns bool