/**
  * {@inheritdoc}
  */
 public function readFrom(\Protobuf\ReadContext $context)
 {
     $reader = $context->getReader();
     $length = $context->getLength();
     $stream = $context->getStream();
     $limit = $length !== null ? $stream->tell() + $length : null;
     while ($limit === null || $stream->tell() < $limit) {
         if ($stream->eof()) {
             break;
         }
         $key = $reader->readVarint($stream);
         $wire = \Protobuf\WireFormat::getTagWireType($key);
         $tag = \Protobuf\WireFormat::getTagFieldNumber($key);
         if ($stream->eof()) {
             break;
         }
         if ($tag === 1) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->name = $reader->readString($stream);
             continue;
         }
         if ($tag === 3) {
             \Protobuf\WireFormat::assertWireType($wire, 5);
             $this->number = $reader->readVarint($stream);
             continue;
         }
         if ($tag === 4) {
             \Protobuf\WireFormat::assertWireType($wire, 14);
             $this->label = \google\protobuf\FieldDescriptorProto\Label::valueOf($reader->readVarint($stream));
             continue;
         }
         if ($tag === 5) {
             \Protobuf\WireFormat::assertWireType($wire, 14);
             $this->type = \google\protobuf\FieldDescriptorProto\Type::valueOf($reader->readVarint($stream));
             continue;
         }
         if ($tag === 6) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->type_name = $reader->readString($stream);
             continue;
         }
         if ($tag === 2) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->extendee = $reader->readString($stream);
             continue;
         }
         if ($tag === 7) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->default_value = $reader->readString($stream);
             continue;
         }
         if ($tag === 9) {
             \Protobuf\WireFormat::assertWireType($wire, 5);
             $this->oneof_index = $reader->readVarint($stream);
             continue;
         }
         if ($tag === 10) {
             \Protobuf\WireFormat::assertWireType($wire, 9);
             $this->json_name = $reader->readString($stream);
             continue;
         }
         if ($tag === 8) {
             \Protobuf\WireFormat::assertWireType($wire, 11);
             $innerSize = $reader->readVarint($stream);
             $innerMessage = new \google\protobuf\FieldOptions();
             $this->options = $innerMessage;
             $context->setLength($innerSize);
             $innerMessage->readFrom($context);
             $context->setLength($length);
             continue;
         }
         $extensions = $context->getExtensionRegistry();
         $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;
         if ($extension !== null) {
             $this->extensions()->add($extension, $extension->readFrom($context, $wire));
             continue;
         }
         if ($this->unknownFieldSet === null) {
             $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
         }
         $data = $reader->readUnknown($stream, $wire);
         $unknown = new \Protobuf\Unknown($tag, $wire, $data);
         $this->unknownFieldSet->add($unknown);
     }
 }
 /**
  * @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;
 }