phpbotgram

BaseFilter extends Filter
in package

AbstractYes

Empty-extension alias for {@see Filter} mirroring upstream's `aiogram.filters.base.BaseFilter` import path (`aiogram/filters/base.py:9`).

User code that idiomatically ports from aiogram.filters import BaseFilter and writes class MyFilter(BaseFilter) can do the same here with class MyFilter extends BaseFilter — both Filter and BaseFilter are interchangeable as the abstract supertype, because BaseFilter extends Filter and adds nothing.

Why a real subclass rather than class_alias

A class_alias(Filter::class, BaseFilter::class) call would only run when its containing file is loaded by the autoloader. PSR-4 won't load a file that doesn't declare the expected symbol, so a file with ONLY a class_alias body never executes and BaseFilter stays unresolved.

Declaring BaseFilter as a real (empty) abstract class extending Filter sidesteps that limitation entirely: PSR-4 loads the file because the class name matches, and the resulting symbol passes is_subclass_of(BaseFilter, Filter) for free. Subclasses written against either supertype work identically under the dispatcher's Filter $filter type narrowing.

Table of Contents

Methods

__invoke()  : array<string, mixed>|bool
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).

Methods

__invoke()

Evaluate the filter against an update.

public abstract __invoke(object $event, mixed ...$kwargs) : array<string, mixed>|bool

$kwargs is captured variadically so that CallableObject::prepareKwargs detects the variadic tail and passes through the ENTIRE dispatcher kwargs bag (bot, event_context, state, …) rather than intersecting it down to only the parameter names literally declared here. The variadic capture produces a regular array<string, mixed> inside the method body, so existing accesses like $kwargs['bot'] ?? null continue to work unchanged.

Parameters
$event : object
$kwargs : mixed
Return values
array<string, mixed>|bool

See class docblock for the interpretation contract.

all()

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
AndFilter

any()

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
OrFilter

invertOf()

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
Return values
InvertFilter
On this page

Search results