API - XOOPS 2.5.11 Beta 2
By monxoops.fr
HTMLPurifier_VarParser Class Reference
Inheritance diagram for HTMLPurifier_VarParser:

Public Member Functions

 parse ($var, $type, $allow_null=false)
 

Static Public Member Functions

static getTypeName ($type)
 

Data Fields

const C_STRING = 1
 
const ISTRING = 2
 
const TEXT = 3
 
const ITEXT = 4
 
const C_INT = 5
 
const C_FLOAT = 6
 
const C_BOOL = 7
 
const LOOKUP = 8
 
const ALIST = 9
 
const HASH = 10
 
const C_MIXED = 11
 

Static Public Attributes

static $types
 
static $stringTypes
 

Protected Member Functions

 parseImplementation ($var, $type, $allow_null)
 
 error ($msg)
 
 errorInconsistent ($class, $type)
 
 errorGeneric ($var, $type)
 

Detailed Description

Parses string representations into their corresponding native PHP variable type. The base implementation does a simple type-check.

Member Function Documentation

◆ error()

error (   $msg)
protected

Throws an exception.

Exceptions
HTMLPurifier_VarParserException
Here is the caller graph for this function:

◆ errorGeneric()

errorGeneric (   $var,
  $type 
)
protected

Generic error for if a type didn't work.

Parameters
mixed$var
int$type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorInconsistent()

errorInconsistent (   $class,
  $type 
)
protected

Throws an inconsistency exception.

Note
This should not ever be called. It would be called if we extend the allowed values of HTMLPurifier_VarParser without updating subclasses.
Parameters
string$class
int$type
Exceptions
HTMLPurifier_Exception
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTypeName()

static getTypeName (   $type)
static
Parameters
int$type
Returns
string
Here is the caller graph for this function:

◆ parse()

parse (   $var,
  $type,
  $allow_null = false 
)
final

Validate a variable according to type. It may return NULL as a valid type if $allow_null is true.

Parameters
mixed$varVariable to validate
int$typeType of variable, see HTMLPurifier_VarParser->types
bool$allow_nullWhether or not to permit null as a value
Returns
string Validated and type-coerced variable
Exceptions
HTMLPurifier_VarParserException
Here is the call graph for this function:

◆ parseImplementation()

parseImplementation (   $var,
  $type,
  $allow_null 
)
protected

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

Parameters
mixed$var
int$type
bool$allow_null
Returns
string

Reimplemented in HTMLPurifier_VarParser_Flexible, and HTMLPurifier_VarParser_Native.

Here is the caller graph for this function:

Field Documentation

◆ $stringTypes

$stringTypes
static
Initial value:
= array(
self::C_STRING => true,
self::ISTRING => true,
self::TEXT => true,
self::ITEXT => true,
)

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

◆ $types

$types
static
Initial value:
= 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
)

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

◆ ALIST

const ALIST = 9

◆ C_BOOL

const C_BOOL = 7

◆ C_FLOAT

const C_FLOAT = 6

◆ C_INT

const C_INT = 5

◆ C_MIXED

const C_MIXED = 11

◆ C_STRING

const C_STRING = 1

◆ HASH

const HASH = 10

◆ ISTRING

const ISTRING = 2

◆ ITEXT

const ITEXT = 4

◆ LOOKUP

const LOOKUP = 8

◆ TEXT

const TEXT = 3

The documentation for this class was generated from the following file: