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:
argsare prepended to the value:function(...$args, $value). This matches upstream which callsfunction(*args, value, **kwargs).kwargsare passed as named arguments.- Each
arg/kwargentry that is itself aMagicFilteris resolved against the original subject before the call, courtesy ofHelper::resolveIfNeeded— so call sites likeF->func(InArrayCheck, ['admin', 'mod'])work. - Any
TypeError/ValueErrorfrom the underlying call is wrapped asRejectOperationsso the chain short-circuits (matching upstream behaviour atfunction.py:27).
Table of Contents
Properties
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
$args read-only
public
array<string|int, mixed>
$args
= []
$function read-only
public
Closure
$function
$kwargs read-only
public
array<string|int, mixed>
$kwargs
= []
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
boolresolve()
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 nestedMagicFilteragainst the root rather than the current intermediate value.