class Quick

Methods

static string
getSource(array $compiledTemplates)

Generate the Quick renderer's source

static string
export(array $arr)

Export an array as PHP

static array[]
getRenderingStrategy(string $php)

Compute the rendering strategy for a compiled template

static string[]
getQuickRendering(string $php)

Generate the code for rendering a compiled template with the Quick renderer

static void
convertPHP(string $head, string $tail, bool $passthrough)

Convert the two sides of a compiled template to quick rendering

static void
replacePHP(string $php)

Replace the PHP code used in a compiled template to be used by the Quick renderer

static string[]
buildPHP(array $branches)

Build the source for the two sides of a templates based on the structure extracted from its original source

static int[]
getBranchesPassthrough(array $branches)

Get the unique values for the "passthrough" key of given branches

static array|bool
getDynamicRendering(string $php)

Get a string suitable as a preg_replace() replacement for given PHP code

static bool|string
getStaticRendering(string $php)

Get a string suitable as a str_replace() replacement for given PHP code

static array
getStringRenderings(string $php)

Get string rendering strategies for given chunks

static void
replacePlaceholder(string $str, string $uniqid, int $index)

Replace all instances of a uniqid with a PCRE replacement in a string

Details

at line 22
static string getSource(array $compiledTemplates)

Generate the Quick renderer's source

Parameters

array $compiledTemplates

Array of tagName => compiled template

Return Value

string

at line 104
static protected string export(array $arr)

Export an array as PHP

Parameters

array $arr

Return Value

string

at line 125
static array[] getRenderingStrategy(string $php)

Compute the rendering strategy for a compiled template

Parameters

string $php

Template compiled for the PHP renderer

Return Value

array[]

An array containing 0 to 2 pairs of [, ]

at line 159
static protected string[] getQuickRendering(string $php)

Generate the code for rendering a compiled template with the Quick renderer

Parse and record every code path that contains a passthrough. Parse every if-else structure. When the whole structure is parsed, there are 2 possible situations:

  • no code path contains a passthrough, in which case we discard the data
  • all the code paths including the mandatory "else" branch contain a passthrough, in which case we keep the data

Parameters

string $php

Template compiled for the PHP renderer

Return Value

string[]

An array containing one or two strings of PHP, or an empty array if the PHP cannot be converted

at line 341
static protected void convertPHP(string $head, string $tail, bool $passthrough)

Convert the two sides of a compiled template to quick rendering

Parameters

string $head
string $tail
bool $passthrough

Return Value

void

at line 394
static protected void replacePHP(string $php)

Replace the PHP code used in a compiled template to be used by the Quick renderer

Parameters

string $php

Return Value

void

at line 503
static protected string[] buildPHP(array $branches)

Build the source for the two sides of a templates based on the structure extracted from its original source

Parameters

array $branches

Return Value

string[]

at line 532
static protected int[] getBranchesPassthrough(array $branches)

Get the unique values for the "passthrough" key of given branches

Parameters

array $branches

Return Value

int[]

at line 556
static protected array|bool getDynamicRendering(string $php)

Get a string suitable as a preg_replace() replacement for given PHP code

Parameters

string $php

Original code

Return Value

array|bool

Array of [regexp, replacement] if possible, or FALSE otherwise

at line 693
static protected bool|string getStaticRendering(string $php)

Get a string suitable as a str_replace() replacement for given PHP code

Parameters

string $php

Original code

Return Value

bool|string

Static replacement if possible, or FALSE otherwise

at line 715
static protected array getStringRenderings(string $php)

Get string rendering strategies for given chunks

Parameters

string $php

Return Value

array

at line 756
static protected void replacePlaceholder(string $str, string $uniqid, int $index)

Replace all instances of a uniqid with a PCRE replacement in a string

Parameters

string $str

PCRE replacement

string $uniqid

Unique ID

int $index

Capture index

Return Value

void