phpbotgram

FunctionOperation extends BaseOperation
in package

Apply an external callable to the running value, optionally with extra positional / named arguments resolved against the chain root.

Mirrors upstream magic_filter.operations.function.FunctionOperation (magic_filter/operations/function.py). Call semantics:

  • args are prepended to the value: function(...$args, $value). This matches upstream which calls function(*args, value, **kwargs).
  • kwargs are passed as named arguments.
  • Each arg/kwarg entry that is itself a MagicFilter is resolved against the original subject before the call, courtesy of Helper::resolveIfNeeded — so call sites like F->func(InArrayCheck, ['admin', 'mod']) work.
  • Any TypeError/ValueError from the underlying call is wrapped as RejectOperations so the chain short-circuits (matching upstream behaviour at function.py:27).

Table of Contents

Properties

$args  : array<string|int, mixed>
$function  : Closure
$kwargs  : array<string|int, mixed>

Methods

__construct()  : mixed
important()  : bool
`true` for operations that must always evaluate even when an earlier step in the chain raised `RejectOperations`. The canonical example is `~F->message->text` (`ImportantFunctionOperation` wrapping logical NOT): if `text` is missing we want the negation to still flip the `null` result to `true` rather than collapse to `false`.
resolve()  : mixed
Evaluate this operation.

Properties

Methods

__construct()

public __construct(Closure $function[, array<int, mixed> $args = [] ][, array<string, mixed> $kwargs = [] ]) : mixed
Parameters
$function : Closure
$args : array<int, mixed> = []
$kwargs : array<string, mixed> = []

important()

`true` for operations that must always evaluate even when an earlier step in the chain raised `RejectOperations`. The canonical example is `~F->message->text` (`ImportantFunctionOperation` wrapping logical NOT): if `text` is missing we want the negation to still flip the `null` result to `true` rather than collapse to `false`.

public important() : bool

Subclasses opt in by extending ImportantBaseOperation or by overriding this method directly.

Return values
bool

resolve()

Evaluate this operation.

public resolve(mixed $value, mixed $initialValue) : mixed
Parameters
$value : mixed

The current running value (output of the previous operation, or the original subject for the first step).

$initialValue : mixed

The original subject passed to MagicFilter::resolve. Used by combinator / comparator operations that need to resolve a nested MagicFilter against the root rather than the current intermediate value.

On this page

Search results