Documentation

Expression
in package

LightnCandy Expression handler

Table of Contents

analyze()  : array<string|int, int|bool|array>
Analyze an expression
arrayString()  : string
Get string presentation for an array
boolString()  : string
return 'true' or 'false' string.
listString()  : string
Get string presentation for a string list
toString()  : string
get normalized handlebars expression for a variable

Methods

analyze()

Analyze an expression

public static analyze(array<string, array|string|int> $context, array<string|int, array|string|int> $var) : array<string|int, int|bool|array>
Parameters
$context : array<string, array|string|int>

Current context

$var : array<string|int, array|string|int>

variable parsed path

Tags
expect

array(0, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(0, 'foo')

expect

array(1, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(1, 'foo')

Return values
array<string|int, int|bool|array>

analyzed result

arrayString()

Get string presentation for an array

public static arrayString(array<string|int, string> $list) : string
Parameters
$list : array<string|int, string>

an array of variable names.

Tags
expect

'' when input array()

expect

"['a']" when input array('a')

expect

"['a']['b']['c']" when input array('a', 'b', 'c')

Return values
string

PHP array names string

boolString()

return 'true' or 'false' string.

public static boolString(int $v) : string
Parameters
$v : int

value

Tags
expect

'true' when input 1

expect

'true' when input 999

expect

'false' when input 0

expect

'false' when input -1

Return values
string

'true' when the value larger then 0

listString()

Get string presentation for a string list

public static listString(array<string|int, string> $list) : string
Parameters
$list : array<string|int, string>

an array of strings.

Tags
expect

'' when input array()

expect

"'a'" when input array('a')

expect

"'a','b','c'" when input array('a', 'b', 'c')

Return values
string

PHP list string

toString()

get normalized handlebars expression for a variable

public static toString(int $levels, bool $spvar, array<string|int, string|int> $var) : string
Parameters
$levels : int

trace N levels top parent scope

$spvar : bool

is the path start with @ or not

$var : array<string|int, string|int>

variable parsed path

Tags
expect

'[a].[b]' when input 0, false, array('a', 'b')

expect

'@[root]' when input 0, true, array('root')

expect

'this' when input 0, false, null

expect

'this.[id]' when input 0, false, array(null, 'id')

expect

'@[root].[a].[b]' when input 0, true, array('root', 'a', 'b')

expect

'../../[a].[b]' when input 2, false, array('a', 'b')

expect

'../[a'b]' when input 1, false, array('a'b')

Return values
string

normalized expression for debug display

Search results