Skip to content

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.

Methods

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|bool|float|int|mixed|null|string

Parameters:

Parameter Type Description
$var mixed
$type int
$allow_null bool

Throws:


Inherited methods

parse

Validate a variable according to type.

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

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

  • This method is final.

Parameters:

Parameter Type Description
$var mixed Variable to validate
$type int Type of variable, see HTMLPurifier_VarParser->types
$allow_null bool Whether or not to permit null as a value

Return Value:

Validated and type-coerced variable

Throws:


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): string

Parameters:

Parameter Type Description
$var mixed
$type int
$allow_null bool

error

Throws an exception.

protected error(mixed $msg): mixed

Parameters:

Parameter Type Description
$msg mixed

Throws:


errorInconsistent

Throws an inconsistency exception.

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

Parameters:

Parameter Type Description
$class string
$type int

Throws:


errorGeneric

Generic error for if a type didn't work.

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

Parameters:

Parameter Type Description
$var mixed
$type int

getTypeName

public static getTypeName(int $type): string
  • This method is static.

Parameters:

Parameter Type Description
$type int


Automatically generated on 2025-03-18