Add nested enum descriptor in php rumtime. (#3009)

This commit is contained in:
Paul Yang 2017-04-24 12:40:37 -07:00 committed by GitHub
parent e64b618b21
commit fba2acd72e
3 changed files with 11 additions and 1 deletions

View File

@ -95,6 +95,9 @@ class DescriptorPool
foreach ($descriptor->getNestedType() as $nested_type) {
$this->addDescriptor($nested_type);
}
foreach ($descriptor->getEnumType() as $enum_type) {
$this->addEnumDescriptor($enum_type);
}
}
public function addEnumDescriptor($descriptor)

View File

@ -210,6 +210,12 @@ class Descriptor
$nested_proto, $file_proto, $message_name_without_package));
}
// Handle nested enum.
foreach ($proto->getEnumType() as $enum_proto) {
$desc->addEnumType(EnumDescriptor::buildFromProto(
$enum_proto, $file_proto, $message_name_without_package));
}
// Handle oneof fields.
foreach ($proto->getOneofDecl() as $oneof_proto) {
$desc->addOneofDecl(

View File

@ -839,7 +839,8 @@ class GeneratedClassTest extends TestBase
public function testMessageWithoutNamespace()
{
$m = new TestMessage();
$m->setOptionalNoNamespaceMessage(new NoNameSpaceMessage());
$sub = new NoNameSpaceMessage();
$m->setOptionalNoNamespaceMessage($sub);
$m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage();
$n = new NoNamespaceMessage();