CRUDUI PHP API

Expression
in package

FinalYes

Public facade for the CRUDUI expression engine: string → tokens → AST → value.

The pipeline is strictly staged (GRAMMAR §0): never split a string to evaluate, never eval. parse() caches one AST per expression string, at most CACHE_CAPACITY of them with the least recently used evicted first, as in the TypeScript and Go validators. evaluate() returns a boolean condition result; evaluateValue() returns a ternary's branch value and the boolean condition result for everything else (JS evaluateExpressionValue parity — the shared 4-language fixture is generated from the JS engine).

Table of Contents

Constants

CACHE_CAPACITY  : mixed = 1000
The most parsed expressions kept at once.

Properties

$cache  : array<string, Node>

Methods

clearCache()  : void
Clear the parsed-AST cache.
evaluate()  : bool
Evaluate to a truthy boolean (show/display call site): the result of the expression read as a condition, which `evaluateValue` returns as it is.
evaluateValue()  : mixed
Evaluate to the raw value (class/style/number/null call site): the value the expression selects, such as the class of a ternary or the number of a path, where `evaluate` returns only its truth.
isConditionExpression()  : bool
Recognize expression strings used by validation and form appearance.
parse()  : Node
Parse an expression into its AST (cached).
tokenize()  : array<int, Token>
Tokenize an expression. WHITESPACE excluded; ends with EOF.

Constants

CACHE_CAPACITY

The most parsed expressions kept at once.

public mixed CACHE_CAPACITY = 1000

Properties

$cache

private static array<string, Node> $cache = []

parsed-AST cache keyed by expression text, least recently used first

Methods

clearCache()

Clear the parsed-AST cache.

public static clearCache() : void

evaluate()

Evaluate to a truthy boolean (show/display call site): the result of the expression read as a condition, which `evaluateValue` returns as it is.

public static evaluate(string $expression, array<string, mixed>|stdClass $formData[, array<int, string> $currentPath = [] ][, array<int, int> $rowKeys = [] ]) : bool
Parameters
$expression : string
$formData : array<string, mixed>|stdClass

the form data that the paths of the expression read

$currentPath : array<int, string> = []

the path of the field that carries the expression

$rowKeys : array<int, int> = []

positions of the row keys in $currentPath

Return values
bool

evaluateValue()

Evaluate to the raw value (class/style/number/null call site): the value the expression selects, such as the class of a ternary or the number of a path, where `evaluate` returns only its truth.

public static evaluateValue(string $expression, array<string, mixed>|stdClass $formData[, array<int, string> $currentPath = [] ][, array<int, int> $rowKeys = [] ]) : mixed
Parameters
$expression : string
$formData : array<string, mixed>|stdClass

the form data that the paths of the expression read

$currentPath : array<int, string> = []

the path of the field that carries the expression

$rowKeys : array<int, int> = []

positions of the row keys in $currentPath

isConditionExpression()

Recognize expression strings used by validation and form appearance.

public static isConditionExpression(string $value) : bool
Parameters
$value : string
Return values
bool

parse()

Parse an expression into its AST (cached).

public static parse(string $expression) : Node
Parameters
$expression : string
Return values
Node

tokenize()

Tokenize an expression. WHITESPACE excluded; ends with EOF.

public static tokenize(string $expression) : array<int, Token>
Parameters
$expression : string
Return values
array<int, Token>
On this page

Search results