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

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

Methods

__construct(long $key_type, long $value_type, string $klass = null)

Constructs an instance of MapField.

getKeyType()

No description

getValueType()

No description

getValueClass()

No description

getLegacyValueClass()

No description

object
offsetGet(int|string $key)

Return the element at the given key.

void
offsetSet(int|string $key, object $value)

Assign the element at the given key.

void
offsetUnset(int|string $key)

Remove the element at the given key.

bool
offsetExists(int|string $key)

Check the existence of the element at the given key.

getIterator()

No description

int
count()

Return the number of stored elements.

Details

__construct(long $key_type, long $value_type, string $klass = null)

Constructs an instance of MapField.

Parameters

long $key_type

Type of the stored key element.

long $value_type

Type of the stored value element.

string $klass

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

getKeyType()

No description

getValueType()

No description

getValueClass()

No description

getLegacyValueClass()

No description

object offsetGet(int|string $key)

Return the element at the given key.

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

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

Parameters

int|string $key

The key of the element to be fetched.

Return Value

object

The stored element at given key.

Exceptions

ErrorException
ErrorException

void offsetSet(int|string $key, object $value)

Assign the element at the given key.

This will also be called for: $arr[$key] = $value

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

Parameters

int|string $key

The key of the element to be fetched.

object $value

The element to be assigned.

Return Value

void

Exceptions

ErrorException
ErrorException
ErrorException

void offsetUnset(int|string $key)

Remove the element at the given key.

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

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

Parameters

int|string $key

The key of the element to be removed.

Return Value

void

Exceptions

ErrorException

bool offsetExists(int|string $key)

Check the existence of the element at the given key.

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

Parameters

int|string $key

The key of the element to be removed.

Return Value

bool

True if the element at the given key 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.