CooperTuple
in package
implements
ArrayAccess, Countable, IteratorAggregate, JsonSerializable
A CASC tuple (CASC.md ยง6.11) -- `office_location = (52.5200, 13.4050)`.
The spec requires a genuine tuple type all the way through to the
returned value ("an implementation must carry a real tuple type
through parsing, merging, and the final returned value"), and a PHP
array could not be told apart from a list again. Read-only:
array-style reads, count(), and foreach work, writes throw.
Tags
Table of Contents
Interfaces
- ArrayAccess
- Countable
- IteratorAggregate
- JsonSerializable
Properties
- $items : array<int, mixed>
Methods
- __construct() : mixed
- count() : int
- equals() : bool
- Whether `$other` is a tuple of the same arity with equal elements.
- getIterator() : ArrayIterator<int, mixed>
- jsonSerialize() : array<int, mixed>
- Encodes as a JSON array of the elements.
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : never
- offsetUnset() : never
- toArray() : array<int, mixed>
- The tuple's elements as a plain list.
Properties
$items read-only
public
array<int, mixed>
$items
Methods
__construct()
public
__construct(array<string|int, mixed> $items) : mixed
Parameters
- $items : array<string|int, mixed>
-
the tuple's elements, in order (keys are discarded)
count()
public
count() : int
Return values
int —the tuple's arity
equals()
Whether `$other` is a tuple of the same arity with equal elements.
public
equals(mixed $other) : bool
Parameters
- $other : mixed
-
the value to compare against
Return values
bool —true when both tuples hold equal elements in the same order
getIterator()
public
getIterator() : ArrayIterator<int, mixed>
Return values
ArrayIterator<int, mixed> —an iterator over the elements
jsonSerialize()
Encodes as a JSON array of the elements.
public
jsonSerialize() : array<int, mixed>
Return values
array<int, mixed> —the elements, in order
offsetExists()
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
-
the element index
Return values
bool —whether that index exists
offsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
-
the element index
Tags
Return values
mixed —the element at that index
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : never
Parameters
- $offset : mixed
-
ignored
- $value : mixed
-
ignored
Tags
Return values
neveroffsetUnset()
public
offsetUnset(mixed $offset) : never
Parameters
- $offset : mixed
-
ignored
Tags
Return values
nevertoArray()
The tuple's elements as a plain list.
public
toArray() : array<int, mixed>
Return values
array<int, mixed> —the elements, in order