class Helpers

internal  
 

Latte helpers.

Methods

static string|null
getSuggestion(array $items, string $value)

Finds the best suggestion.

toReflection(mixed $callable)

Returns a reflection object for the given callable.

static array
sortBeforeAfter(array $list)

Sorts items by before/after ordering constraints defined as \stdClass objects.

static void
removeNulls(array $items)

Removes null values from the array and re-indexes it.

static array|null
mapCompiledToSource(string $compiledFile, int|null $compiledLine = null)

Attempts to map the compiled template to the source.

static string|null
guessTemplatePosition()

Tries to guess the template position from the backtrace. Returns a human-readable string like "in 'path/to/template.latte' on line 42", or null if the position cannot be determined.

static array
resolveParams(Engine $engine, object|array $params)

Resolves template parameters from an object, its public properties are extracted as variables and annotated methods are registered as filters/functions.

Details

at line 24
static string|null getSuggestion(array $items, string $value)

Finds the best suggestion.

Parameters

array $items
string $value

Return Value

string|null

at line 43
static ReflectionFunctionAbstract toReflection(mixed $callable)

Returns a reflection object for the given callable.

Intentionally without callable type hint to avoid unhelpful error messages.

Parameters

mixed $callable

Return Value

ReflectionFunctionAbstract

at line 64
static array sortBeforeAfter(array $list)

Sorts items by before/after ordering constraints defined as \stdClass objects.

Parameters

array $list

Return Value

array

at line 147
static void removeNulls(array $items)

Removes null values from the array and re-indexes it.

Parameters

array $items

Return Value

void

at line 157
static array|null mapCompiledToSource(string $compiledFile, int|null $compiledLine = null)

Attempts to map the compiled template to the source.

Parameters

string $compiledFile
int|null $compiledLine

Return Value

array|null

at line 179
static string|null guessTemplatePosition()

Tries to guess the template position from the backtrace. Returns a human-readable string like "in 'path/to/template.latte' on line 42", or null if the position cannot be determined.

Return Value

string|null

at line 204
static array resolveParams(Engine $engine, object|array $params)

Resolves template parameters from an object, its public properties are extracted as variables and annotated methods are registered as filters/functions.

Parameters

Engine $engine
object|array $params

Return Value

array