Documentation

Parser
in package

Parsing algorithms

Tags
psalm-suppress

InvalidScalarArgument

Table of Contents

compileForeach()  : string
Method processes 'foreach' macro
compilePrint()  : string
Method processes 'print' macro
compileSwitch()  : string
Method processes 'switch' macro
compileValues()  : string
Method processes values substitution
getBlockData()  : mixed
Method returns content between {$blockStart} and {$blockEnd} tags
getBlockPositions()  : array<string|int, mixed>
Method returns block's start and end
getMacroParameters()  : string|bool
Method fetches macro parameters
printRecord()  : string
Method replaces all {var-name} placeholders in $string with fields from $record
replaceBlock()  : string
Method replaces block with content
unwrapBlocks()  : string
Method unwraps data
applyForeachData()  : string
Method applyes data for foreach block content
applyPrintData()  : string
Method applyes data for print block content
areTerminalParams()  : bool
Method returns true if the params are terminal, false otherwise
findMacro()  : string|bool
Getting macro start
getAllBlockPositions()  : array<string|int, mixed>
Method returns block's start and end
getPossibleBlockPositions()  : array<string|int, mixed>
Method returns starts and ends of the block
handleMacroEnd()  : void
Getting macro end
handleMacroStart()  : void
Getting macro start
handleMacroStartEnd()  : void
Getting macro bounds

Methods

compileForeach()

Method processes 'foreach' macro

public static compileForeach(string $string, mixed &$record) : string
Parameters
$string : string

processing string

$record : mixed

printing record

Return values
string

Processed string

compilePrint()

Method processes 'print' macro

public static compilePrint(string $string, mixed &$record) : string
Parameters
$string : string

processing string

$record : mixed

printing record

Tags
psalm-suppress

MixedAssignment

Return values
string

processed string

compileSwitch()

Method processes 'switch' macro

public static compileSwitch(string $string) : string
Parameters
$string : string

processing string

Tags
psalm-suppress

MixedAssignment, MixedArgument, MixedOperand

Return values
string

Processed string

compileValues()

Method processes values substitution

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

processing string

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

printing record

Return values
string

Processed string

getBlockData()

Method returns content between {$blockStart} and {$blockEnd} tags

public static getBlockData(string $string, string $blockStart, string $blockEnd) : mixed
Parameters
$string : string

processing string

$blockStart : string

start of the block

$blockEnd : string

end of the block

Tags
psalm-suppress

MixedAssignment, MixedArgument, MixedOperand

Return values
mixed

block content. Or false if the block was not found

getBlockPositions()

Method returns block's start and end

public static getBlockPositions(string $string, string $blockStart, string $blockEnd) : array<string|int, mixed>
Parameters
$string : string

Parsing string

$blockStart : string

Block start

$blockEnd : string

Block end

Return values
array<string|int, mixed>

Positions of the beginning and the end

getMacroParameters()

Method fetches macro parameters

public static getMacroParameters(string $string, string $name[, int|bool $startPos = -1 ]) : string|bool
Parameters
$string : string

string to be parsed

$name : string

macro name

$startPos : int|bool = -1

starting position of the search

Return values
string|bool

Macro parameters or false if the macro was not found

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

replaceBlock()

Method replaces block with content

public static replaceBlock(string $str, string $blockStart, string $blockEnd, string $content) : string
Parameters
$str : string

string to process

$blockStart : string

starting marker of the block

$blockEnd : string

ending marker of the block

$content : string

content to replace block

Tags
psalm-suppress

MixedAssignment, MixedArgument, MixedOperand

Return values
string

processed string

unwrapBlocks()

Method unwraps data

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

processing string

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

printing record

Tags
psalm-suppress

MixedArgument

Return values
string

processed string

applyForeachData()

Method applyes data for foreach block content

protected static applyForeachData(string $str, string $parameters, mixed $data) : string
Parameters
$str : string

string to process

$parameters : string

block parameters

$data : mixed

replacement data

Tags
psalm-suppress

MixedAssignment, MixedArgument

Return values
string

Processed string

applyPrintData()

Method applyes data for print block content

protected static applyPrintData(string $str, string $parameters, mixed $data) : string
Parameters
$str : string

string to process

$parameters : string

block parameters

$data : mixed

replacement data

Tags
psalm-suppress

MixedAssignment, MixedArgument

Return values
string

Processed string

areTerminalParams()

Method returns true if the params are terminal, false otherwise

protected static areTerminalParams(string $parameters) : bool
Parameters
$parameters : string

Parameters to be analized

Return values
bool

true if the params are terminal, false otherwise

findMacro()

Getting macro start

protected static findMacro(string &$stringData, int|bool &$tmpStartPos, int|bool &$tmpEndPos, int|bool &$startPos, int &$counter, int $macroStartPos, int $paramStartPos) : string|bool
Parameters
$stringData : string

parsing string

$tmpStartPos : int|bool

search temporary starting position

$tmpEndPos : int|bool

search temporary ending position

$startPos : int|bool

search starting position

$counter : int

brackets counter

$macroStartPos : int

position of the macro

$paramStartPos : int

position of macro's parameters

Return values
string|bool

macro parameters or false otherwise

getAllBlockPositions()

Method returns block's start and end

protected static getAllBlockPositions(string $string, string $blockStart, string $blockEnd) : array<string|int, mixed>
Parameters
$string : string

Parsing string

$blockStart : string

Block start

$blockEnd : string

Block end

Return values
array<string|int, mixed>

Starting and ending positions of the block

getPossibleBlockPositions()

Method returns starts and ends of the block

protected static getPossibleBlockPositions(array<string|int, mixed> &$positions) : array<string|int, mixed>
Parameters
$positions : array<string|int, mixed>

Starting and ending positions of the blocks

Tags
psalm-suppress

RedundantCondition

Return values
array<string|int, mixed>

Updated positions

handleMacroEnd()

Getting macro end

protected static handleMacroEnd(int|bool $tmpStartPos, int|bool $tmpEndPos, int|bool &$startPos, int &$counter, int $macroStartPos) : void
Parameters
$tmpStartPos : int|bool

Search temporary starting position

$tmpEndPos : int|bool

Search temporary ending position

$startPos : int|bool

Search starting position

$counter : int

Brackets counter

$macroStartPos : int

Position of the macro

Return values
void

handleMacroStart()

Getting macro start

protected static handleMacroStart(int|bool $tmpStartPos, int|bool $tmpEndPos, int|bool &$startPos, int &$counter) : void
Parameters
$tmpStartPos : int|bool

Search temporary starting position

$tmpEndPos : int|bool

Search temporary ending position

$startPos : int|bool

Search starting position

$counter : int

Brackets counter

Return values
void

handleMacroStartEnd()

Getting macro bounds

protected static handleMacroStartEnd(string &$stringData, int|bool &$tmpStartPos, int|bool &$tmpEndPos, int|bool &$startPos, int &$counter, int $macroStartPos) : void
Parameters
$stringData : string

Parsing string

$tmpStartPos : int|bool

Search temporary starting position

$tmpEndPos : int|bool

Search temporary ending position

$startPos : int|bool

Search starting position

$counter : int

Brackets counter

$macroStartPos : int

Position of the macro

Return values
void

Search results

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