final class PhpHelpers

internal  
 

PHP helpers.

Methods

static string
reformatCode(string $source)

Optimizes code readability.

static string
dump(mixed $value, bool $multiline = false)

Exports value to PHP code representation.

static string
optimizeEcho(string $source)

Optimizes consecutive echo statements into single call.

static int|float|null
decodeNumber(string $str, int|null $base = null)

Decodes number string to int or float value.

static string
decodeEscapeSequences(string $str, string|null $quote)

Decodes PHP string escape sequences (e.g. \n, \x1B, \u{1F600}).

static void
checkCode(string $phpBinary, string $code, string $name)

Validates the generated PHP code using the given PHP binary as a linter.

Details

at line 24
static string reformatCode(string $source)

Optimizes code readability.

Parameters

string $source

Return Value

string

at line 104
static string dump(mixed $value, bool $multiline = false)

Exports value to PHP code representation.

Parameters

mixed $value
bool $multiline

Return Value

string

at line 127
static string optimizeEcho(string $source)

Optimizes consecutive echo statements into single call.

Parameters

string $source

Return Value

string

at line 169
static int|float|null decodeNumber(string $str, int|null $base = null)

Decodes number string to int or float value.

Parameters

string $str
int|null $base

Return Value

int|float|null

at line 195
static string decodeEscapeSequences(string $str, string|null $quote)

Decodes PHP string escape sequences (e.g. \n, \x1B, \u{1F600}).

Pass $quote to also unescape the given quote character.

Parameters

string $str
string|null $quote

Return Value

string

at line 251
static void checkCode(string $phpBinary, string $code, string $name)

Validates the generated PHP code using the given PHP binary as a linter.

Throws CompileException if the code contains syntax errors.

Parameters

string $phpBinary
string $code
string $name

Return Value

void