abstract class Type

PHP return, property and parameter types.

Constants

String

Int

Float

Bool

Array

Object

Callable

Iterable

Void

Never

Mixed

True

False

Null

Self

Parent

Static

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 Type
fromName(string $name)

No description

string
toString(bool $complex = false)

No description

string
__toString()

No description

include(string|self $type)

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

bool
accepts(string|self $type)

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

bool
isAllowedBy(Type $acceptor)

Called when THIS object is the "incoming" type being checked.

bool
isSupertypeOfAtomic(Type $type)

Validates if the given atomic type matches THIS acceptor.

static string
nullable(string $type, bool $nullable = true)

No description

static string
union(string ...$types)

No description

static string
intersection(string ...$types)

No description

Details

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

Creates the Type object according to the text notation.

Parameters

string $type

Return Value

Type

at line 84
static Type fromValue(mixed $value)

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

Parameters

mixed $value

Return Value

Type

at line 101
static Type fromName(string $name)

internal  
 

No description

Parameters

string $name

Return Value

Type

at line 112
string toString(bool $complex = false)

No description

Parameters

bool $complex

Return Value

string

at line 119
final string __toString()

No description

Return Value

string

at line 128
Type include(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 149
bool accepts(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

at line 159
protected bool isAllowedBy(Type $acceptor)

Called when THIS object is the "incoming" type being checked.

Parameters

Type $acceptor

Return Value

bool

at line 168
abstract protected bool isSupertypeOfAtomic(Type $type)

Validates if the given atomic type matches THIS acceptor.

Parameters

Type $type

Return Value

bool

at line 174
static string nullable(string $type, bool $nullable = true)

No description

Parameters

string $type
bool $nullable

Return Value

string

at line 199
static string union(string ...$types)

No description

Parameters

string ...$types

Return Value

string

at line 206
static string intersection(string ...$types)

No description

Parameters

string ...$types

Return Value

string