phpbotgram

OrFilter extends Filter
in package

FinalYes

"At least one child must accept" combinator. Mirrors upstream `aiogram.filters.logic._OrFilter` at `aiogram/filters/logic.py`.

Semantics:

  1. With zero targets, the loop is a no-op and the filter returns false (identity-reject — the dual of empty AndFilter).
  2. Each child sees the SAME input $kwargs (no cascade — unlike AndFilter). Upstream calls target(*args, **kwargs) once per iteration without merging anything from the previous result.
  3. The first non-false return (true or an array) is forwarded verbatim to the caller — including array form, so a Regex | Command chain can still inject match data when either branch accepts. Later targets are skipped.
  4. If every target rejects, return false.

Table of Contents

Properties

$targets  : array<int, Filter>

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

Methods

__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
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