Type
final class Type
PHP type reflection.
Methods
Creates a Type object based on reflection. Resolves self, static and parent to the actual class name.
Creates the Type object according to the text notation.
Resolves 'self', 'static' and 'parent' to the actual class name.
No description
Returns the array of subtypes that make up the compound type as strings.
Returns the array of subtypes that make up the compound type as Type objects:
Returns the type name for single types, otherwise null.
Returns true whether it is a union type.
Returns true whether it is a single type. Simple nullable types are also considered to be single types.
Returns true whether the type is both a single and a PHP built-in type.
Returns true whether the type is both a single and a class name.
Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.
Details
at line 32
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.
at line 65
static Type
fromString(string $type)
Creates the Type object according to the text notation.
at line 82
static string
resolve(string $type, ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $reflection)
Resolves 'self', 'static' and 'parent' to the actual class name.
at line 107
string
__toString()
No description
at line 119
array
getNames()
Returns the array of subtypes that make up the compound type as strings.
at line 129
array
getTypes()
Returns the array of subtypes that make up the compound type as Type objects:
at line 138
string|null
getSingleName()
Returns the type name for single types, otherwise null.
at line 149
bool
isUnion()
Returns true whether it is a union type.
at line 158
bool
isSingle()
Returns true whether it is a single type. Simple nullable types are also considered to be single types.
at line 167
bool
isBuiltin()
Returns true whether the type is both a single and a PHP built-in type.
at line 176
bool
isClass()
Returns true whether the type is both a single and a class name.
at line 185
bool
allows(string $type)
Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.