diff options
author | michaelbausor <michaelbausor@google.com> | 2017-08-04 16:35:22 -0700 |
---|---|---|
committer | Paul Yang <TeBoring@users.noreply.github.com> | 2017-08-04 16:35:22 -0700 |
commit | 21b0e5587c01948927ede9be789671ff116b7ad4 (patch) | |
tree | 8bb156c68677804739e65c3b4ee6cd9f891797f2 /php/src/Google/Protobuf/Internal/EnumDescriptor.php | |
parent | 1ab5adbdec4d6487c8e6f230138092d27d6a0818 (diff) | |
download | protobuf-21b0e5587c01948927ede9be789671ff116b7ad4.tar.gz protobuf-21b0e5587c01948927ede9be789671ff116b7ad4.tar.bz2 protobuf-21b0e5587c01948927ede9be789671ff116b7ad4.zip |
Update PHP descriptors (#3391)
* Add descriptors test
* Update descriptors tests
* Add public descriptors
* Add test_desriptors.proto to test script
* Update composer files
* Remove references to GPBType, update tests to be compatible with c
* Update for c extension compatibility
* Remove nested enums for descriptor, update tests
* Strip leading '.' from descriptor name
* Update tests with test for getClass, fix OneofDescriptor
* Add new files to Makefile.am
Diffstat (limited to 'php/src/Google/Protobuf/Internal/EnumDescriptor.php')
-rw-r--r-- | php/src/Google/Protobuf/Internal/EnumDescriptor.php | 20 |
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; |