本文整理汇总了PHP中Google\Protobuf\FieldDescriptorProto::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldDescriptorProto::setName方法的具体用法?PHP FieldDescriptorProto::setName怎么用?PHP FieldDescriptorProto::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google\Protobuf\FieldDescriptorProto
的用法示例。
在下文中一共展示了FieldDescriptorProto::setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFieldDescriptorProto
/**
* @param integer $number
* @param string $name
* @param integer $type
* @param integer $label
* @param string $typeName
* @param array $values
*
* @return \google\protobuf\FieldDescriptorProto
*/
protected function createFieldDescriptorProto($number, $name, $type, $label, $typeName = null, array $values = [])
{
$field = new FieldDescriptorProto();
$options = isset($values['options']) ? $values['options'] : null;
$field->setName($name);
$field->setNumber($number);
$field->setTypeName($typeName);
$field->setType(FieldDescriptorProto\Type::valueOf($type));
$field->setLabel(FieldDescriptorProto\Label::valueOf($label));
if (isset($values['default'])) {
$field->setDefaultValue($values['default']);
}
if ($options !== null) {
$fieldOptions = new FieldOptions();
if (isset($options['packed'])) {
$fieldOptions->setPacked($options['packed']);
}
$field->setOptions($fieldOptions);
}
return $field;
}
示例2: compileExtension
protected function compileExtension(proto\FieldDescriptorProto $field, $ns, $indent)
{
$extendee = $this->normalizeNS($field->getExtendee());
$name = $this->normalizeNS($ns . '.' . $field->getName());
$field->setName($name);
$s[] = "\\{$extendee}::extension(function(){";
$s[] = $this->compileField($field, $ns, $indent . ' ');
$s[] = ' // @@protoc_insertion_point(scope_extension)';
$s[] = ' // @@protoc_insertion_point(extension_' . $ns . ':' . $field->getName() . ')';
$s[] = ' return $f;';
$s[] = "});";
return $indent . implode(PHP_EOL . $indent, $s);
}
示例3: compileExtension
public function compileExtension(proto\FieldDescriptorProto $field, $ns, $indent)
{
$extendee = $this->normalizeReference($field->getExtendee());
$name = $field->getName();
if ($ns) {
$name = $ns . '.' . $name;
}
$field->setName($name);
$s[] = "ProtoJson.extend({$extendee}, {";
$s[] = " {$field->number}: " . $this->generateField($field);
$s[] = "});";
$s[] = '';
return $indent . implode("\n{$indent}", $s);
}