OrFilter
extends Filter
in package
"At least one child must accept" combinator. Mirrors upstream `aiogram.filters.logic._OrFilter` at `aiogram/filters/logic.py`.
Semantics:
- With zero targets, the loop is a no-op and the filter returns
false(identity-reject — the dual of empty AndFilter). - Each child sees the SAME input
$kwargs(no cascade — unlike AndFilter). Upstream callstarget(*args, **kwargs)once per iteration without merging anything from the previous result. - The first non-
falsereturn (trueor an array) is forwarded verbatim to the caller — including array form, so aRegex | Commandchain can still inject match data when either branch accepts. Later targets are skipped. - If every target rejects, return
false.
Table of Contents
Properties
Methods
- __construct() : mixed
- __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).
Properties
$targets read-only
public
array<int, Filter>
$targets
Methods
__construct()
public
__construct(Filter ...$targets) : mixed
Parameters
- $targets : Filter
__invoke()
Evaluate the filter against an update.
public
__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
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