/** * @param \google\protobuf\FieldDescriptorProto $field * * @return string */ protected function getDoctype(FieldDescriptorProto $field) { $fieldType = $field->getType()->value(); $phpType = Field::getPhpType($fieldType); $refTypes = [Type::TYPE_ENUM_VALUE => true, Type::TYPE_MESSAGE_VALUE => true]; if (isset($refTypes[$fieldType])) { $typeName = $field->getTypeName(); $refEntity = $this->getEntity($typeName); return $refEntity->getNamespacedName(); } return $phpType ?: 'mixed'; }
/** * @dataProvider phpTypeProvider */ public function testGetPhpType($type, $expected) { $this->assertEquals($expected, Field::getPhpType($type)); }