From 21b0e5587c01948927ede9be789671ff116b7ad4 Mon Sep 17 00:00:00 2001 From: michaelbausor Date: Fri, 4 Aug 2017 16:35:22 -0700 Subject: 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 --- php/src/Google/Protobuf/Internal/EnumDescriptor.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'php/src/Google/Protobuf/Internal/EnumDescriptor.php') 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; -- cgit v1.2.3