Every public method on InitPHP\ParameterBag\ParameterBag and
InitPHP\ParameterBag\ParameterBagInterface. Behavioural details are
linked into the Usage section.
public function __construct(array $data = [], array $options = []);Initialises the bag with $data and applies $options. See
Configuration options. Throws
ParameterBagInvalidArgumentException if any unknown option key is
supplied.
public function get(string $key, mixed $default = null): mixed;Returns the value at $key, or $default if the key is absent.
Dotted paths walk nested arrays when isMulti is on. A scalar leaf
at a non-leaf path returns $default (the bag does not probe into
strings). See Basic usage and
Nested data.
public function has(string $key): bool;true when the key exists, even when the stored value is null.
public function set(string $key, mixed $value): self;Assigns $value to $key. Array values are normalised through the
constructor's code path (recursive lower-casing when
caseInsensitive is on). Returns $this for chaining.
public function remove(string ...$keys): self;Deletes one or more keys. Missing keys are a no-op. Returns $this.
public function merge(array|ParameterBagInterface ...$payloads): self;Flat mode → array_merge (shallow). Multi mode →
array_replace_recursive. Empty arguments are skipped silently.
Throws ParameterBagInvalidArgumentException if any argument is
neither an array nor a ParameterBagInterface. See
Merging.
public function replace(array $data): self;Swaps the entire stack. Options are preserved.
public function all(): array;Returns the underlying stack as a plain array, preserving nesting.
public function keys(): array;
public function values(): array;Top-level keys / values in insertion order.
public function isEmpty(): bool;true when the stack has no top-level entries.
public function count(): int;Top-level entry count. Also available via count($bag) (Countable).
public function getIterator(): \ArrayIterator;Yields top-level entries. Iteration is repeatable. See Iteration & counting.
public function offsetExists(mixed $offset): bool;
public function offsetGet(mixed $offset): mixed;
public function offsetSet(mixed $offset, mixed $value): void;
public function offsetUnset(mixed $offset): void;Delegate to has, get, set, and remove. Appending without a
key ($bag[] = $v) raises
ParameterBagInvalidArgumentException.
public function clear(): void;Empties the stack but leaves options intact.
public function close(): void;Empties the stack AND resets every option to its default
(isMulti=false, separator='.', caseInsensitive=false).
public function __debugInfo(): array;Returns a var_dump-friendly snapshot:
[
'isMulti' => 'yes' | 'no',
'separator' => string,
'data' => array,
]protected function getKey(string $key): string;Normalises a caller-supplied key (case fold + separator trim). Override to change the normalisation policy in a subclass.
protected function setOptions(array $options): void;Applies recognised options. Subclasses that introduce additional
options should override this method, extend the validation, and call
back into parent::setOptions().