CallbackQueryFilter
extends Filter
in package
Dispatcher-side filter that bridges incoming `CallbackQuery` events to a typed `CallbackData` subclass. Created via `MyCallbackData::filter()`, not instantiated directly by user code (though direct construction is supported for tests and Logic combinator wiring).
Port of aiogram.filters.callback_data.CallbackQueryFilter
(aiogram/filters/callback_data.py:152-194).
Behavior
- Reject when the event isn't a
CallbackQueryor carries nodata. - Call
$callbackDataClass::unpack($data). - On success → return
['callback_data' => $parsed]so the parsed instance reaches the handler as the$callback_datakwarg. The kwarg name is the snake_case form mirroring upstream's{"callback_data": callback_data}return shape. - On
unpack()failure (prefix mismatch, arity mismatch, …) → collapse the exception tofalseso the dispatcher can move on to the next handler. Matches upstream'sexcept (TypeError, ValueError): return False.
MagicFilter rule
Upstream's __init__(*, callback_data, rule) accepts an optional
MagicFilter post-validation rule. Task 4.8 keeps the surface
parameter-less; the rule argument lands when Phase 4.5+ wires
MagicData/the F-DSL into the filter chain.
Table of Contents
Properties
- $callbackDataClass : string
Methods
- __construct() : mixed
- __invoke() : array<string, mixed>|false
- Evaluate the filter against an update.
- all() : AndFilter
- Compose an AND across filters: every child must accept, kwargs cascade. PHP equivalent of Python's `f1 & f2`.
- any() : OrFilter
- Compose an OR across filters: the first accepting child wins, no cascade. PHP equivalent of Python's `f1 | f2`.
- invertOf() : InvertFilter
- Invert a filter's accept/reject decision. Named `invertOf` rather than `not` because PHP forbids a static and an instance method sharing one name in a single class (the instance-side `$f->not()` convenience may land in a later task).
Properties
$callbackDataClass read-only
public
string
$callbackDataClass
Methods
__construct()
public
__construct(CallbackData> $callbackDataClass) : mixed
Parameters
- $callbackDataClass : CallbackData>
-
The bound subclass that drives
unpack(). Pinned at construction so__invokecan dispatch without re-resolving the target type.
__invoke()
Evaluate the filter against an update.
public
__invoke(object $event, mixed ...$kwargs) : array<string, mixed>|false
Parameters
- $event : object
- $kwargs : mixed
Return values
array<string, mixed>|falseall()
Compose an AND across filters: every child must accept, kwargs cascade. PHP equivalent of Python's `f1 & f2`.
public
static all(Filter ...$filters) : AndFilter
Parameters
- $filters : Filter
Return values
AndFilterany()
Compose an OR across filters: the first accepting child wins, no cascade. PHP equivalent of Python's `f1 | f2`.
public
static any(Filter ...$filters) : OrFilter
Parameters
- $filters : Filter
Return values
OrFilterinvertOf()
Invert a filter's accept/reject decision. Named `invertOf` rather than `not` because PHP forbids a static and an instance method sharing one name in a single class (the instance-side `$f->not()` convenience may land in a later task).
public
static invertOf(Filter $filter) : InvertFilter
Parameters
- $filter : Filter