\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.

Type

$stringTypes

$stringTypes : 

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

Type

Methods

parse()

parse(mixed  $var, integer  $type, boolean  $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

integer $type

Type of variable, see HTMLPurifier_VarParser->types

boolean $allow_null

Whether or not to permit null as a value

Throws

\HTMLPurifier_VarParserException

Returns

string —

Validated and type-coerced variable

getTypeName()

getTypeName(integer  $type) : string

Parameters

integer $type

Returns

string

parseImplementation()

parseImplementation(mixed  $var, integer  $type, boolean  $allow_null) : array|boolean|float|integer|mixed|null|string

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

Parameters

mixed $var
integer $type
boolean $allow_null

Throws

\HTMLPurifier_VarParserException

Returns

array|boolean|float|integer|mixed|null|string

error()

error(  $msg) 

Throws an exception.

Parameters

$msg

Throws

\HTMLPurifier_VarParserException

errorInconsistent()

errorInconsistent(string  $class, integer  $type) 

Throws an inconsistency exception.

Parameters

string $class
integer $type

Throws

\HTMLPurifier_Exception

errorGeneric()

errorGeneric(mixed  $var, integer  $type) 

Generic error for if a type didn't work.

Parameters

mixed $var
integer $type