Compound
extends AggregatedType
in package
FinalYes
Value Object representing a Compound Type.
A Compound Type is not so much a special keyword or object reference but is a series of Types that are separated
using an OR operator (|
). This combination of types signifies that whatever is associated with this compound type
may contain a value with any of the given types.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface.
- __toString() : string
- Returns a rendered output of the Type as it would be used in a DocBlock.
- contains() : bool
- Tests if this compound type contains the given type.
- get() : Type|null
- Returns the type at the given index.
- getIterator() : ArrayIterator<int, Type>
- has() : bool
- Tests if this compound type has a type with the given index.
- add() : void
Properties
$token
private
string
$token
$types
private
array<int, Type>
$types
= []
Tags
Methods
__construct()
Initializes a compound type (i.e. `string|int`) and tests if the provided types all implement the Type interface.
public
__construct(array<string|int, Type> $types) : mixed
Parameters
- $types : array<string|int, Type>
__toString()
Returns a rendered output of the Type as it would be used in a DocBlock.
public
__toString() : string
Return values
stringcontains()
Tests if this compound type contains the given type.
public
contains(Type $type) : bool
Parameters
- $type : Type
Return values
boolget()
Returns the type at the given index.
public
get(int $index) : Type|null
Parameters
- $index : int
Return values
Type|nullgetIterator()
public
getIterator() : ArrayIterator<int, Type>
Return values
ArrayIterator<int, Type>has()
Tests if this compound type has a type with the given index.
public
has(int $index) : bool
Parameters
- $index : int
Return values
booladd()
private
add(Type $type) : void
Parameters
- $type : Type