Hierarchy final class
Minn\Support\Hierarchy · public/minn/src/Minn/Support/Hierarchy.php · 52 lines
Loops in a parent chain, found with two walkers: a slow one that takes one step at a time and a fast one that takes two (probe functions-utils, the hierarchy-loop finders). They meet only when the chain loops; it ends when a parent is empty. Each walker reads parents through the closure it is given, so a caller can override any node's parent.
Public
| static | meeting(Closure $parentOf, mixed $start): mixed# | The node where the slow walker meets the fast one, or null when the chain ends.
| |||
| static | walked(Closure $parentOf, mixed $start): ?array# | Every node either walker stepped on before they met, in the order first reached (the slow walker's node, then the fast one's two steps), or null when the chain ends without a loop.
@return array<int|string, true>|null |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | walk(Closure $parentOf, mixed $start): array# | @return array{0: mixed, 1: array<int|string, true>} the meeting node (or null) and the nodes walked |
Nothing matches.