Commit fba2acd7 authored by Paul Yang's avatar Paul Yang Committed by GitHub

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

parent e64b618b
...@@ -95,6 +95,9 @@ class DescriptorPool ...@@ -95,6 +95,9 @@ class DescriptorPool
foreach ($descriptor->getNestedType() as $nested_type) { foreach ($descriptor->getNestedType() as $nested_type) {
$this->addDescriptor($nested_type); $this->addDescriptor($nested_type);
} }
foreach ($descriptor->getEnumType() as $enum_type) {
$this->addEnumDescriptor($enum_type);
}
} }
public function addEnumDescriptor($descriptor) public function addEnumDescriptor($descriptor)
......
...@@ -210,6 +210,12 @@ class Descriptor ...@@ -210,6 +210,12 @@ class Descriptor
$nested_proto, $file_proto, $message_name_without_package)); $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. // Handle oneof fields.
foreach ($proto->getOneofDecl() as $oneof_proto) { foreach ($proto->getOneofDecl() as $oneof_proto) {
$desc->addOneofDecl( $desc->addOneofDecl(
......
...@@ -839,7 +839,8 @@ class GeneratedClassTest extends TestBase ...@@ -839,7 +839,8 @@ class GeneratedClassTest extends TestBase
public function testMessageWithoutNamespace() public function testMessageWithoutNamespace()
{ {
$m = new TestMessage(); $m = new TestMessage();
$m->setOptionalNoNamespaceMessage(new NoNameSpaceMessage()); $sub = new NoNameSpaceMessage();
$m->setOptionalNoNamespaceMessage($sub);
$m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage(); $m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage();
$n = new NoNamespaceMessage(); $n = new NoNamespaceMessage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment