Skip to main content

Module php_config

Module php_config 

Source
Expand description

A reader for PHP array literals, enough for application config files such as Nextcloud’s config/config.php (Phase 38.1, ADR-0148).

Nothing here executes anything. The file is data written in PHP syntax: $CONFIG = array ( 'key' => 'value', ... );, with the short [ ... ] form accepted too. What is understood is strings (single and double quoted), integers, floats, true/false/null, nested arrays, and the three comment styles. Anything else - a function call, a constant, a concatenation, a variable - cannot be known without running PHP, so its value becomes null and a warning naming the key and line is recorded instead of guessing.

Every length the file can control is bounded: nesting depth and total node count, so a hostile file cannot make this recurse or allocate without limit.

Structs§

Parsed
The parsed array and anything that could not be read.

Functions§

parse
Parse the array assigned to the first = in src.
parse_var
Parse the array assigned to $name (for Nextcloud, CONFIG). A file that is a script rather than a config array - one that sets other variables first - is read from the right assignment instead of the first =.