Documentation

EscaperRuntime
in package
implements RuntimeExtensionInterface

FinalYes

Table of Contents

Interfaces

RuntimeExtensionInterface

Properties

$charset  : mixed
$escapers  : array<string, callable(string, string): string>

Methods

__construct()  : mixed
addSafeClass()  : void
escape()  : mixed
Escapes a string.
getEscapers()  : array<string, callable(string $string, string $charset): string>
Gets all defined escapers.
setEscaper()  : void
Defines a new escaper to be used via the escape filter.
setSafeClasses()  : void
convertEncoding()  : mixed

Properties

$escapers

private array<string, callable(string, string): string> $escapers = []

Methods

__construct()

public __construct([mixed $charset = 'UTF-8' ]) : mixed
Parameters
$charset : mixed = 'UTF-8'

addSafeClass()

public addSafeClass(Stringable> $class, array<string|int, string> $strategies) : void
Parameters
$class : Stringable>
$strategies : array<string|int, string>

escape()

Escapes a string.

public escape(mixed $string[, string $strategy = 'html' ][, string|null $charset = null ][, bool $autoescape = false ]) : mixed
Parameters
$string : mixed

The value to be escaped

$strategy : string = 'html'

The escaping strategy

$charset : string|null = null

The charset

$autoescape : bool = false

Whether the function is called by the auto-escaping feature (true) or by the developer (false)

Tags
throws
RuntimeError

getEscapers()

Gets all defined escapers.

public getEscapers() : array<string, callable(string $string, string $charset): string>
Return values
array<string, callable(string $string, string $charset): string>

An array of escapers

setEscaper()

Defines a new escaper to be used via the escape filter.

public setEscaper(string $strategy, callable(string $string, string $charset): string $callable) : void
Parameters
$strategy : string

The strategy name that should be used as a strategy in the escape call

$callable : callable(string $string, string $charset): string

A valid PHP callable

setSafeClasses()

public setSafeClasses([array<Stringable>, array<string|int, string>> $safeClasses = [] ]) : void
Parameters
$safeClasses : array<Stringable>, array<string|int, string>> = []

convertEncoding()

private convertEncoding(string $string, string $to, string $from) : mixed
Parameters
$string : string
$to : string
$from : string

        
On this page

Search results