abstract 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 Type
fromValue(mixed $value)

Creates a Type object based on the actual type of value.

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

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

string
__toString()

No description

with(string|self $type)

Returns a type that accepts both the current type and the given type.

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 simple types, otherwise null.

bool
isUnion()

Returns true whether it is a union type.

bool
isIntersection()

Returns true whether it is an intersection type.

bool
isSimple()

Returns true whether it is a simple type. Single nullable types are also considered to be simple types.

bool
isSingle()

No description

bool
isBuiltin()

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

bool
isClass()

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

bool
isClassKeyword()

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

bool
allows(string|self $type)

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

Details

at line 25
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 69
static Type fromString(string $type)

Creates the Type object according to the text notation.

Parameters

string $type

Return Value

Type

at line 98
static Type fromValue(mixed $value)

Creates a Type object based on the actual type of value.

Parameters

mixed $value

Return Value

Type

at line 117
static string resolve(string $type, ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $of)

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

Parameters

string $type
ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $of

Return Value

string

at line 137
abstract string __toString()

No description

Return Value

string

at line 143
Type with(string|self $type)

Returns a type that accepts both the current type and the given type.

Parameters

string|self $type

Return Value

Type

at line 165
abstract array getNames()

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

Return Value

array

at line 172
abstract array getTypes()

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

Return Value

array

at line 178
string|null getSingleName()

Returns the type name for simple types, otherwise null.

Return Value

string|null

at line 187
bool isUnion()

Returns true whether it is a union type.

Return Value

bool

at line 196
bool isIntersection()

Returns true whether it is an intersection type.

Return Value

bool

at line 205
bool isSimple()

Returns true whether it is a simple type. Single nullable types are also considered to be simple types.

Return Value

bool

at line 211
bool isSingle()

No description

Return Value

bool

at line 221
bool isBuiltin()

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

Return Value

bool

at line 230
bool isClass()

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

Return Value

bool

at line 239
bool isClassKeyword()

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

Return Value

bool

at line 248
bool allows(string|self $type)

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

Parameters

string|self $type

Return Value

bool