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 simple types, otherwise null.
Returns true whether it is a union type.
Returns true whether it is an intersection type.
Returns true whether it is a simple type. Single nullable types are also considered to be simple types.
No description
Returns true whether the type is both a simple and a PHP built-in type.
Returns true whether the type is both a simple and a class name.
Determines if type is special class name self/parent/static.
Verifies type compatibility. For example, it checks if a value of a certain type could be passed as a parameter.
Details
at line 31
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 66
static Type
fromString(string $type)
Creates the Type object according to the text notation.
at line 91
static Type
fromValue(mixed $value)
Creates a Type object based on the actual type of value.
at line 108
static string
resolve(string $type, ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty $of)
Resolves 'self', 'static' and 'parent' to the actual class name.
at line 142
string
__toString()
No description
at line 160
Type
with(string|self $type)
Returns a type that accepts both the current type and the given type.
at line 178
array
getNames()
Returns the array of subtypes that make up the compound type as strings.
at line 188
array
getTypes()
Returns the array of subtypes that make up the compound type as Type objects:
at line 197
string|null
getSingleName()
Returns the type name for simple types, otherwise null.
at line 208
bool
isUnion()
Returns true whether it is a union type.
at line 217
bool
isIntersection()
Returns true whether it is an intersection type.
at line 226
bool
isSimple()
Returns true whether it is a simple type. Single nullable types are also considered to be simple types.
at line 232
bool
isSingle()
No description
at line 242
bool
isBuiltin()
Returns true whether the type is both a simple and a PHP built-in type.
at line 251
bool
isClass()
Returns true whether the type is both a simple and a class name.
at line 260
bool
isClassKeyword()
Determines if type is special class name self/parent/static.
at line 269
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.