HumHub Documentation (unofficial)

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

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
string

parse()

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
throws
HTMLPurifier_VarParserException
Return values
string

Validated and type-coerced variable

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
note

This should not ever be called. It would be called if we extend the allowed values of HTMLPurifier_VarParser without updating subclasses.

throws
HTMLPurifier_Exception

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
Tags
throws
HTMLPurifier_VarParserException
Return values
array<string|int, mixed>|bool|float|int|mixed|null|string

        
On this page

Search results