aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/OneofDescriptor.php
diff options
context:
space:
mode:
authorBo Yang <paulyang1211@gmail.com>2017-08-05 10:42:29 -0700
committerBo Yang <paulyang1211@gmail.com>2017-08-05 10:42:29 -0700
commit8f4b8e430a0cf087af423be434cf8d837027c651 (patch)
treea7a79a2ff33b31b9036eb378eb458928a0648481 /php/src/Google/Protobuf/Internal/OneofDescriptor.php
parentc2f69d6fa23a815948368fae0b8c1e56e50715c9 (diff)
parentf14703c933d04a4aac285c482bf828269bd0a151 (diff)
downloadprotobuf-8f4b8e430a0cf087af423be434cf8d837027c651.tar.gz
protobuf-8f4b8e430a0cf087af423be434cf8d837027c651.tar.bz2
protobuf-8f4b8e430a0cf087af423be434cf8d837027c651.zip
Merge branch 'master' into 3.4.x
Diffstat (limited to 'php/src/Google/Protobuf/Internal/OneofDescriptor.php')
-rw-r--r--php/src/Google/Protobuf/Internal/OneofDescriptor.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptor.php b/php/src/Google/Protobuf/Internal/OneofDescriptor.php
index 04988737..67b107f6 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptor.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptor.php
@@ -34,10 +34,16 @@ namespace Google\Protobuf\Internal;
class OneofDescriptor
{
+ use HasPublicDescriptorTrait;
private $name;
private $fields;
+ public function __construct()
+ {
+ $this->public_desc = new \Google\Protobuf\OneofDescriptor($this);
+ }
+
public function setName($name)
{
$this->name = $name;
@@ -48,7 +54,7 @@ class OneofDescriptor
return $this->name;
}
- public function addField(&$field)
+ public function addField(FieldDescriptor $field)
{
$this->fields[] = $field;
}
@@ -58,10 +64,15 @@ class OneofDescriptor
return $this->fields;
}
- public static function buildFromProto($oneof_proto)
+ public static function buildFromProto($oneof_proto, $desc, $index)
{
$oneof = new OneofDescriptor();
$oneof->setName($oneof_proto->getName());
+ foreach ($desc->getField() as $field) {
+ if ($field->getOneofIndex() == $index) {
+ $oneof->addField($field);
+ }
+ }
return $oneof;
}
}