本文整理汇总了PHP中google\protobuf\FieldDescriptorProto\Label类的典型用法代码示例。如果您正苦于以下问题:PHP Label类的具体用法?PHP Label怎么用?PHP Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testComplexMessageDescriptor
public function testComplexMessageDescriptor()
{
$descriptor = AddressBook::descriptor();
$this->assertInstanceOf(DescriptorProto::CLASS, $descriptor);
$this->assertEquals('AddressBook', $descriptor->getName());
$this->assertCount(1, $descriptor->getFieldList());
$this->assertInstanceOf(FieldDescriptorProto::CLASS, $descriptor->getFieldList()[0]);
$this->assertEquals(1, $descriptor->getFieldList()[0]->getNumber());
$this->assertEquals('person', $descriptor->getFieldList()[0]->getName());
$this->assertSame(Type::TYPE_MESSAGE(), $descriptor->getFieldList()[0]->getType());
$this->assertSame(Label::LABEL_REPEATED(), $descriptor->getFieldList()[0]->getLabel());
$this->assertEquals('.ProtobufCompilerTest.Protos.Person', $descriptor->getFieldList()[0]->getTypeName());
}
示例2: generateRequiredFieldException
/**
* @param \Protobuf\Compiler\Entity $entity
* @param \google\protobuf\FieldDescriptorProto $field
*
* @return string[]
*/
protected function generateRequiredFieldException(Entity $entity, FieldDescriptorProto $field)
{
$name = $field->getName();
$label = $field->getLabel();
$tag = $field->getNumber();
$isRequired = $label === Label::LABEL_REQUIRED();
if (!$isRequired) {
return [];
}
$class = $entity->getNamespacedName();
$format = 'Field "%s#%s" (tag %s) is required but has no value.';
$message = var_export(sprintf($format, $class, $name, $tag), true);
$body[] = 'if ($this->' . $name . ' === null) {';
$body[] = ' throw new \\UnexpectedValueException(' . $message . ');';
$body[] = '}';
$body[] = null;
return $body;
}
示例3: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'UseIncenseMessage', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'incense_type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Inventory.Item.ItemId'])]]);
}
示例4: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'FortDetailsResponse', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'fort_id', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'team_color', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Enums.TeamColor']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 3, 'name' => 'pokemon_data', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Data.PokemonData']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 4, 'name' => 'name', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 5, 'name' => 'image_urls', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 6, 'name' => 'fp', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 7, 'name' => 'stamina', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 8, 'name' => 'max_stamina', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 9, 'name' => 'type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Map.Fort.FortType']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 10, 'name' => 'latitude', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_DOUBLE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 11, 'name' => 'longitude', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_DOUBLE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 12, 'name' => 'description', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 13, 'name' => 'modifiers', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.POGOProtos.Map.Fort.FortModifier'])]]);
}
示例5: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'SfidaActionLogResponse', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'result', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Networking.Responses.SfidaActionLogResponse.Result']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'log_entries', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.POGOProtos.Data.Logs.ActionLogEntry'])]]);
}
示例6: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'CheckAwardedBadgesResponse', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'success', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_BOOL(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'awarded_badges', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.POGOProtos.Enums.BadgeType']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 3, 'name' => 'awarded_badge_levels', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED()])]]);
}
示例7: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'SourceCodeInfo', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'location', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.SourceCodeInfo.Location'])]]);
}
示例8: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'BattleResults', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'gym_state', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Data.Gym.GymState']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'attackers', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.POGOProtos.Data.Battle.BattleParticipant']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 3, 'name' => 'player_experience_awarded', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 4, 'name' => 'next_defender_pokemon_id', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT64(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 5, 'name' => 'gym_points_delta', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例9: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'ItemAward', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'item_id', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Inventory.Item.ItemId']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'item_count', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例10: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'DailyBonus', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'next_collected_timestamp_ms', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT64(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'next_defender_bonus_collect_timestamp_ms', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT64(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例11: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'DescriptorProto', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'name', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'field', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.FieldDescriptorProto']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 6, 'name' => 'extension', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.FieldDescriptorProto']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 3, 'name' => 'nested_type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.DescriptorProto']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 4, 'name' => 'enum_type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.EnumDescriptorProto']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 5, 'name' => 'extension_range', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.DescriptorProto.ExtensionRange']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 8, 'name' => 'oneof_decl', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.OneofDescriptorProto']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 7, 'name' => 'options', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.google.protobuf.MessageOptions']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 9, 'name' => 'reserved_range', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_MESSAGE(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED(), 'type_name' => '.google.protobuf.DescriptorProto.ReservedRange']), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 10, 'name' => 'reserved_name', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED()])]]);
}
示例12: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'BattleAttributes', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'sta_percent', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例13: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'RegisterBackgroundDeviceMessage', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'device_type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'device_id', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_STRING(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例14: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'GymBattleSettings', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'energy_per_sec', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'dodge_energy_cost', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 3, 'name' => 'retarget_seconds', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 4, 'name' => 'enemy_attack_interval', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 5, 'name' => 'attack_server_interval', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 6, 'name' => 'round_duration_seconds', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 7, 'name' => 'bonus_time_per_ally_seconds', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 8, 'name' => 'maximum_attackers_per_battle', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 9, 'name' => 'same_type_attack_bonus_multiplier', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 10, 'name' => 'maximum_energy', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 11, 'name' => 'energy_delta_per_health_lost', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 12, 'name' => 'dodge_duration_ms', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 13, 'name' => 'minimum_player_level', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 14, 'name' => 'swap_duration_ms', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 15, 'name' => 'dodge_damage_reduction_percent', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()])]]);
}
示例15: descriptor
/**
* {@inheritdoc}
*/
public static function descriptor()
{
return \google\protobuf\DescriptorProto::fromArray(['name' => 'InventoryUpgradeAttributes', 'field' => [\google\protobuf\FieldDescriptorProto::fromArray(['number' => 1, 'name' => 'additional_storage', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()]), \google\protobuf\FieldDescriptorProto::fromArray(['number' => 2, 'name' => 'upgrade_type', 'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_ENUM(), 'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL(), 'type_name' => '.POGOProtos.Inventory.InventoryUpgradeType'])]]);
}