ComparatorOperation
extends BaseOperation
in package
Binary comparison between the running value and a literal (or another `MagicFilter` chain that resolves against the same root): supports `==`, `!=`, `<`, `<=`, `>`, `>=` via a pluggable comparator closure.
Mirrors upstream magic_filter.operations.comparator.ComparatorOperation
(magic_filter/operations/comparator.py). Upstream stores the comparator
as a Python operator.eq / operator.lt / etc. callable; we use named
Closure instances built once in MagicFilter::__construct to keep the
dispatch table cheap.
The right operand is resolved lazily via Helper::resolveIfNeeded so
call sites like F->id == F->reply->fromUser->id work (both sides are
MagicFilter chains rooted on the same subject).
Table of Contents
Properties
- $comparator : Closure
- $right : 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
$comparator read-only
public
Closure
$comparator
$right read-only
public
mixed
$right
Methods
__construct()
public
__construct(mixed $right, Closure $comparator) : mixed
Parameters
- $right : mixed
- $comparator : 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.