class Context (View source)

A Eel evaluation context

It works as a variable container with wrapping of return values for safe access without warnings (on missing properties).

Methods

__construct(mixed $value = null, EelInvocationTracerInterface|null $tracer = null)

No description

mixed
get(string|int|Context $path)

Get a value of the context

getAndWrap(string $path = null)

Get a value by path and wrap it into another context

mixed
call(string $method, array $arguments = [])

Call a method on this context

mixed
callAndWrap(string $method, array $arguments = [])

Call a method and wrap the result

wrap(mixed $value)

Wraps the given value in a new Context

mixed
unwrap()

Unwrap the context value recursively

mixed
unwrapValue(mixed $value)

Unwrap a value by unwrapping nested context objects

push(mixed $value, string $key = null)

Push an entry to the context

Details

__construct(mixed $value = null, EelInvocationTracerInterface|null $tracer = null)

No description

Parameters

mixed $value
EelInvocationTracerInterface|null $tracer

mixed get(string|int|Context $path)

Get a value of the context

This basically acts as a safe access to non-existing properties, unified array and property access (using getters) and access to the current value (empty path).

If a property or key did not exist this method will return NULL.

Parameters

string|int|Context $path

The path as string or Context value, will be unwrapped for convenience

Return Value

mixed

The value

Exceptions

EvaluationException

Context getAndWrap(string $path = null)

Get a value by path and wrap it into another context

Parameters

string $path

Return Value

Context

The wrapped value

mixed call(string $method, array $arguments = [])

Call a method on this context

Parameters

string $method
array $arguments

Arguments to the method, if of type Context they will be unwrapped

Return Value

mixed

Exceptions

Exception

mixed callAndWrap(string $method, array $arguments = [])

Call a method and wrap the result

Parameters

string $method
array $arguments

Return Value

mixed

Context wrap(mixed $value)

Wraps the given value in a new Context

Parameters

mixed $value

Return Value

Context

mixed unwrap()

Unwrap the context value recursively

Return Value

mixed

mixed unwrapValue(mixed $value)

Unwrap a value by unwrapping nested context objects

This method is public for closure access.

Parameters

mixed $value

Return Value

mixed

Context push(mixed $value, string $key = null)

Push an entry to the context

Is used to build array instances inside the evaluator.

Parameters

mixed $value
string $key

Return Value

Context

Exceptions

EvaluationException