aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/EnumDescriptor.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/EnumDescriptor.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/EnumDescriptor.php')
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptor.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
index 33a55a4a..01649fec 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
@@ -2,13 +2,22 @@
namespace Google\Protobuf\Internal;
+use Google\Protobuf\EnumValueDescriptor;
+
class EnumDescriptor
{
+ use HasPublicDescriptorTrait;
private $klass;
private $full_name;
private $value;
private $name_to_value;
+ private $value_descriptor = [];
+
+ public function __construct()
+ {
+ $this->public_desc = new \Google\Protobuf\EnumDescriptor($this);
+ }
public function setFullName($full_name)
{
@@ -24,6 +33,7 @@ class EnumDescriptor
{
$this->value[$number] = $value;
$this->name_to_value[$value->getName()] = $value;
+ $this->value_descriptor[] = new EnumValueDescriptor($value->getName(), $number);
}
public function getValueByNumber($number)
@@ -36,6 +46,16 @@ class EnumDescriptor
return $this->name_to_value[$name];
}
+ public function getValueDescriptorByIndex($index)
+ {
+ return $this->value_descriptor[$index];
+ }
+
+ public function getValueCount()
+ {
+ return count($this->value);
+ }
+
public function setClass($klass)
{
$this->klass = $klass;