Poll
extends TelegramObject
in package
This object contains information about a poll.
Source: https://core.telegram.org/bots/api#poll
Table of Contents
Properties
- $allowsMultipleAnswers : bool
- $allowsRevoting : bool
- $bot : Bot|null
- $closeDate : DateTime|null
- $correctOptionIds : array<string|int, mixed>|null
- $countryCodes : array<string|int, mixed>|null
- $description : string|null
- $descriptionEntities : array<string|int, mixed>|null
- $explanation : string|null
- $explanationEntities : array<string|int, mixed>|null
- $explanationMedia : PollMedia|null
- $id : string
- $isAnonymous : bool
- $isClosed : bool
- $media : PollMedia|null
- $membersOnly : bool
- $openPeriod : int|null
- $options : array<string|int, mixed>
- $question : string
- $questionEntities : array<string|int, mixed>|null
- $totalVoterCount : int
- $type : string
Methods
- __construct() : mixed
- as_() : static
- Alias of withBot() for grep-translating aiogram code that uses obj.as_(bot).
- withBot() : static
- Returns a clone of $this with $bot rebound recursively. Walks every public property; nested `BotContextController` instances are rebound via their own `withBot`, arrays (including nested arrays of arbitrary depth — e.g.
Properties
$allowsMultipleAnswers read-only
public
bool
$allowsMultipleAnswers
$allowsRevoting read-only
public
bool
$allowsRevoting
$bot read-only
public
Bot|null
$bot
= null
$closeDate read-only
public
DateTime|null
$closeDate
= null
$correctOptionIds read-only
public
array<string|int, mixed>|null
$correctOptionIds
= null
$countryCodes read-only
public
array<string|int, mixed>|null
$countryCodes
= null
$description read-only
public
string|null
$description
= null
$descriptionEntities read-only
public
array<string|int, mixed>|null
$descriptionEntities
= null
$explanation read-only
public
string|null
$explanation
= null
$explanationEntities read-only
public
array<string|int, mixed>|null
$explanationEntities
= null
$explanationMedia read-only
public
PollMedia|null
$explanationMedia
= null
$id read-only
public
string
$id
$isAnonymous read-only
public
bool
$isAnonymous
$isClosed read-only
public
bool
$isClosed
$media read-only
public
PollMedia|null
$media
= null
$membersOnly read-only
public
bool
$membersOnly
$openPeriod read-only
public
int|null
$openPeriod
= null
$options read-only
public
array<string|int, mixed>
$options
$question read-only
public
string
$question
$questionEntities read-only
public
array<string|int, mixed>|null
$questionEntities
= null
$totalVoterCount read-only
public
int
$totalVoterCount
$type read-only
public
string
$type
Methods
__construct()
public
__construct(string $id, string $question, array<int, PollOption> $options, int $totalVoterCount, bool $isClosed, bool $isAnonymous, string $type, bool $allowsMultipleAnswers, bool $allowsRevoting, bool $membersOnly[, null|array<int, MessageEntity> $questionEntities = null ][, null|array<int, string> $countryCodes = null ][, null|array<int, int> $correctOptionIds = null ][, string|null $explanation = null ][, null|array<int, MessageEntity> $explanationEntities = null ][, PollMedia|null $explanationMedia = null ][, int|null $openPeriod = null ][, DateTime|null $closeDate = null ][, string|null $description = null ][, null|array<int, MessageEntity> $descriptionEntities = null ][, PollMedia|null $media = null ][, Bot|null $bot = null ]) : mixed
Parameters
- $id : string
- $question : string
- $options : array<int, PollOption>
- $totalVoterCount : int
- $isClosed : bool
- $isAnonymous : bool
- $type : string
- $allowsMultipleAnswers : bool
- $allowsRevoting : bool
- $membersOnly : bool
- $questionEntities : null|array<int, MessageEntity> = null
- $countryCodes : null|array<int, string> = null
- $correctOptionIds : null|array<int, int> = null
- $explanation : string|null = null
- $explanationEntities : null|array<int, MessageEntity> = null
- $explanationMedia : PollMedia|null = null
- $openPeriod : int|null = null
- $closeDate : DateTime|null = null
- $description : string|null = null
- $descriptionEntities : null|array<int, MessageEntity> = null
- $media : PollMedia|null = null
- $bot : Bot|null = null
as_()
Alias of withBot() for grep-translating aiogram code that uses obj.as_(bot).
public
as_(Bot|null $bot) : static
IMPORTANT: behaves DIFFERENTLY from upstream — upstream mutates self.bot in place and returns self. The PHP port can't mutate readonly, so this returns a clone. Callers must reassign: $msg = $msg->as($bot).
Parameters
- $bot : Bot|null
Return values
staticwithBot()
Returns a clone of $this with $bot rebound recursively. Walks every public property; nested `BotContextController` instances are rebound via their own `withBot`, arrays (including nested arrays of arbitrary depth — e.g.
public
withBot(Bot|null $bot) : static
list<list<KeyboardButton>>) are walked element-wise. Plain values
(scalars, DateTime, enums, InputFile etc.) pass through untouched.
Mirrors upstream pydantic model_validate(context={"bot": bot}) (aiogram
ContextController.as_/model_dump_json+model_validate).
Scope note: PHP 8.5 treats public readonly as effectively
public protected(set) readonly for clone-with — only code running with
a scope in the property's declaring class hierarchy (declaring class plus
its ancestors and descendants) can use clone($obj, ['x' => ...]) against
it. Because this method lives on BotContextController and every
TelegramObject/TelegramMethod subclass extends it, the walker's
clone($this, [...]) call legally rewrites subclass-declared readonly
slots like Message::$chat. External callers cannot use the same syntax
— they must funnel through this method.
Parameters
- $bot : Bot|null