Skip to content

PhpArrayPositionParser

Best-effort key-path -> {file, line} index for a PHP-array config file’s own return [...] literal.

Unlike XML, no per-handler reconciliation is needed: a hand-authored PHP config file’s array literal already IS the canonical array, verbatim (see FactoryConfigHandler/PluginConfigHandler’s own docblocks), so the tokenizer’s key paths already match the canonical array’s key names directly.

Uses \PhpToken::tokenize() rather than the legacy token_get_all(): every token — including single characters like [, ,, ) — carries a real ->line, where token_get_all() only gives line numbers on multi-character tokens.

Only literal nested arrays are descended into; any other value (a function call, a constant, string concatenation, …) is recorded as a leaf position at its key/item’s own line and then skipped as an opaque, balanced-bracket expression — this is a diagnostic position index, not a second PHP evaluator, and never needs to understand what a value means.

Never throws: a position-tracking failure must not block the real PhpArrayFormatDriver::load() path, which parses the file completely independently via a plain require.

final class PhpArrayPositionParser

Since1.0.0
SourceConfig/Format/Php/PhpArrayPositionParser.php
MethodDescription
parse(string $path): array<string, array{file: string, line: int}>

public static function parse(string $path): array<string, array{file: string, line: int}>

ParameterTypeDescription
$pathstring

Returns array``<``string``, ``array{file: string, line: int}``>