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 a union type that accepts both the current type and the given type.
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 simple types, otherwise null.
Returns true whether it is a union type.
Returns true whether it is an intersection type.
Checks whether it is a simple (non-compound) type. Single nullable types such as ?int are also considered simple.
No description
Checks whether it is a simple PHP built-in type (int, string, bool, etc.).
Checks whether it is a simple class or interface name (not a built-in type).
Determines if type is special class name self/parent/static.
Checks whether a value of the given type could be assigned to this type.
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.
at line 69
static Type
fromString(string $type)
Creates the Type object according to the text notation.
at line 94
static Type
fromValue(mixed $value)
Creates a Type object based on the actual type of value.
at line 111
static string
resolve(string $type, ReflectionFunction|ReflectionMethod|ReflectionParameter|ReflectionProperty $of)
Resolves 'self', 'static' and 'parent' to the actual class name.
at line 151
string
__toString()
No description
at line 169
Type
with(string|self $type)
Returns a union type that accepts both the current type and the given type.
at line 187
array
getNames()
Returns the array of subtypes that make up the compound type as strings.
at line 197
array
getTypes()
Returns the array of subtypes that make up the compound type as Type objects.
at line 206
string|null
getSingleName()
Returns the type name for simple types, otherwise null.
at line 215
bool
isUnion()
Returns true whether it is a union type.
at line 224
bool
isIntersection()
Returns true whether it is an intersection type.
at line 233
bool
isSimple()
Checks whether it is a simple (non-compound) type. Single nullable types such as ?int are also considered simple.
at line 239
bool
isSingle()
No description
at line 249
bool
isBuiltin()
Checks whether it is a simple PHP built-in type (int, string, bool, etc.).
at line 258
bool
isClass()
Checks whether it is a simple class or interface name (not a built-in type).
at line 267
bool
isClassKeyword()
Determines if type is special class name self/parent/static.
at line 276
bool
allows(string|self $type)
Checks whether a value of the given type could be assigned to this type.