class RepeatedField implements ArrayAccess, IteratorAggregate, Countable (View source)

RepeatedField is used by generated protocol message classes to manipulate repeated fields. It can be used like native PHP array.

Methods

__construct(int $type, string $klass = null)

Constructs an instance of RepeatedField.

getType()

No description

getClass()

No description

getLegacyClass()

No description

mixed
offsetGet(int $offset)

Return the element at the given index.

void
offsetSet(int|null $offset, mixed $value)

Assign the element at the given index.

void
offsetUnset(int $offset)

Remove the element at the given index.

bool
offsetExists(int $offset)

Check the existence of the element at the given index.

getIterator()

No description

int
count()

Return the number of stored elements.

Details

__construct(int $type, string $klass = null)

Constructs an instance of RepeatedField.

Parameters

int $type

Type of the stored element.

string $klass

Message/Enum class name (message/enum fields only).

getType()

No description

getClass()

No description

getLegacyClass()

No description

mixed offsetGet(int $offset)

Return the element at the given index.

This will also be called for: $ele = $arr[0]

need to add return type mixed (require update php version to 8.0)

Parameters

int $offset

The index of the element to be fetched.

Return Value

mixed

The stored element at given index.

Exceptions

ErrorException
ErrorException

void offsetSet(int|null $offset, mixed $value)

Assign the element at the given index.

This will also be called for: $arr []= $ele and $arr[0] = ele

need to add return type void (require update php version to 7.1)

Parameters

int|null $offset

The index of the element to be assigned.

mixed $value

The element to be assigned.

Return Value

void

Exceptions

ErrorException
ErrorException
ErrorException

void offsetUnset(int $offset)

Remove the element at the given index.

This will also be called for: unset($arr)

need to add return type void (require update php version to 7.1)

Parameters

int $offset

The index of the element to be removed.

Return Value

void

Exceptions

ErrorException
ErrorException

bool offsetExists(int $offset)

Check the existence of the element at the given index.

This will also be called for: isset($arr)

Parameters

int $offset

The index of the element to be removed.

Return Value

bool

True if the element at the given offset exists.

Exceptions

ErrorException

Traversable getIterator()

No description

Return Value

Traversable

int count()

Return the number of stored elements.

This will also be called for: count($arr)

Return Value

int

The number of stored elements.