aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf/Internal/EnumDescriptor.php
diff options
context:
space:
mode:
authorJisi Liu <liujisi@google.com>2017-08-07 11:47:29 -0700
committerGitHub <noreply@github.com>2017-08-07 11:47:29 -0700
commit3afcded28a6aa9c44adf801ca5bff2133fcf3030 (patch)
treecebd73fdf090a98c32ad1a1c996af9cc8f1f8ad6 /php/src/Google/Protobuf/Internal/EnumDescriptor.php
parent176713d6fbbf72056b009f76e7625f267273bd75 (diff)
parent8f4b8e430a0cf087af423be434cf8d837027c651 (diff)
downloadprotobuf-3afcded28a6aa9c44adf801ca5bff2133fcf3030.tar.gz
protobuf-3afcded28a6aa9c44adf801ca5bff2133fcf3030.tar.bz2
protobuf-3afcded28a6aa9c44adf801ca5bff2133fcf3030.zip
Merge pull request #3461 from TeBoring/3.4.xv3.4.0rc1
Merge 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;