final class Type

PHP type reflection.

Methods

static Type|null
fromReflection(ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection)

Creates a Type object based on reflection. Resolves self, static and parent to the actual class name.

static Type
fromString(string $type)

Creates the Type object according to the text notation.

static string
resolve(string $type, ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection)

Resolves 'self', 'static' and 'parent' to the actual class name.

string
__toString()

No description

array
getNames()

Returns the array of subtypes that make up the compound type as strings.

array
getTypes()

Returns the array of subtypes that make up the compound type as Type objects:

string|null
getSingleName()

Returns the type name for single types, otherwise null.

bool
isUnion()

Returns true whether it is a union type.

bool
isIntersection()

Returns true whether it is an intersection type.

bool
isSingle()

Returns true whether it is a single type. Simple nullable types are also considered to be single types.

bool
isBuiltin()

Returns true whether the type is both a single and a PHP built-in type.

bool
isClass()

Returns true whether the type is both a single and a class name.

bool
isClassKeyword()

Determines if type is special class name self/parent/static.

bool
allows(string $type)

Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.

Details

at line 29
static Type|null fromReflection(ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection)

Creates a Type object based on reflection. Resolves self, static and parent to the actual class name.

If the subject has no type, it returns null.

Parameters

ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection

Return Value

Type|null

at line 65
static Type fromString(string $type)

Creates the Type object according to the text notation.

Parameters

string $type

Return Value

Type

at line 88
static string resolve(string $type, ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection)

Resolves 'self', 'static' and 'parent' to the actual class name.

Parameters

string $type
ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection

Return Value

string

at line 117
string __toString()

No description

Return Value

string

at line 129
array getNames()

Returns the array of subtypes that make up the compound type as strings.

Return Value

array

at line 139
array getTypes()

Returns the array of subtypes that make up the compound type as Type objects:

Return Value

array

at line 148
string|null getSingleName()

Returns the type name for single types, otherwise null.

Return Value

string|null

at line 159
bool isUnion()

Returns true whether it is a union type.

Return Value

bool

at line 168
bool isIntersection()

Returns true whether it is an intersection type.

Return Value

bool

at line 177
bool isSingle()

Returns true whether it is a single type. Simple nullable types are also considered to be single types.

Return Value

bool

at line 186
bool isBuiltin()

Returns true whether the type is both a single and a PHP built-in type.

Return Value

bool

at line 195
bool isClass()

Returns true whether the type is both a single and a class name.

Return Value

bool

at line 204
bool isClassKeyword()

Determines if type is special class name self/parent/static.

Return Value

bool

at line 213
bool allows(string $type)

Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.

Parameters

string $type

Return Value

bool