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/Descriptor.php | 100 +++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 php/src/Google/Protobuf/Descriptor.php (limited to 'php/src/Google/Protobuf/Descriptor.php') diff --git a/php/src/Google/Protobuf/Descriptor.php b/php/src/Google/Protobuf/Descriptor.php new file mode 100644 index 00000000..986b81e1 --- /dev/null +++ b/php/src/Google/Protobuf/Descriptor.php @@ -0,0 +1,100 @@ +internal_desc = $internal_desc; + } + + /** + * @return string Full protobuf message name + */ + public function getFullName() + { + return trim($this->internal_desc->getFullName(), "."); + } + + /** + * @return string PHP class name + */ + public function getClass() + { + return $this->internal_desc->getClass(); + } + + /** + * @param int $index Must be >= 0 and < getFieldCount() + * @return FieldDescriptor + */ + public function getField($index) + { + return $this->getPublicDescriptor($this->internal_desc->getFieldByIndex($index)); + } + + /** + * @return int Number of fields in message + */ + public function getFieldCount() + { + return count($this->internal_desc->getField()); + } + + /** + * @param int $index Must be >= 0 and < getOneofDeclCount() + * @return OneofDescriptor + */ + public function getOneofDecl($index) + { + return $this->getPublicDescriptor($this->internal_desc->getOneofDecl()[$index]); + } + + /** + * @return int Number of oneofs in message + */ + public function getOneofDeclCount() + { + return count($this->internal_desc->getOneofDecl()); + } +} -- cgit v1.2.3