InvertFilter
extends Filter
in package
Negation combinator. Mirrors upstream `aiogram.filters.logic._InvertFilter` at `aiogram/filters/logic.py`, with one deliberate PHP-side simplification.
Semantics: invoke the wrapped target and flip the accept/reject decision.
- Wrapped
true→ returnfalse(accept inverts to reject). - Wrapped
false→ returntrue(reject inverts to accept). - Wrapped
array(any shape) → returnfalse. An array return is semantically "accept and contribute these kwargs"; inverting an accept gives a reject. There is no array form for "negated accept" —notonly flips booleans, and the kwargs themselves vanish (they have no meaning on the reject branch).
Python deviation note: naive not result in Python would coerce a
populated dict to False (matching this implementation) but would also
coerce an EMPTY dict } to True — promoting a "trivially-accepting"
filter into a reject under inversion. The PHP port collapses both array
shapes to false because Filter::__invoke's contract never produces
an empty array as an "accept-without-kwargs" signal in the first place
(callers return true for that), so the only array returns to negate
are semantically accepting ones.
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
$target read-only
public
Filter
$target
Methods
__construct()
public
__construct(Filter $target) : mixed
Parameters
- $target : 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