phpbotgram

BotDefault
in package
implements JsonSerializable, Stringable

FinalYes

Sentinel for "use the bot's configured default for this field".

Renamed from upstream Default because PHP reserves default as a keyword (case-insensitive) so class Default won't parse even when namespaced.

The Serializer always resolves BotDefault instances against $bot->getDefaultProperties() before encoding. jsonSerialize throws so a BotDefault that escapes resolution fails loudly rather than silently emitting null on the wire.

Table of Contents

Interfaces

JsonSerializable
Stringable

Properties

$name  : string
$cache  : array<string, self>
Per-name singleton cache so generated method defaults share identity.

Methods

__construct()  : mixed
__toString()  : string
equals()  : bool
for()  : self
Returns a per-name singleton so `BotDefault::for('parse_mode') === BotDefault::for('parse_mode')`.
jsonSerialize()  : never

Properties

$cache

Per-name singleton cache so generated method defaults share identity.

private static array<string, self> $cache = []

Lives on the class rather than as a readonly property because PHP 8.5 forbids static properties on readonly classes; the public $name is still promoted-readonly below.

Methods

__construct()

public __construct(string $name) : mixed
Parameters
$name : string

__toString()

public __toString() : string
Return values
string

for()

Returns a per-name singleton so `BotDefault::for('parse_mode') === BotDefault::for('parse_mode')`.

public static for(string $name) : self

NOTE: PHP 8.5 disallows static method calls in default-parameter expressions (only new ClassName(...) is legal there), so Phase 2 codegen still has to emit new BotDefault(...) for default parameter values. This helper is for non-default callsites — user code that wants a stable sentinel identity when comparing externally.

Parameters
$name : string
Return values
self

jsonSerialize()

public jsonSerialize() : never
Return values
never
On this page

Search results