function Message::defaultValue
@ignore
6 calls to Message::defaultValue()
- Message::convertJsonValueToProtoValue in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - Message::existField in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - @ignore
- Message::fieldByteSize in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - @ignore
- Message::initWithDescriptor in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - @ignore
- Message::mergeFrom in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - Merges the contents of the specified message into current message.
File
-
vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php, line 245
Class
- Message
- Parent class of all proto messages. Users should not instantiate this class or extend this class or its child classes by their own. See the comment of specific functions for more details.
Namespace
Google\Protobuf\InternalCode
private function defaultValue($field) {
$value = null;
switch ($field->getType()) {
case GPBType::DOUBLE:
case GPBType::FLOAT:
return 0.0;
case GPBType::UINT32:
case GPBType::INT32:
case GPBType::FIXED32:
case GPBType::SFIXED32:
case GPBType::SINT32:
case GPBType::ENUM:
return 0;
case GPBType::INT64:
case GPBType::UINT64:
case GPBType::FIXED64:
case GPBType::SFIXED64:
case GPBType::SINT64:
if (PHP_INT_SIZE === 4) {
return '0';
}
else {
return 0;
}
case GPBType::BOOL:
return false;
case GPBType::STRING:
case GPBType::BYTES:
return "";
case GPBType::GROUP:
case GPBType::MESSAGE:
return null;
default:
user_error("Unsupported type.");
return false;
}
}