phpbotgram

StorageKey
in package

Read onlyYes
FinalYes

Immutable contextual key that identifies a single FSM record. Every FSM storage operation is addressed by one of these keys; the key encodes the Telegram context (bot, chat, thread, user, optional business connection) plus an optional `destiny` tag for advanced multi-slot scenarios.

Mirrors aiogram.fsm.storage.base.StorageKey (@dataclass(frozen=True), aiogram/fsm/storage/base.py:14-21). The frozen-dataclass guarantee maps directly to PHP's final readonly class, which prohibits mutation after construction and prevents subclassing.

Field mapping (upstream → PHP):

  • bot_id$botId
  • chat_id$chatId
  • user_id$userId
  • thread_id$threadId
  • business_connection_id$businessConnectionId
  • destiny$destiny

Table of Contents

Constants

DEFAULT_DESTINY  : string = 'default'
Wire-level sentinel for the default destiny slot.

Properties

$botId  : int
$businessConnectionId  : string|null
$chatId  : int
$destiny  : string
$threadId  : int|null
$userId  : int

Methods

__construct()  : mixed
withDestiny()  : self
Return a new `StorageKey` identical to this one but with a different destiny.

Constants

DEFAULT_DESTINY

Wire-level sentinel for the default destiny slot.

public string DEFAULT_DESTINY = 'default'

Mirrors DEFAULT_DESTINY = "default" at aiogram/fsm/storage/base.py:11. Declared as a class constant so callers can reference it as StorageKey::DEFAULT_DESTINY without importing a free-standing constant.

Properties

$businessConnectionId

public string|null $businessConnectionId = null

$destiny

public string $destiny = self::DEFAULT_DESTINY

Methods

__construct()

public __construct(int $botId, int $chatId, int $userId[, null|int $threadId = null ][, null|string $businessConnectionId = null ][, string $destiny = self::DEFAULT_DESTINY ]) : mixed
Parameters
$botId : int

Telegram Bot ID — identifies which bot token owns this record.

$chatId : int

Telegram Chat ID — the conversation the record belongs to.

$userId : int

Telegram User ID — the participant within that chat.

$threadId : null|int = null

Optional message-thread (forum topic) ID within a supergroup.

$businessConnectionId : null|string = null

Optional business connection identifier.

$destiny : string = self::DEFAULT_DESTINY

Destiny tag for multi-slot usage; defaults to self::DEFAULT_DESTINY.

withDestiny()

Return a new `StorageKey` identical to this one but with a different destiny.

public withDestiny(string $destiny) : self

Because StorageKey is final readonly, mutation is impossible — this factory method produces a fresh instance with all fields copied and only $destiny replaced. Used by HistoryManager to derive a separate storage slot for the history stack without affecting the main FSM slot.

Mirrors the replace(state.key, destiny=destiny) call in aiogram/fsm/scene.py:52 (Python's dataclasses.replace equivalent).

Parameters
$destiny : string

The new destiny tag for the returned key.

Return values
self

A new instance with the replaced destiny.

On this page

Search results