Index

DocNode

MMO\doc\models · 1 symbol · generated 30 Sep 2026

class

DocNode

DocNode.php:18

Base of every node of the documentation model (DocPage, DocSymbol, DocMember, DocParam).

class MMO\doc\models\DocNode implements MMO\core\interfaces\iArray, JsonSerializable use MMO\core\classes\tArray
Namespace
MMO\doc\models
Implements
iArray, JsonSerializable
Uses traits
tArray
The model is the single source of truth both renderers read: [`MarkdownPrinter`](https://mcp.mmoframework.fr/documentation/mmo.doc/php/MarkdownPrinter.md#markdownprinter) writes the `.md` files from it, and [`DocPageController`](https://mcp.mmoframework.fr/documentation/mmo.doc/php/controllers/DocPageController.md#docpagecontroller) renders the html pages from the very same structure -- reloaded from the `.json` file the generator writes next to each `.md`, so rendering a page at request time never needs reflection, a parser, or the source code to still be there. It is deliberately a plain `iArray` bag rather than an `Entity`: a node is a pure value, never persisted in a collection, and it has to round-trip through `json_encode`/`json_decode` without losing anything.

Index

content
nodeCache
add($key, $node)Append a child node under $key.
clear()Empty the underlying content, keeping the object itself.
compact()Drop every key whose value is null, '' or [] -- keeps the generated json readable and small.
count()\Countable::count
defaults()
Flatten($value) static
get($key, $default)Read a key, without the "undefined array key" notice $node['missing'] would raise (tArray::offsetGet returns by reference, so it cannot null-coalesce on its own).
getIterator()\IteratorAggregate::getIterator
isEmpty()
jsonSerialize()
keys()
loadArray($data)Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g.
nodes($key, $class)Read a key as a list of child nodes, rebuilding each one into $class if it is still a plain array (which is what it is right after json_decode).
offsetExists($key)\ArrayAccess::offsetExists
offsetGet($key)\ArrayAccess::offsetGet
offsetSet($key, $value)Store a value, dropping whatever nodes had already rebuilt for that key.
offsetUnset($key)\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain …
storeValue($key, $value)\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
toArray()Recursively convert to plain arrays.
__construct($data)

Properties2

content

protected $content = []

nodeCache

protected array $nodeCache = []
Type
array

Methods20

add($key, $node)

DocNode.php:83

Append a child node under $key.

function add(string $key, MMO\doc\models\DocNode $node): MMO\doc\models\DocNode
$keystring
$nodeDocNode
returnsDocNode$node, for chaining

clear()

tArray.php:25

Empty the underlying content, keeping the object itself.

function clear()
returns
$bag->clear(); // count($bag) === 0 afterwards

compact()

DocNode.php:91

Drop every key whose value is null, '' or [] -- keeps the generated json readable and small.

function compact(): static
returnsstatic

defaults()

DocNode.php:36
protected function defaults(): array
returnsarraythe keys every node of this kind always carries (so a renderer never has to test for them).

Flatten($value)

staticDocNode.php:113
protected static function Flatten(mixed $value): mixed
$valuemixed
returnsmixed$value with every nested iArray replaced by its own plain-array form.

get($key, $default)

DocNode.php:47

Read a key, without the "undefined array key" notice $node['missing'] would raise (tArray::offsetGet returns by reference, so it cannot null-coalesce on its own).

function get(string|int $key, mixed $default = null): mixed
$keystring | int
$default = nullmixedreturned when the key is unset *or* null
returnsmixed

isEmpty()

tArray.php:33
function isEmpty()
returnstrue if the underlying content has no elements
$bag->isEmpty(); // true right after clear(), false as soon as an item is set

keys()

tArray.php:82
function keys(): array
returnsarraythe list of keys currently set
$bag->keys(); // e.g. ['x', 0]

loadArray($data)

tArray.php:71

Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).

function loadArray(array $data): static
$dataarray
returnsstatic$this, for chaining
$bag->loadArray(['x' => 1, 'y' => 2]); // equivalent to $bag['x'] = 1; $bag['y'] = 2;

nodes($key, $class)

DocNode.php:58

Read a key as a list of child nodes, rebuilding each one into $class if it is still a plain array (which is what it is right after json_decode).

function nodes(string $key, string $class): array
$keystring
$classstring
returnsarray

offsetExists($key)

tArray.php:130

\ArrayAccess::offsetExists

function offsetExists(mixed $key): bool
$keymixed
returnsbool

offsetSet($key, $value)

DocNode.php:72

Store a value, dropping whatever nodes had already rebuilt for that key.

function offsetSet(mixed $key, mixed $value): void
$keymixed
$valuemixed
returnsvoid

offsetUnset($key)

tArray.php:107

\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.

function offsetUnset(mixed $key): void
$keymixed
returnsvoid
unset($bag[0]); // on a list: every following index shifts down by one, like array_splice()

storeValue($key, $value)

tArray.php:122

\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.

protected function storeValue(mixed $key, mixed $value): void
$keymixed
$valuemixed
returnsvoid

toArray()

DocNode.php:104

Recursively convert to plain arrays. tArray::toArray only unwraps iArray values sitting *directly* under a key -- a documentation node keeps most of its children in plain lists (members, params, ...), so those have to be walked too or the result is still full of objects.

function toArray(): array
returnsarray