class CompilingEvaluator implements EelEvaluatorInterface (View source)

An evaluator that compiles expressions down to PHP code

This simple implementation will lazily parse and evaluate the generated PHP code into a function with a name built from the hashed expression.

Properties

protected closure[] $evaluatedExpressions

Runtime cache of execution ready closures.

protected StringFrontend $expressionCache

Methods

injectExpressionCache(StringFrontend $expressionCache)

TODO: As soon as we support PSR-16 (Simple Cache) this could be replaced by a simple cache.

mixed
evaluate(string $expression, Context $context)

Evaluate an expression under a given context

mixed
evaluateAndUnwrap(closure $expressionFunction, Context $context)

No description

string
generateEvaluatorCode(string $expression)

Internal generator method

Details

injectExpressionCache(StringFrontend $expressionCache)

TODO: As soon as we support PSR-16 (Simple Cache) this could be replaced by a simple cache.

Parameters

StringFrontend $expressionCache

mixed evaluate(string $expression, Context $context)

Evaluate an expression under a given context

Parameters

string $expression

The expression to evaluate

Context $context

The context to provide to the expression

Return Value

mixed

The evaluated expression

protected mixed evaluateAndUnwrap(closure $expressionFunction, Context $context)

No description

Parameters

closure $expressionFunction
Context $context

Return Value

mixed

protected string generateEvaluatorCode(string $expression)

Internal generator method

Used by unit tests to debug generated PHP code.

Parameters

string $expression

Return Value

string

Exceptions

ParserException