Page MenuHomePhorge

final class PhutilTypeSpec
libphutil Technical Documentation (Parsers)

Perform type checks using a simple type grammar. The grammar supports the following basic types:

int
float
bool
string
null
callable
regex
wild
AnyClassOrInterfaceName

It supports the following complex types:

list<type>
map<type, type>
type|type

A type may be marked as optional by suffixing it with "?" or prefixing it with the word "optional":

int?
optional int

A type may have a human-readable comment in parentheses, at the end:

int (must be even)

For example, these are valid type specifications:

int|string
map<int, bool>
list<list<wild>>
optional int
string (uppercase)

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

private function __construct()

This method is not documented.
Return
this//Implicit.//

public function getType()

This method is not documented.
Return
wild

public function check($value, $name)

This method is not documented.
Parameters
$value
$name
Return
wild

public static function checkMap($values, $types)

This method is not documented.
Parameters
array$values
array$types
Return
wild

public static function getCommonParentClass($class_a, $class_b)

This method is not documented.
Parameters
$class_a
$class_b
Return
wild

public static function getTypeOf($value)

This method is not documented.
Parameters
$value
Return
wild

private static function getTypeOfVector($vector)

This method is not documented.
Parameters
array$vector
Return
wild

public function toString()

This method is not documented.
Return
wild

public static function newFromString($string)

This method is not documented.
Parameters
$string
Return
wild

public static function didReduceTokens($rule, $production, $tokens)

This method is not documented.
Parameters
$rule
$production
array$tokens
Return
wild

private static function getLexer()

This method is not documented.
Return
wild

private static function parseTokens($tokens, $callback)

This method is not documented.
Parameters
array$tokens
$callback
Return
wild