示例#1
0
 /**
  * @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;
 }