function MapField::__construct
Constructs an instance of MapField.
@ignore
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).
File
-
vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ MapField.php, line 55
Class
- MapField
- MapField is used by generated protocol message classes to manipulate map fields. It can be used like native PHP array.
Namespace
Google\Protobuf\InternalCode
public function __construct($key_type, $value_type, $klass = null) {
$this->container = [];
$this->key_type = $key_type;
$this->value_type = $value_type;
$this->klass = $klass;
if ($this->value_type == GPBType::MESSAGE) {
$pool = DescriptorPool::getGeneratedPool();
$desc = $pool->getDescriptorByClassName($klass);
if ($desc == NULL) {
new $klass();
// No msg class instance has been created before.
$desc = $pool->getDescriptorByClassName($klass);
}
$this->klass = $desc->getClass();
$this->legacy_klass = $desc->getLegacyClass();
}
}