Documentation

Parser2
in package

Parsing algorithms

Tags
psalm-suppress

MixedReturnStatement, MixedInferredReturnType

Table of Contents

$macroHandlers  : array<string, callable>
List of macro handlers
compile()  : string
Method compiles string
printRecord()  : string
Method replaces all {var-name} placeholders in $string with fields from $record
processMacro()  : string
Method processes the specified macro
getContentInBraces()  : string
Method extracts content within macro
getMacroName()  : string
Method returns macro name
getReadEnd()  : int
Method finds position of the final symbol to de read
getReadStart()  : int
Method returns read start
hasParameters()  : bool
Checking if the macro has parameters
substituteMacro()  : string
Method substitutes macro

Properties

$macroHandlers

List of macro handlers

public static array<string, callable> $macroHandlers = ['foreach' => 'Handlers\ForeachHandler::parse', 'switch' => 'Handlers\SwitchHandler::parse']

Methods

compile()

Method compiles string

public static compile(string $string[, array<string|int, mixed>|object $record = [] ]) : string
Parameters
$string : string

string to be compiled

$record : array<string|int, mixed>|object = []

set of vars to be applied

Return values
string

compiled string

printRecord()

Method replaces all {var-name} placeholders in $string with fields from $record

public static printRecord(string $string, array<string|int, mixed>|object|mixed $record) : string
Parameters
$string : string

processing string

$record : array<string|int, mixed>|object|mixed

printing record

Return values
string

processMacro()

Method processes the specified macro

public static processMacro(string $macroName, string $content, array<string|int, mixed>|object $record) : string
Parameters
$macroName : string

macro name

$content : string

content to be processed

$record : array<string|int, mixed>|object

set of vars to be applied

Return values
string

processed content

getContentInBraces()

Method extracts content within macro

protected static getContentInBraces(string $content, int $openBracePosition) : string
Parameters
$content : string

content to be parsed

$openBracePosition : int

starting position

Return values
string

macro content

getMacroName()

Method returns macro name

protected static getMacroName(string $content, int $openBracePosition) : string
Parameters
$content : string

content to be parsed

$openBracePosition : int

open brace position

Return values
string

macro name

getReadEnd()

Method finds position of the final symbol to de read

protected static getReadEnd(string $content, int $openBracePosition) : int
Parameters
$content : string

content to be parsed

$openBracePosition : int

start of the macro

Return values
int

position of the final symbol to de read

getReadStart()

Method returns read start

protected static getReadStart(string $content, int $openBracePosition) : int
Parameters
$content : string

content to be processed

$openBracePosition : int

open brace position

Return values
int

read cursor

hasParameters()

Checking if the macro has parameters

protected static hasParameters(string $content, int $openBracePosition) : bool
Parameters
$content : string

content to be parsed

$openBracePosition : int

start of the macro

Return values
bool

if the macro has parameters, false otherwise

substituteMacro()

Method substitutes macro

protected static substituteMacro(string $string, string $content, int $openBracePosition) : string
Parameters
$string : string

string to be processed

$content : string

already processed string

$openBracePosition : int

starting of the macro

Return values
string

parsed

Search results

    Яндекс.Метрика