TuiStateManagerInterface
Persists an opaque TUI session state array across process runs (e.g. to a JSON file), so an interactive loop can resume where a previous invocation left off. State shape is entirely caller-defined; this contract only owns the load/save/clear lifecycle.
TuiStateManagerInterface::loadState()
abstract public function loadState(): array|falseLoads the previously saved state, if any.
Returns
`false` specifically (not an empty array or `null`) when there is no persisted state to restore — e.g. no session file exists yet, or the persisted data was unreadable/corrupt. Callers MUST distinguish this from a legitimately empty saved state (`[]`).
TuiStateManagerInterface::saveState()
abstract public function saveState(array $state): boolPersists `$state`, replacing whatever was previously saved.
Parameters
| Name | Type | Description |
|---|---|---|
| $state | array<string, mixed> |
Returns
Whether the save succeeded. Implementations MUST NOT throw for an ordinary I/O failure (e.g. an unwritable path) — the caller decides whether a failed save is fatal to the interactive session.
TuiStateManagerInterface::clearSession()
abstract public function clearSession(): voidDiscards any persisted state. MUST be a no-op, not an error, if no state was ever saved.