HTMLPurifier_VarParser_Flexible
extends HTMLPurifier_VarParser
in package
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.
Table of Contents
Constants
- ALIST = 9
- C_BOOL = 7
- C_FLOAT = 6
- C_INT = 5
- C_MIXED = 11
- C_STRING = 1
- HASH = 10
- ISTRING = 2
- ITEXT = 4
- LOOKUP = 8
- TEXT = 3
Properties
- $stringTypes : mixed
- Lookup table of types that are string, and can have aliases or allowed value lists.
- $types : mixed
- Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.
Methods
- getTypeName() : string
- parse() : string
- Validate a variable according to type.
- error() : mixed
- Throws an exception.
- errorGeneric() : mixed
- Generic error for if a type didn't work.
- errorInconsistent() : mixed
- Throws an inconsistency exception.
- parseImplementation() : array<string|int, mixed>|bool|float|int|mixed|null|string
- Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this!
Constants
ALIST
public
mixed
ALIST
= 9
C_BOOL
public
mixed
C_BOOL
= 7
C_FLOAT
public
mixed
C_FLOAT
= 6
C_INT
public
mixed
C_INT
= 5
C_MIXED
public
mixed
C_MIXED
= 11
C_STRING
public
mixed
C_STRING
= 1
HASH
public
mixed
HASH
= 10
ISTRING
public
mixed
ISTRING
= 2
ITEXT
public
mixed
ITEXT
= 4
LOOKUP
public
mixed
LOOKUP
= 8
TEXT
public
mixed
TEXT
= 3
Properties
$stringTypes
Lookup table of types that are string, and can have aliases or allowed value lists.
public
static mixed
$stringTypes
= array(self::C_STRING => \true, self::ISTRING => \true, self::TEXT => \true, self::ITEXT => \true)
$types
Lookup table of allowed types. Mainly for backwards compatibility, but also convenient for transforming string type names to the integer constants.
public
static mixed
$types
= array('string' => self::C_STRING, 'istring' => self::ISTRING, 'text' => self::TEXT, 'itext' => self::ITEXT, 'int' => self::C_INT, 'float' => self::C_FLOAT, 'bool' => self::C_BOOL, 'lookup' => self::LOOKUP, 'list' => self::ALIST, 'hash' => self::HASH, 'mixed' => self::C_MIXED)
Methods
getTypeName()
public
static getTypeName(int $type) : string
Parameters
- $type : int
Return values
stringparse()
Validate a variable according to type.
public
final parse(mixed $var, int $type[, bool $allow_null = false ]) : string
It may return NULL as a valid type if $allow_null is true.
Parameters
- $var : mixed
-
Variable to validate
- $type : int
-
Type of variable, see HTMLPurifier_VarParser->types
- $allow_null : bool = false
-
Whether or not to permit null as a value
Tags
Return values
string —Validated and type-coerced variable
error()
Throws an exception.
protected
error(mixed $msg) : mixed
Parameters
- $msg : mixed
Tags
errorGeneric()
Generic error for if a type didn't work.
protected
errorGeneric(mixed $var, int $type) : mixed
Parameters
- $var : mixed
- $type : int
errorInconsistent()
Throws an inconsistency exception.
protected
errorInconsistent(string $class, int $type) : mixed
Parameters
- $class : string
- $type : int
Tags
parseImplementation()
Actually implements the parsing. Base implementation does not do anything to $var. Subclasses should overload this!
protected
parseImplementation(mixed $var, int $type, bool $allow_null) : array<string|int, mixed>|bool|float|int|mixed|null|string
Parameters
- $var : mixed
- $type : int
- $allow_null : bool