CastOperation
extends BaseOperation
in package
Apply a unary transformation to the running value: `F->id->cast(intval(...))` passes the value through `intval` and forwards the result.
Mirrors upstream magic_filter.operations.cast.CastOperation
(magic_filter/operations/cast.py). Any exception from the cast
function is caught and re-raised as RejectOperations so the chain
treats a failed cast like a missing attribute (the rest of the chain
is short-circuited unless an important operation rescues it).
The constructor parameter is a Closure; non-Closure callables passed
via MagicFilter::cast() are wrapped via Closure::fromCallable(...)
by the caller so the operation always holds a Closure.
Table of Contents
Properties
- $func : Closure
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
$func read-only
public
Closure
$func
Methods
__construct()
public
__construct(Closure $func) : mixed
Parameters
- $func : Closure
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.