aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src/Google/Protobuf/Internal/OneofDescriptor.php
diff options
context:
space:
mode:
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 57961f39..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(Descriptor $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;
}
}