\HTMLPurifier_VarParser_Flexible

Performs safe variable parsing based on types which can be used by users. This may not be able to represent all possible data inputs, however.

Summary

Methods
Properties
Constants
parse()
getTypeName()
$types
$stringTypes
C_STRING
ISTRING
TEXT
ITEXT
C_INT
C_FLOAT
C_BOOL
LOOKUP
ALIST
HASH
C_MIXED
parseImplementation()
error()
errorInconsistent()
errorGeneric()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

C_STRING

C_STRING = 1

ISTRING

ISTRING = 2

TEXT

TEXT = 3

ITEXT

ITEXT = 4

C_INT

C_INT = 5

C_FLOAT

C_FLOAT = 6

C_BOOL

C_BOOL = 7

LOOKUP

LOOKUP = 8

ALIST

ALIST = 9

HASH

HASH = 10

C_MIXED

C_MIXED = 11

Properties

$types

$types

Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.

$stringTypes

$stringTypes

Lookup table of types that are string, and can have aliases or allowed value lists.

Methods

parse()

parse(mixed  $var, int  $type, bool  $allow_null = false) : string

Validate a variable according to type.

It may return NULL as a valid type if $allow_null is true.

Parameters

mixed $var

Variable to validate

int $type

Type of variable, see HTMLPurifier_VarParser->types

bool $allow_null

Whether or not to permit null as a value

Throws

\HTMLPurifier_VarParserException

Returns

string —

Validated and type-coerced variable

getTypeName()

getTypeName(int  $type) : string

Parameters

int $type

Returns

string —

parseImplementation()

parseImplementation(mixed  $var, int  $type, bool  $allow_null) : array|bool|float|int|mixed|null|string

Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this!

Parameters

mixed $var
int $type
bool $allow_null

Throws

\HTMLPurifier_VarParserException

Returns

array|bool|float|int|mixed|null|string —

error()

error(mixed  $msg) : mixed

Throws an exception.

Parameters

mixed $msg

Throws

\HTMLPurifier_VarParserException

Returns

mixed —

errorInconsistent()

errorInconsistent(string  $class, int  $type) : mixed

Throws an inconsistency exception.

Parameters

string $class
int $type

Throws

\HTMLPurifier_Exception

Returns

mixed —

errorGeneric()

errorGeneric(mixed  $var, int  $type) : mixed

Generic error for if a type didn't work.

Parameters

mixed $var
int $type

Returns

mixed —