phpbotgram

BaseStorage
in package

AbstractYes

Abstract base for all FSM storage backends.

Mirrors aiogram.fsm.storage.base.BaseStorage (aiogram/fsm/storage/base.py:103-200). Five methods are abstract; two concrete default implementations are provided exactly as in the Python original.

Async note: phpbotgram exposes a sync-style public surface — methods return concrete values, not Future<> / Promise<>. Implementations may suspend internally via Amp (Revolt event loop) but must never leak async primitives through this interface.

Table of Contents

Methods

close()  : void
Release all resources held by this storage instance.
getData()  : array<string, mixed>
Retrieve the FSM data payload for the given key.
getState()  : null|string
Retrieve the FSM state for the given key.
getValue()  : mixed
Read a single key from the data map stored at `$storageKey`.
setData()  : void
Persist the FSM data payload for the given key.
setState()  : void
Persist the FSM state for the given key.
updateData()  : array<string, mixed>
Merge `$data` into the existing record at `$key` and persist the result.

Methods

close()

Release all resources held by this storage instance.

public abstract close() : void

Mirrors BaseStorage.close (base.py:148-149).

getData()

Retrieve the FSM data payload for the given key.

public abstract getData(StorageKey $key) : array<string, mixed>
Parameters
$key : StorageKey

Storage address.

Return values
array<string, mixed>

Current data map (may be empty).

Mirrors BaseStorage.get_data (base.py:143-146).

getState()

Retrieve the FSM state for the given key.

public abstract getState(StorageKey $key) : null|string
Parameters
$key : StorageKey

Storage address.

Return values
null|string

Serialised state name, or null if no state is stored.

Mirrors BaseStorage.get_state (base.py:132-135).

getValue()

Read a single key from the data map stored at `$storageKey`.

public getValue(StorageKey $storageKey, string $dictKey[, mixed $default = null ]) : mixed

Returns $default when the dict key is absent. PHP collapses the upstream @overload pattern into one method with a mixed $default = null parameter.

Parameters
$storageKey : StorageKey

Storage address.

$dictKey : string

Key within the data map.

$default : mixed = null

Value to return when $dictKey is not present.

Return values
mixed

The stored value, or $default.

Mirrors BaseStorage.get_value (base.py:151-168).

setData()

Persist the FSM data payload for the given key.

public abstract setData(StorageKey $key, array<string, mixed> $data) : void
Parameters
$key : StorageKey

Storage address.

$data : array<string, mixed>

Data map to store (replaces the current record entirely).

Mirrors BaseStorage.set_data (base.py:137-141). Python Mapping[str, Any] → PHP array<string, mixed>.

setState()

Persist the FSM state for the given key.

public abstract setState(StorageKey $key[, null|State|string $state = null ]) : void
Parameters
$key : StorageKey

Storage address.

$state : null|State|string = null

New state value. string — a raw state name already serialised. State — a State instance; implementations call $state->state() to obtain the qualified name. null — clears the state.

Mirrors BaseStorage.set_state (base.py:127-130).

updateData()

Merge `$data` into the existing record at `$key` and persist the result.

public updateData(StorageKey $key, array<string, mixed> $data) : array<string, mixed>

Loads the current data map, merges the supplied patch on top with array_merge (later keys win on collision), persists the merged map, and returns a copy so that mutations to the returned array cannot bleed back into storage.

Parameters
$key : StorageKey

Storage address.

$data : array<string, mixed>

Partial data map to merge in.

Return values
array<string, mixed>

A copy of the merged data map as it was persisted.

Mirrors BaseStorage.update_data (base.py:170-181). Upstream returns current_data.copy() after in-place update.

On this page

Search results