function MapEntry::__construct
Overrides Message::__construct
File
-
vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ MapEntry.php, line 20
Class
Namespace
Google\Protobuf\InternalCode
public function __construct($desc) {
parent::__construct($desc);
// For MapEntry, getValue should always return a valid value. Thus, we
// need to create a default instance value if the value type is
// message, in case no value is provided in data.
$value_field = $desc->getFieldByNumber(2);
if ($value_field->getType() == GPBType::MESSAGE) {
$klass = $value_field->getMessageType()
->getClass();
$value = new $klass();
$this->setValue($value);
}
}