Skip to content

Commit

Permalink
Add nested enum descriptor in php rumtime. (#3009)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeBoring authored Apr 24, 2017
1 parent e64b618 commit fba2acd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions php/src/Google/Protobuf/Internal/DescriptorPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function addDescriptor($descriptor)
foreach ($descriptor->getNestedType() as $nested_type) {
$this->addDescriptor($nested_type);
}
foreach ($descriptor->getEnumType() as $enum_type) {
$this->addEnumDescriptor($enum_type);
}
}

public function addEnumDescriptor($descriptor)
Expand Down
6 changes: 6 additions & 0 deletions php/src/Google/Protobuf/descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ public static function buildFromProto($proto, $file_proto, $containing)
$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(
Expand Down
3 changes: 2 additions & 1 deletion php/tests/generated_class_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ public function testMessageMergeFromInvalidTypeFail()
public function testMessageWithoutNamespace()
{
$m = new TestMessage();
$m->setOptionalNoNamespaceMessage(new NoNameSpaceMessage());
$sub = new NoNameSpaceMessage();
$m->setOptionalNoNamespaceMessage($sub);
$m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage();

$n = new NoNamespaceMessage();
Expand Down

0 comments on commit fba2acd

Please sign in to comment.