aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorPool.php3
-rw-r--r--php/src/Google/Protobuf/descriptor.php6
-rw-r--r--php/tests/generated_class_test.php3
3 files changed, 11 insertions, 1 deletions
diff --git a/php/src/Google/Protobuf/Internal/DescriptorPool.php b/php/src/Google/Protobuf/Internal/DescriptorPool.php
index 1ef403cf..2c00dfb6 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorPool.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorPool.php
@@ -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)
diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php
index 9c744a8a..fb69eda0 100644
--- a/php/src/Google/Protobuf/descriptor.php
+++ b/php/src/Google/Protobuf/descriptor.php
@@ -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(
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index 554d2bea..21ee8490 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -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();