function MapFieldIter::key
Return the current key.
@todo need to add return type mixed (require update php version to 8.0)
Return value
object The current key.
File
-
vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ MapFieldIter.php, line 77
Class
- MapFieldIter
- MapFieldIter is used to iterate MapField. It is also need for the foreach syntax.
Namespace
Google\Protobuf\InternalCode
public function key() {
$key = key($this->container);
switch ($this->key_type) {
case GPBType::INT64:
case GPBType::UINT64:
case GPBType::FIXED64:
case GPBType::SFIXED64:
case GPBType::SINT64:
if (PHP_INT_SIZE === 8) {
return $key;
}
// Intentionally fall through
case GPBType::STRING:
// PHP associative array stores int string as int for key.
return strval($key);
case GPBType::BOOL:
// PHP associative array stores bool as integer for key.
return boolval($key);
default:
return $key;
}
}