resolveReferencePath.php
Table of Contents
Functions
- resolveReferencePath() : mixed
- Navigates to the parent container of the last key segment in a nested structure.
Functions
resolveReferencePath()
Navigates to the parent container of the last key segment in a nested structure.
& resolveReferencePath(array<string|int, mixed>|object &$document, array<string|int, mixed> $keys, bool $isArray) : mixed
This function traverses through nested arrays or objects based on the provided key path, ensuring that each intermediate level exists. It returns a reference to the parent container that should contain the final key segment.
It is typically used to prepare for read/write operations on nested values.
Requires external helpers:
ensureArrayPath()
(creates intermediate arrays)ensureObjectPath()
(creates intermediate objects)
Parameters
- $document : array<string|int, mixed>|object
-
The root document to navigate through (passed by reference).
- $keys : array<string|int, mixed>
-
The exploded path as array segments (e.g. ['user', 'profile', 'name']).
- $isArray : bool
-
If true, treat the structure as arrays; if false, as objects.
Tags
Return values
mixed —Reference to the container (array or object) that should hold the final key.