Copied!

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

CloneableInstantiableIterable
  • Implements
    ArrayAccess
    Countable
    IteratorAggregate
    Traversable
Methods
public __construct( $key_type, $value_type, $klass = NULL)
 

Constructs an instance of MapField.

  • param \long $key_type Type of the stored key element.
  • param \long $value_type Type of the stored value element.
  • param string $klass Message/Enum class name of value instance (message/enum fields only).
  • ignore
public count() : int
 

Return the number of stored elements.

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

  • return int The number of stored elements.
public getIterator() : Traversable
 
  • ignore
public getKeyType()
 
  • ignore
public getLegacyValueClass()
 
  • ignore
public getValueClass()
 
  • ignore
public getValueType()
 
  • ignore
public offsetExists( $key) : bool
 

Check the existence of the element at the given key.

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

  • param int|string $key The key of the element to be removed.
  • return bool True if the element at the given key exists.
  • throws \ErrorException Invalid type for key.
public offsetGet( $key)
 

Return the element at the given key.

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

  • param int|string $key The key of the element to be fetched.
  • return object The stored element at given key.
  • throws \ErrorException Invalid type for index.
  • throws \ErrorException Non-existing index.
  • todo need to add return type mixed (require update php version to 8.0)
  • attribute ReturnTypeWillChange
public offsetSet( $key, $value)
 

Assign the element at the given key.

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

  • param int|string $key The key of the element to be fetched.
  • param object $value The element to be assigned.
  • return void
  • throws \ErrorException Invalid type for key.
  • throws \ErrorException Invalid type for value.
  • throws \ErrorException Non-existing key.
  • todo need to add return type void (require update php version to 7.1)
  • attribute ReturnTypeWillChange
public offsetUnset( $key)
 

Remove the element at the given key.

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

  • param int|string $key The key of the element to be removed.
  • return void
  • throws \ErrorException Invalid type for key.
  • todo need to add return type void (require update php version to 7.1)
  • attribute ReturnTypeWillChange
Properties
private $container = NULL
 
  • ignore
private $key_type = NULL
 
  • ignore
private $klass = NULL
 
  • ignore
private $legacy_klass = NULL
 
  • ignore
private $value_type = NULL
 
  • ignore
Methods
private checkKey( $key_type, $key)
 
  • ignore
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration