LICENSE000064400000002754146412221520005560 0ustar00BSD 3-Clause License Copyright (c) 2019, Protocol Buffers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. README.md000064400000000571146412221520006025 0ustar00# protobuf-php This repository contains only PHP files to support Composer installation. This repository is a mirror of [protobuf](https://github.com/protocolbuffers/protobuf). Any support requests, bug reports, or development contributions should be directed to that project. To install protobuf for PHP, please see https://github.com/protocolbuffers/protobuf/tree/master/php composer.json000064400000001051146412221520007262 0ustar00{ "name": "google/protobuf", "type": "library", "description": "proto library for PHP", "keywords": ["proto"], "homepage": "https://developers.google.com/protocol-buffers/", "license": "BSD-3-Clause", "require": { "php": ">=5.5.0" }, "require-dev": { "phpunit/phpunit": ">=4.8.0" }, "autoload": { "psr-4": { "Google\\": "src/Google" }, "files": [ "src/Google/Protobuf/descriptor.php", "src/Google/Protobuf/descriptor_internal.pb.php", "src/Google/Protobuf/Internal/Type.php" ] } } src/Google/Protobuf/Internal/DescriptorPool.php000064400000012367146412221520015614 0ustar00decode($data); $file = FileDescriptor::buildFromProto($files->getFile()[0]); foreach ($file->getMessageType() as &$desc) { $this->addDescriptor($desc); } unset($desc); foreach ($file->getEnumType() as &$desc) { $this->addEnumDescriptor($desc); } unset($desc); foreach ($file->getMessageType() as &$desc) { $this->crossLink($desc); } unset($desc); } public function addMessage($name, $klass) { return new MessageBuilderContext($name, $klass, $this); } public function addEnum($name, $klass) { return new EnumBuilderContext($name, $klass, $this); } public function addDescriptor($descriptor) { $this->proto_to_class[$descriptor->getFullName()] = $descriptor->getClass(); $this->class_to_desc[$descriptor->getClass()] = $descriptor; foreach ($descriptor->getNestedType() as $nested_type) { $this->addDescriptor($nested_type); } } public function addEnumDescriptor($descriptor) { $this->proto_to_class[$descriptor->getFullName()] = $descriptor->getClass(); $this->class_to_enum_desc[$descriptor->getClass()] = $descriptor; } public function getDescriptorByClassName($klass) { return $this->class_to_desc[$klass]; } public function getEnumDescriptorByClassName($klass) { return $this->class_to_enum_desc[$klass]; } public function getDescriptorByProtoName($proto) { $klass = $this->proto_to_class[$proto]; return $this->class_to_desc[$klass]; } public function getEnumDescriptorByProtoName($proto) { $klass = $this->proto_to_class[$proto]; return $this->class_to_enum_desc[$klass]; } private function crossLink(&$desc) { foreach ($desc->getField() as &$field) { switch ($field->getType()) { case GPBType::MESSAGE: $proto = $field->getMessageType(); $field->setMessageType( $this->getDescriptorByProtoName($proto)); break; case GPBType::ENUM: $proto = $field->getEnumType(); $field->setEnumType( $this->getEnumDescriptorByProtoName($proto)); break; default: break; } } unset($field); foreach ($desc->getNestedType() as &$nested_type) { $this->crossLink($nested_type); } unset($nested_type); } public function finish() { foreach ($this->class_to_desc as $klass => &$desc) { $this->crossLink($desc); } unset($desc); } } src/Google/Protobuf/Internal/EnumBuilderContext.php000064400000004546146412221520016424 0ustar00descriptor = new EnumDescriptor(); $this->descriptor->setFullName($full_name); $this->descriptor->setClass($klass); $this->pool = $pool; } public function value($name, $number) { $value = new EnumValueDescriptor(); $this->descriptor->addValue($number, $value); return $this; } public function finalizeToPool() { $this->pool->addEnumDescriptor($this->descriptor); } } src/Google/Protobuf/Internal/GPBLabel.php000064400000003403146412221520014203 0ustar00> 31) & 0x1)) & ~0xFFFFFFFF); } } else { trigger_error("Expect integer.", E_USER_ERROR); } } public static function checkInt64(&$var) { if (is_numeric($var)) { $var = intval($var); } else { trigger_error("Expect integer.", E_USER_ERROR); } } public static function checkUint64(&$var) { if (is_numeric($var)) { $var = intval($var); } else { trigger_error("Expect integer.", E_USER_ERROR); } } public static function checkFloat(&$var) { if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { trigger_error("Expect float.", E_USER_ERROR); } } public static function checkDouble(&$var) { if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { trigger_error("Expect float.", E_USER_ERROR); } } public static function checkBool(&$var) { if (is_array($var) || is_object($var)) { trigger_error("Expect boolean.", E_USER_ERROR); return; } $var = boolval($var); } public static function checkMessage(&$var, $klass) { if (!$var instanceof $klass && !is_null($var)) { trigger_error("Expect message.", E_USER_ERROR); } } public static function checkRepeatedField(&$var, $type, $klass = null) { if (!$var instanceof RepeatedField) { trigger_error("Expect repeated field.", E_USER_ERROR); } if ($var->getType() != $type) { trigger_error( "Expect repeated field of different type.", E_USER_ERROR); } if ($var->getType() === GPBType::MESSAGE && $var->getClass() !== $klass) { trigger_error( "Expect repeated field of different message.", E_USER_ERROR); } } public static function Int64($value) { return new Int64($value); } public static function Uint64($value) { return new Uint64($value); } } src/Google/Protobuf/Internal/GPBWire.php000064400000040445146412221520014101 0ustar00> self::TAG_TYPE_BITS) & (1 << ((PHP_INT_SIZE * 8) - self::TAG_TYPE_BITS)) - 1; } public static function getTagWireType($tag) { return $tag & 0x7; } public static function getWireType($type) { switch ($type) { case GPBType::FLOAT: case GPBType::FIXED32: case GPBType::SFIXED32: return self::WIRETYPE_FIXED32; case GPBType::DOUBLE: case GPBType::FIXED64: case GPBType::SFIXED64: return self::WIRETYPE_FIXED64; case GPBType::UINT32: case GPBType::UINT64: case GPBType::INT32: case GPBType::INT64: case GPBType::SINT32: case GPBType::SINT64: case GPBType::ENUM: case GPBType::BOOL: return self::WIRETYPE_VARINT; case GPBType::STRING: case GPBType::BYTES: case GPBType::MESSAGE: return self::WIRETYPE_LENGTH_DELIMITED; case GPBType::GROUP: user_error("Unsupported type."); return 0; default: user_error("Unsupported type."); return 0; } } // ZigZag Transform: Encodes signed integers so that they can be effectively // used with varint encoding. // // varint operates on unsigned integers, encoding smaller numbers into fewer // bytes. If you try to use it on a signed integer, it will treat this // number as a very large unsigned integer, which means that even small // signed numbers like -1 will take the maximum number of bytes (10) to // encode. zigZagEncode() maps signed integers to unsigned in such a way // that those with a small absolute value will have smaller encoded values, // making them appropriate for encoding using varint. // // int32 -> uint32 // ------------------------- // 0 -> 0 // -1 -> 1 // 1 -> 2 // -2 -> 3 // ... -> ... // 2147483647 -> 4294967294 // -2147483648 -> 4294967295 // // >> encode >> // << decode << public static function zigZagEncode32($int32) { // Fill high 32 bits. if (PHP_INT_SIZE === 8) { $int32 |= ((($int32 << 32) >> 31) & (0xFFFFFFFF << 32)); } $uint32 = ($int32 << 1) ^ ($int32 >> 31); // Fill high 32 bits. if (PHP_INT_SIZE === 8) { $uint32 |= ((($uint32 << 32) >> 31) & (0xFFFFFFFF << 32)); } return $uint32; } public static function zigZagDecode32($uint32) { // Fill high 32 bits. if (PHP_INT_SIZE === 8) { $uint32 |= ($uint32 & 0xFFFFFFFF); } $int32 = (($uint32 >> 1) & 0x7FFFFFFF) ^ (-($uint32 & 1)); return $int32; } public static function zigZagEncode64($int64) { $a = $int64->copy()->leftShift(1); $b = $int64->copy()->rightShift(63); $result = $a->bitXor($b); $uint64 = Uint64::newValue($result->high, $result->low); return $uint64; } public static function zigZagDecode64($uint64) { $a = $uint64->copy()->rightShift(1); $b = $uint64->oddMask(); $result = $a->bitXor($b); $int64 = Int64::newValue($result->high, $result->low); return $int64; } public static function readInt32(&$input, &$value) { return $input->readVarint32($value); } public static function readInt64(&$input, &$value) { return $input->readVarint64($value); } public static function readUint32(&$input, &$value) { return self::readInt32($input, $value); } public static function readUint64(&$input, &$value) { return self::readInt64($input, $value); } public static function readSint32(&$input, &$value) { if (!$input->readVarint32($value)) { return false; } $value = GPBWire::zigZagDecode32($value); return true; } public static function readSint64(&$input, &$value) { if (!$input->readVarint64($value)) { return false; } $value = GPBWire::zigZagDecode64($value); return true; } public static function readFixed32(&$input, &$value) { return $input->readLittleEndian32($value); } public static function readFixed64(&$input, &$value) { return $input->readLittleEndian64($value); } public static function readSfixed32(&$input, &$value) { if (!self::readFixed32($input, $value)) { return false; } if (PHP_INT_SIZE === 8) { $value |= (-($value >> 31) << 32); } return true; } public static function readSfixed64(&$input, &$value) { if (!self::readFixed64($input, $value)) { return false; } $value = Int64::newValue($value->high, $value->low); return true; } public static function readFloat(&$input, &$value) { $data = null; if (!$input->readRaw(4, $data)) { return false; } $value = unpack('f', $data)[1]; return true; } public static function readDouble(&$input, &$value) { $data = null; if (!$input->readRaw(8, $data)) { return false; } $value = unpack('d', $data)[1]; return true; } public static function readBool(&$input, &$value) { if (!$input->readVarint64($value)) { return false; } if ($value->high === 0 && $value->low === 0) { $value = false; } else { $value = true; } return true; } public static function readString(&$input, &$value) { $length = 0; return $input->readVarintSizeAsInt($length) && $input->readRaw($length, $value); } public static function readMessage(&$input, &$message) { $length = 0; if (!$input->readVarintSizeAsInt($length)) { return false; } $old_limit = 0; $recursion_limit = 0; $input->incrementRecursionDepthAndPushLimit( $length, $old_limit, $recursion_limit); if ($recursion_limit < 0 || !$message->parseFromStream($input)) { return false; } return $input->decrementRecursionDepthAndPopLimit($old_limit); } public static function writeTag(&$output, $tag) { return $output->writeTag($tag); } public static function writeInt32(&$output, $value) { return $output->writeVarint32($value); } public static function writeInt64(&$output, $value) { return $output->writeVarint64($value); } public static function writeUint32(&$output, $value) { return $output->writeVarint32($value); } public static function writeUint64(&$output, $value) { return $output->writeVarint64($value); } public static function writeSint32(&$output, $value) { $value = GPBWire::zigZagEncode32($value); return $output->writeVarint64($value); } public static function writeSint64(&$output, $value) { $value = GPBWire::zigZagEncode64(GPBUtil::Int64($value)); return $output->writeVarint64($value->toInteger()); } public static function writeFixed32(&$output, $value) { return $output->writeLittleEndian32($value); } public static function writeFixed64(&$output, $value) { return $output->writeLittleEndian64($value); } public static function writeSfixed32(&$output, $value) { return $output->writeLittleEndian32($value); } public static function writeSfixed64(&$output, $value) { return $output->writeLittleEndian64($value); } public static function writeBool(&$output, $value) { if ($value) { return $output->writeVarint32(1); } else { return $output->writeVarint32(0); } } public static function writeFloat(&$output, $value) { $data = pack("f", $value); return $output->writeRaw($data, 4); } public static function writeDouble(&$output, $value) { $data = pack("d", $value); return $output->writeRaw($data, 8); } public static function writeString(&$output, $value) { return self::writeBytes($output, $value); } public static function writeBytes(&$output, $value) { $size = strlen($value); if (!$output->writeVarint32($size)) { return false; } return $output->writeRaw($value, $size); } public static function writeMessage(&$output, $value) { $size = $value->byteSize(); if (!$output->writeVarint32($size)) { return false; } return $value->serializeToStream($output); } public static function makeTag($number, $type) { return ($number << 3) | self::getWireType($type); } public static function tagSize($field) { $tag = self::makeTag($field->getNumber(), $field->getType()); return self::varint32Size($tag); } public static function varint32Size($value) { if ($value < 0) { return 5; } if ($value < (1 << 7)) { return 1; } if ($value < (1 << 14)) { return 2; } if ($value < (1 << 21)) { return 3; } if ($value < (1 << 28)) { return 4; } return 5; } public static function sint32Size($value) { $value = self::zigZagEncode32($value); return self::varint32Size($value); } public static function sint64Size($value) { $value = GPBUtil::Int64($value); $value = self::zigZagEncode64($value); return self::varint64Size($value->toInteger()); } public static function varint64Size($value) { if ($value < 0) { return 10; } if ($value < (1 << 7)) { return 1; } if ($value < (1 << 14)) { return 2; } if ($value < (1 << 21)) { return 3; } if ($value < (1 << 28)) { return 4; } if ($value < (1 << 35)) { return 5; } if ($value < (1 << 42)) { return 6; } if ($value < (1 << 49)) { return 7; } if ($value < (1 << 56)) { return 8; } return 9; } public static function serializeFieldToStream( $value, $field, $need_tag, &$output) { if ($need_tag) { if (!GPBWire::writeTag( $output, self::makeTag( $field->getNumber(), $field->getType()))) { return false; } } switch ($field->getType()) { case GPBType::DOUBLE: if (!GPBWire::writeDouble($output, $value)) { return false; } break; case GPBType::FLOAT: if (!GPBWire::writeFloat($output, $value)) { return false; } break; case GPBType::INT64: if (!GPBWire::writeInt64($output, $value)) { return false; } break; case GPBType::UINT64: if (!GPBWire::writeUint64($output, $value)) { return false; } break; case GPBType::INT32: if (!GPBWire::writeInt32($output, $value)) { return false; } break; case GPBType::FIXED32: if (!GPBWire::writeFixed32($output, $value)) { return false; } break; case GPBType::FIXED64: if (!GPBWire::writeFixed64($output, $value)) { return false; } break; case GPBType::BOOL: if (!GPBWire::writeBool($output, $value)) { return false; } break; case GPBType::STRING: if (!GPBWire::writeString($output, $value)) { return false; } break; // case GPBType::GROUP: // echo "GROUP\xA"; // trigger_error("Not implemented.", E_ERROR); // break; case GPBType::MESSAGE: if (!GPBWire::writeMessage($output, $value)) { return false; } break; case GPBType::BYTES: if (!GPBWire::writeBytes($output, $value)) { return false; } break; case GPBType::UINT32: if (!GPBWire::writeUint32($output, $value)) { return false; } break; case GPBType::ENUM: if (!GPBWire::writeInt32($output, $value)) { return false; } break; case GPBType::SFIXED32: if (!GPBWire::writeSfixed32($output, $value)) { return false; } break; case GPBType::SFIXED64: if (!GPBWire::writeSfixed64($output, $value)) { return false; } break; case GPBType::SINT32: if (!GPBWire::writeSint32($output, $value)) { return false; } break; case GPBType::SINT64: if (!GPBWire::writeSint64($output, $value)) { return false; } break; default: user_error("Unsupported type."); return false; } return true; } } src/Google/Protobuf/Internal/InputStream.php000064400000024450146412221520015113 0ustar00buffer = $buffer; $this->buffer_size_after_limit = 0; $this->buffer_end = $end; $this->current = $start; $this->current_limit = $end; $this->legitimate_message_end = false; $this->recursion_budget = self::DEFAULT_RECURSION_LIMIT; $this->recursion_limit = self::DEFAULT_RECURSION_LIMIT; $this->total_bytes_limit = self::DEFAULT_TOTAL_BYTES_LIMIT; $this->total_bytes_read = $end - $start; } private function advance($amount) { $this->current += $amount; } private function bufferSize() { return $this->buffer_end - $this->current; } private function current() { return $this->total_bytes_read - ($this->buffer_end - $this->current + $this->buffer_size_after_limit); } private function recomputeBufferLimits() { $this->buffer_end += $this->buffer_size_after_limit; $closest_limit = min($this->current_limit, $this->total_bytes_limit); if ($closest_limit < $this->total_bytes_read) { // The limit position is in the current buffer. We must adjust the // buffer size accordingly. $this->buffer_size_after_limit = $this->total_bytes_read - $closest_limit; $this->buffer_end -= $this->buffer_size_after_limit; } else { $this->buffer_size_after_limit = 0; } } private function consumedEntireMessage() { return $this->legitimate_message_end; } /** * Read uint32 into $var. Advance buffer with consumed bytes. If the * contained varint is larger than 32 bits, discard the high order bits. * @param $var. */ public function readVarint32(&$var) { if (!$this->readVarint64($var)) { return false; } $var = $var->toInteger() & 0xFFFFFFFF; // Convert large uint32 to int32. if (PHP_INT_SIZE === 8 && ($var > 0x7FFFFFFF)) { $var = $var | (0xFFFFFFFF << 32); } return true; } /** * Read Uint64 into $var. Advance buffer with consumed bytes. * @param $var. */ public function readVarint64(&$var) { $result = new Uint64(0); $count = 0; $b = 0; do { if ($this->current === $this->buffer_end) { return false; } if ($count === self::MAX_VARINT_BYTES) { return false; } $b = ord($this->buffer[$this->current]); $result->bitOr((new Uint64($b & 0x7F))->leftShift(7 * $count)); $this->advance(1); $count += 1; } while ($b & 0x80); $var = $result; return true; } /** * Read int into $var. If the result is larger than the largest integer, $var * will be -1. Advance buffer with consumed bytes. * @param $var. */ public function readVarintSizeAsInt(&$var) { if (!$this->readVarint64($var)) { return false; } $var = $var->toInteger(); return true; } /** * Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes, * return false. Advance buffer with consumed bytes. * @param $var. */ public function readLittleEndian32(&$var) { $data = null; if (!$this->readRaw(4, $data)) { return false; } $var = unpack('V', $data); $var = $var[1]; return true; } /** * Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes, * return false. Advance buffer with consumed bytes. * @param $var. */ public function readLittleEndian64(&$var) { $data = null; if (!$this->readRaw(4, $data)) { return false; } $low = unpack('V', $data)[1]; if (!$this->readRaw(4, $data)) { return false; } $high = unpack('V', $data)[1]; $var = Uint64::newValue($high, $low); return true; } /** * Read tag into $var. Advance buffer with consumed bytes. * @param $var. */ public function readTag() { if ($this->current === $this->buffer_end) { // Make sure that it failed due to EOF, not because we hit // total_bytes_limit, which, unlike normal limits, is not a valid // place to end a message. $current_position = $this->total_bytes_read - $this->buffer_size_after_limit; if ($current_position >= $this->total_bytes_limit) { // Hit total_bytes_limit_. But if we also hit the normal limit, // we're still OK. $this->legitimate_message_end = ($this->current_limit === $this->total_bytes_limit); } else { $this->legitimate_message_end = true; } return 0; } $result = 0; // The larget tag is 2^29 - 1, which can be represented by int32. $success = $this->readVarint32($result); if ($success) { return $result; } else { return 0; } } public function readRaw($size, &$buffer) { $current_buffer_size = 0; if ($this->bufferSize() < $size) { return false; } $buffer = substr($this->buffer, $this->current, $size); $this->advance($size); return true; } /* Places a limit on the number of bytes that the stream may read, starting * from the current position. Once the stream hits this limit, it will act * like the end of the input has been reached until popLimit() is called. * * As the names imply, the stream conceptually has a stack of limits. The * shortest limit on the stack is always enforced, even if it is not the top * limit. * * The value returned by pushLimit() is opaque to the caller, and must be * passed unchanged to the corresponding call to popLimit(). * * @param integer $byte_limit */ public function pushLimit($byte_limit) { // Current position relative to the beginning of the stream. $current_position = $this->current(); $old_limit = $this->current_limit; // security: byte_limit is possibly evil, so check for negative values // and overflow. if ($byte_limit >= 0 && $byte_limit <= PHP_INT_MAX - $current_position) { $this->current_limit = $current_position + $byte_limit; } else { // Negative or overflow. $this->current_limit = PHP_INT_MAX; } // We need to enforce all limits, not just the new one, so if the previous // limit was before the new requested limit, we continue to enforce the // previous limit. $this->current_limit = min($this->current_limit, $old_limit); $this->recomputeBufferLimits(); return $old_limit; } /* The limit passed in is actually the *old* limit, which we returned from * PushLimit(). * * @param integer $byte_limit */ public function popLimit($byte_limit) { $this->current_limit = $byte_limit; $this->recomputeBufferLimits(); // We may no longer be at a legitimate message end. ReadTag() needs to // be called again to find out. $this->legitimate_message_end = false; } public function incrementRecursionDepthAndPushLimit( $byte_limit, &$old_limit, &$recursion_budget) { $old_limit = $this->pushLimit($byte_limit); $recursion_limit = --$this->recursion_limit; } public function decrementRecursionDepthAndPopLimit($byte_limit) { $result = $this->consumedEntireMessage(); $this->popLimit($byte_limit); ++$this->recursion_budget; return $result; } public function bytesUntilLimit() { if ($this->current_limit === PHP_INT_MAX) { return -1; } return $this->current_limit - $this->current; } } src/Google/Protobuf/Internal/MapEntry.php000064400000004050146412221520014371 0ustar00key = $key; } public function getKey() { return $this->key; } public function setValue(&$value) { $this->value = $value; } public function getValue() { return $this->value; } } src/Google/Protobuf/Internal/MapField.php000064400000021136146412221520014317 0ustar00container = $container; } /** * Reset the status of the iterator * * @return void */ public function rewind() { return reset($this->container); } /** * Return the element at the current position. * * @return object The element at the current position. */ public function current() { return current($this->container); } /** * Return the current key. * * @return object The current key. */ public function key() { return key($this->container); } /** * Move to the next position. * * @return void */ public function next() { return next($this->container); } /** * Check whether there are more elements to iterate. * * @return bool True if there are more elements to iterate. */ public function valid() { return key($this->container) !== null; } } /** * @ignore */ function checkKey($key_type, &$key) { switch ($key_type) { case GPBType::INT32: GPBUtil::checkInt32($key); break; case GPBType::UINT32: GPBUtil::checkUint32($key); break; case GPBType::INT64: GPBUtil::checkInt64($key); break; case GPBType::UINT64: GPBUtil::checkUint64($key); break; case GPBType::FIXED64: GPBUtil::checkUint64($key); break; case GPBType::FIXED32: GPBUtil::checkUint32($key); break; case GPBType::SFIXED64: GPBUtil::checkInt64($key); break; case GPBType::SFIXED32: GPBUtil::checkInt32($key); break; case GPBType::SINT64: GPBUtil::checkInt64($key); break; case GPBType::SINT32: GPBUtil::checkInt32($key); break; case GPBType::BOOL: GPBUtil::checkBool($key); break; case GPBType::STRING: GPBUtil::checkString($key, true); break; default: var_dump($key_type); trigger_error( "Given type cannot be map key.", E_USER_ERROR); break; } } /** * MapField is used by generated protocol message classes to manipulate map * fields. It can be used like native PHP array. */ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable { /** * @ignore */ private $container; /** * @ignore */ private $key_type; /** * @ignore */ private $value_type; /** * @ignore */ private $value_klass; /** * Constructs an instance of MapField. * * @param long $key_type Type of the stored key element. * @param long $value_type Type of the stored value element. * @param string $klass Message/Enum class name of value instance * (message/enum fields only). * @ignore */ public function __construct($key_type, $value_type, $klass = null) { $this->container = []; $this->key_type = $key_type; $this->value_type = $value_type; $this->klass = $klass; } /** * Return the element at the given key. * * This will also be called for: $ele = $arr[$key] * * @param object $key The key of the element to be fetched. * @return object The stored element at given key. * @throws ErrorException Invalid type for index. * @throws ErrorException Non-existing index. */ public function offsetGet($key) { return $this->container[$key]; } /** * Assign the element at the given key. * * This will also be called for: $arr[$key] = $value * * @param object $key The key of the element to be fetched. * @param object $value The element to be assigned. * @return void * @throws ErrorException Invalid type for key. * @throws ErrorException Invalid type for value. * @throws ErrorException Non-existing key. */ public function offsetSet($key, $value) { checkKey($this->key_type, $key); switch ($this->value_type) { case GPBType::INT32: GPBUtil::checkInt32($value); break; case GPBType::UINT32: GPBUtil::checkUint32($value); break; case GPBType::INT64: GPBUtil::checkInt64($value); break; case GPBType::UINT64: GPBUtil::checkUint64($value); break; case GPBType::FLOAT: GPBUtil::checkFloat($value); break; case GPBType::DOUBLE: GPBUtil::checkDouble($value); break; case GPBType::BOOL: GPBUtil::checkBool($value); break; case GPBType::STRING: GPBUtil::checkString($value, true); break; case GPBType::MESSAGE: GPBUtil::checkMessage($value, $this->klass); break; default: break; } $this->container[$key] = $value; } /** * Remove the element at the given key. * * This will also be called for: unset($arr) * * @param object $key The key of the element to be removed. * @return void * @throws ErrorException Invalid type for key. */ public function offsetUnset($key) { checkKey($this->key_type, $key); unset($this->container[$key]); } /** * Check the existence of the element at the given key. * * This will also be called for: isset($arr) * * @param object $key The key of the element to be removed. * @return bool True if the element at the given key exists. * @throws ErrorException Invalid type for key. */ public function offsetExists($key) { checkKey($this->key_type, $key); return isset($this->container[$key]); } /** * @ignore */ public function getIterator() { return new MapFieldIter($this->container); } /** * Return the number of stored elements. * * This will also be called for: count($arr) * * @return integer The number of stored elements. */ public function count() { return count($this->container); } } src/Google/Protobuf/Internal/Message.php000064400000053237146412221520014231 0ustar00desc = $desc; return; } $pool = DescriptorPool::getGeneratedPool(); $this->desc = $pool->getDescriptorByClassName(get_class($this)); foreach ($this->desc->getField() as $field) { $setter = $field->getSetter(); if ($field->isMap()) { $message_type = $field->getMessageType(); $key_field = $message_type->getFieldByNumber(1); $value_field = $message_type->getFieldByNumber(2); switch ($value_field->getType()) { case GPBType::MESSAGE: case GPBType::GROUP: $map_field = new MapField( $key_field->getType(), $value_field->getType(), $value_field->getMessageType()->getClass()); $this->$setter($map_field); break; case GPBType::ENUM: $map_field = new MapField( $key_field->getType(), $value_field->getType(), $value_field->getEnumType()->getClass()); $this->$setter($map_field); break; default: $map_field = new MapField( $key_field->getType(), $value_field->getType()); $this->$setter($map_field); break; } } else if ($field->getLabel() === GPBLabel::REPEATED) { switch ($field->getType()) { case GPBType::MESSAGE: case GPBType::GROUP: $repeated_field = new RepeatedField( $field->getType(), $field->getMessageType()->getClass()); $this->$setter($repeated_field); break; case GPBType::ENUM: $repeated_field = new RepeatedField( $field->getType(), $field->getEnumType()->getClass()); $this->$setter($repeated_field); break; default: $repeated_field = new RepeatedField($field->getType()); $this->$setter($repeated_field); break; } } else if ($field->getOneofIndex() !== -1) { $oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()]; $oneof_name = $oneof->getName(); $this->$oneof_name = new OneofField($oneof); } } } protected function readOneof($number) { $field = $this->desc->getFieldByNumber($number); $oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()]; $oneof_name = $oneof->getName(); $oneof_field = $this->$oneof_name; if ($number === $oneof_field->getNumber()) { return $oneof_field->getValue(); } else { return $this->defaultValue($field); } } protected function writeOneof($number, $value) { $field = $this->desc->getFieldByNumber($number); $oneof = $this->desc->getOneofDecl()[$field->getOneofIndex()]; $oneof_name = $oneof->getName(); $oneof_field = $this->$oneof_name; $oneof_field->setValue($value); $oneof_field->setFieldName($field->getName()); $oneof_field->setNumber($number); } /** * @ignore */ private function defaultValue($field) { $value = null; switch ($field->getType()) { case GPBType::DOUBLE: case GPBType::FLOAT: return 0.0; case GPBType::UINT32: case GPBType::UINT64: case GPBType::INT32: case GPBType::INT64: case GPBType::FIXED32: case GPBType::FIXED64: case GPBType::SFIXED32: case GPBType::SFIXED64: case GPBType::SINT32: case GPBType::SINT64: case GPBType::ENUM: return 0; case GPBType::BOOL: return false; case GPBType::STRING: case GPBType::BYTES: return ""; case GPBType::GROUP: case GPBType::MESSAGE: return null; default: user_error("Unsupported type."); return false; } } /** * @ignore */ private static function parseFieldFromStreamNoTag($input, $field, &$value) { switch ($field->getType()) { case GPBType::DOUBLE: if (!GPBWire::readDouble($input, $value)) { return false; } break; case GPBType::FLOAT: if (!GPBWire::readFloat($input, $value)) { return false; } break; case GPBType::INT64: if (!GPBWire::readInt64($input, $value)) { return false; } $value = $value->toInteger(); break; case GPBType::UINT64: if (!GPBWire::readUint64($input, $value)) { return false; } $value = $value->toInteger(); break; case GPBType::INT32: if (!GPBWire::readInt32($input, $value)) { return false; } break; case GPBType::FIXED64: if (!GPBWire::readFixed64($input, $value)) { return false; } $value = $value->toInteger(); break; case GPBType::FIXED32: if (!GPBWire::readFixed32($input, $value)) { return false; } break; case GPBType::BOOL: if (!GPBWire::readBool($input, $value)) { return false; } break; case GPBType::STRING: // TODO(teboring): Add utf-8 check. if (!GPBWire::readString($input, $value)) { return false; } break; case GPBType::GROUP: echo "GROUP\xA"; trigger_error("Not implemented.", E_ERROR); break; case GPBType::MESSAGE: if ($field->isMap()) { $value = new MapEntry($field->getMessageType()); } else { $klass = $field->getMessageType()->getClass(); $value = new $klass; } if (!GPBWire::readMessage($input, $value)) { return false; } break; case GPBType::BYTES: if (!GPBWire::readString($input, $value)) { return false; } break; case GPBType::UINT32: if (!GPBWire::readUint32($input, $value)) { return false; } break; case GPBType::ENUM: // TODO(teboring): Check unknown enum value. if (!GPBWire::readInt32($input, $value)) { return false; } break; case GPBType::SFIXED32: if (!GPBWire::readSfixed32($input, $value)) { return false; } break; case GPBType::SFIXED64: if (!GPBWire::readSfixed64($input, $value)) { return false; } $value = $value->toInteger(); break; case GPBType::SINT32: if (!GPBWire::readSint32($input, $value)) { return false; } break; case GPBType::SINT64: if (!GPBWire::readSint64($input, $value)) { return false; } $value = $value->toInteger(); break; default: user_error("Unsupported type."); return false; } return true; } /** * @ignore */ private function parseFieldFromStream($tag, $input, $field) { $value = null; $field_type = $field->getType(); $value_format = GPBWire::UNKNOWN; if (GPBWire::getTagWireType($tag) === GPBWire::getWireType($field_type)) { $value_format = GPBWire::NORMAL_FORMAT; } elseif ($field->isPackable() && GPBWire::getTagWireType($tag) === GPBWire::WIRETYPE_LENGTH_DELIMITED) { $value_format = GPBWire::PACKED_FORMAT; } if ($value_format === GPBWire::NORMAL_FORMAT) { if (!self::parseFieldFromStreamNoTag($input, $field, $value)) { return false; } } elseif ($value_format === GPBWire::PACKED_FORMAT) { $length = 0; if (!GPBWire::readInt32($input, $length)) { return false; } $limit = $input->pushLimit($length); $getter = $field->getGetter(); while ($input->bytesUntilLimit() > 0) { if (!self::parseFieldFromStreamNoTag($input, $field, $value)) { return false; } $this->$getter()[] = $value; } $input->popLimit($limit); return true; } else { return false; } if ($field->isMap()) { $getter = $field->getGetter(); $this->$getter()[$value->getKey()] = $value->getValue(); } else if ($field->isRepeated()) { $getter = $field->getGetter(); $this->$getter()[] = $value; } else { $setter = $field->getSetter(); $this->$setter($value); } return true; } /** * Parses a protocol buffer contained in a string. * * This function takes a string in the (non-human-readable) binary wire * format, matching the encoding output by encode(). * * @param string $data Binary protobuf data. * @return bool Return true on success. */ public function decode($data) { $input = new InputStream($data); $this->parseFromStream($input); } /** * @ignore */ public function parseFromStream($input) { while (true) { $tag = $input->readTag(); // End of input. This is a valid place to end, so return true. if ($tag === 0) { return true; } $number = GPBWire::getTagFieldNumber($tag); $field = $this->desc->getFieldByNumber($number); if (!$this->parseFieldFromStream($tag, $input, $field)) { return false; } } } /** * @ignore */ private function serializeSingularFieldToStream($field, &$output) { if (!$this->existField($field)) { return true; } $getter = $field->getGetter(); $value = $this->$getter(); if (!GPBWire::serializeFieldToStream($value, $field, true, $output)) { return false; } return true; } /** * @ignore */ private function serializeRepeatedFieldToStream($field, &$output) { $getter = $field->getGetter(); $values = $this->$getter(); $count = count($values); if ($count === 0) { return true; } $packed = $field->getPacked(); if ($packed) { if (!GPBWire::writeTag( $output, GPBWire::makeTag($field->getNumber(), GPBType::STRING))) { return false; } $size = 0; foreach ($values as $value) { $size += $this->fieldDataOnlyByteSize($field, $value); } if (!$output->writeVarint32($size)) { return false; } } foreach ($values as $value) { if (!GPBWire::serializeFieldToStream( $value, $field, !$packed, $output)) { return false; } } return true; } /** * @ignore */ private function serializeMapFieldToStream($field, $output) { $getter = $field->getGetter(); $values = $this->$getter(); $count = count($values); if ($count === 0) { return true; } foreach ($values as $key => $value) { $map_entry = new MapEntry($field->getMessageType()); $map_entry->setKey($key); $map_entry->setValue($value); if (!GPBWire::serializeFieldToStream( $map_entry, $field, true, $output)) { return false; } } return true; } /** * @ignore */ private function serializeFieldToStream(&$output, $field) { if ($field->isMap()) { return $this->serializeMapFieldToStream($field, $output); } elseif ($field->isRepeated()) { return $this->serializeRepeatedFieldToStream($field, $output); } else { return $this->serializeSingularFieldToStream($field, $output); } } /** * @ignore */ public function serializeToStream(&$output) { $fields = $this->desc->getField(); foreach ($fields as $field) { if (!$this->serializeFieldToStream($output, $field)) { return false; } } return true; } /** * Serialize the message to string. * @return string Serialized binary protobuf data. */ public function encode() { $output = new OutputStream($this->byteSize()); $this->serializeToStream($output); return $output->getData(); } /** * @ignore */ private function existField($field) { $getter = $field->getGetter(); $value = $this->$getter(); return $value !== $this->defaultValue($field); } /** * @ignore */ private function repeatedFieldDataOnlyByteSize($field) { $size = 0; $getter = $field->getGetter(); $values = $this->$getter(); $count = count($values); if ($count !== 0) { $size += $count * GPBWire::tagSize($field); foreach ($values as $value) { $size += $this->singularFieldDataOnlyByteSize($field); } } } /** * @ignore */ private function fieldDataOnlyByteSize($field, $value) { $size = 0; switch ($field->getType()) { case GPBType::BOOL: $size += 1; break; case GPBType::FLOAT: case GPBType::FIXED32: case GPBType::SFIXED32: $size += 4; break; case GPBType::DOUBLE: case GPBType::FIXED64: case GPBType::SFIXED64: $size += 8; break; case GPBType::UINT32: case GPBType::INT32: case GPBType::ENUM: $size += GPBWire::varint32Size($value); break; case GPBType::UINT64: case GPBType::INT64: $size += GPBWire::varint64Size($value); break; case GPBType::SINT32: $size += GPBWire::sint32Size($value); break; case GPBType::SINT64: $size += GPBWire::sint64Size($value); break; case GPBType::STRING: case GPBType::BYTES: $size += strlen($value); $size += GPBWire::varint32Size($size); break; case GPBType::MESSAGE: $size += $value->byteSize(); $size += GPBWire::varint32Size($size); break; case GPBType::GROUP: // TODO(teboring): Add support. user_error("Unsupported type."); break; default: user_error("Unsupported type."); return 0; } return $size; } /** * @ignore */ private function fieldByteSize($field) { $size = 0; if ($field->isMap()) { $getter = $field->getGetter(); $values = $this->$getter(); $count = count($values); if ($count !== 0) { $size += $count * GPBWire::tagSize($field); $message_type = $field->getMessageType(); $key_field = $message_type->getFieldByNumber(1); $value_field = $message_type->getFieldByNumber(2); foreach ($values as $key => $value) { $data_size = 0; $data_size += $this->fieldDataOnlyByteSize($key_field, $key); $data_size += $this->fieldDataOnlyByteSize( $value_field, $value); $data_size += GPBWire::tagSize($key_field); $data_size += GPBWire::tagSize($value_field); $size += GPBWire::varint32Size($data_size) + $data_size; } } } elseif ($field->isRepeated()) { $getter = $field->getGetter(); $values = $this->$getter(); $count = count($values); if ($count !== 0) { if ($field->getPacked()) { $data_size = 0; foreach ($values as $value) { $data_size += $this->fieldDataOnlyByteSize($field, $value); } $size += GPBWire::tagSize($field); $size += GPBWire::varint32Size($data_size); $size += $data_size; } else { $size += $count * GPBWire::tagSize($field); foreach ($values as $value) { $size += $this->fieldDataOnlyByteSize($field, $value); } } } } elseif ($this->existField($field)) { $size += GPBWire::tagSize($field); $getter = $field->getGetter(); $value = $this->$getter(); $size += $this->fieldDataOnlyByteSize($field, $value); } return $size; } /** * @ignore */ public function byteSize() { $size = 0; $fields = $this->desc->getField(); foreach ($fields as $field) { $size += $this->fieldByteSize($field); } return $size; } } src/Google/Protobuf/Internal/MessageBuilderContext.php000064400000010036146412221520017073 0ustar00descriptor = new Descriptor(); $this->descriptor->setFullName($full_name); $this->descriptor->setClass($klass); $this->pool = $pool; } private function getFieldDescriptor($name, $label, $type, $number, $type_name = null) { $field = new FieldDescriptor(); $field->setName($name); $camel_name = implode('', array_map('ucwords', explode('_', $name))); $field->setGetter('get' . $camel_name); $field->setSetter('set' . $camel_name); $field->setType($type); $field->setNumber($number); $field->setLabel($label); // At this time, the message/enum type may have not been added to pool. // So we use the type name as place holder and will replace it with the // actual descriptor in cross building. switch ($type) { case GPBType::MESSAGE: $field->setMessageType($type_name); break; case GPBType::ENUM: $field->setEnumType($type_name); break; default: break; } return $field; } public function optional($name, $type, $number, $type_name = null) { $this->descriptor->addField($this->getFieldDescriptor( $name, GPBLabel::OPTIONAL, $type, $number, $type_name)); return $this; } public function repeated($name, $type, $number, $type_name = null) { $this->descriptor->addField($this->getFieldDescriptor( $name, GPBLabel::REPEATED, $type, $number, $type_name)); return $this; } public function required($name, $type, $number, $type_name = null) { $this->descriptor->addField($this->getFieldDescriptor( $name, GPBLabel::REQUIRED, $type, $number, $type_name)); return $this; } public function finalizeToPool() { $this->pool->addDescriptor($this->descriptor); } } src/Google/Protobuf/Internal/OneofField.php000064400000004530146412221520014647 0ustar00desc = $desc; } public function setValue($value) { $this->value = $value; } public function getValue() { return $this->value; } public function setFieldName($field_name) { $this->field_name = $field_name; } public function getFieldName() { return $this->field_name; } public function setNumber($number) { $this->number = $number; } public function getNumber() { return $this->number; } } src/Google/Protobuf/Internal/OutputStream.php000064400000011404146412221520015307 0ustar00current = 0; $this->buffer_size = $size; $this->buffer = str_repeat(chr(0), $this->buffer_size); } public function getData() { return $this->buffer; } public function writeVarint32($value) { $bytes = str_repeat(chr(0), self::MAX_VARINT32_BYTES); $size = self::writeVarintToArray($value, $bytes, true); return $this->writeRaw($bytes, $size); } public function writeVarint64($value) { $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); $size = self::writeVarintToArray($value, $bytes); return $this->writeRaw($bytes, $size); } public function writeLittleEndian32($value) { $bytes = str_repeat(chr(0), 4); $size = self::writeLittleEndian32ToArray($value, $bytes); return $this->writeRaw($bytes, $size); } public function writeLittleEndian64($value) { $bytes = str_repeat(chr(0), 8); $size = self::writeLittleEndian64ToArray($value, $bytes); return $this->writeRaw($bytes, $size); } public function writeTag($tag) { return $this->writeVarint32($tag); } public function writeRaw($data, $size) { if ($this->buffer_size < $size) { var_dump($this->buffer_size); var_dump($size); trigger_error("Output stream doesn't have enough buffer."); return false; } for ($i = 0; $i < $size; $i++) { $this->buffer[$this->current] = $data[$i]; $this->current++; $this->buffer_size--; } return true; } private static function writeVarintToArray($value, &$buffer, $trim = false) { $current = 0; if ($trim) { $value &= 0xFFFFFFFF; } while ($value >= 0x80 || $value < 0) { $buffer[$current] = chr($value | 0x80); $value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); $current++; } $buffer[$current] = chr($value); return $current + 1; } private static function writeLittleEndian32ToArray($value, &$buffer) { $buffer[0] = chr($value & 0x000000FF); $buffer[1] = chr(($value >> 8) & 0x000000FF); $buffer[2] = chr(($value >> 16) & 0x000000FF); $buffer[3] = chr(($value >> 24) & 0x000000FF); return 4; } private static function writeLittleEndian64ToArray($value, &$buffer) { $buffer[0] = chr($value & 0x000000FF); $buffer[1] = chr(($value >> 8) & 0x000000FF); $buffer[2] = chr(($value >> 16) & 0x000000FF); $buffer[3] = chr(($value >> 24) & 0x000000FF); $buffer[4] = chr(($value >> 32) & 0x000000FF); $buffer[5] = chr(($value >> 40) & 0x000000FF); $buffer[6] = chr(($value >> 48) & 0x000000FF); $buffer[7] = chr(($value >> 56) & 0x000000FF); return 8; } } src/Google/Protobuf/Internal/RepeatedField.php000064400000020265146412221520015335 0ustar00position = 0; $this->container = $container; } /** * Reset the status of the iterator * * @return void */ public function rewind() { $this->position = 0; } /** * Return the element at the current position. * * @return object The element at the current position. */ public function current() { return $this->container[$this->position]; } /** * Return the current position. * * @return integer The current position. */ public function key() { return $this->position; } /** * Move to the next position. * * @return void */ public function next() { ++$this->position; } /** * Check whether there are more elements to iterate. * * @return bool True if there are more elements to iterate. */ public function valid() { return isset($this->container[$this->position]); } } /** * RepeatedField is used by generated protocol message classes to manipulate * repeated fields. It can be used like native PHP array. */ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable { /** * @ignore */ private $container; /** * @ignore */ private $type; /** * @ignore */ private $klass; /** * Constructs an instance of RepeatedField. * * @param long $type Type of the stored element. * @param string $klass Message/Enum class name (message/enum fields only). * @ignore */ public function __construct($type, $klass = null) { $this->container = []; $this->type = $type; $this->klass = $klass; } /** * @ignore */ public function getType() { return $this->type; } /** * @ignore */ public function getClass() { return $this->klass; } /** * Return the element at the given index. * * This will also be called for: $ele = $arr[0] * * @param long $offset The index of the element to be fetched. * @return object The stored element at given index. * @throws ErrorException Invalid type for index. * @throws ErrorException Non-existing index. */ public function offsetGet($offset) { return $this->container[$offset]; } /** * Assign the element at the given index. * * This will also be called for: $arr []= $ele and $arr[0] = ele * * @param long $offset The index of the element to be assigned. * @param object $value The element to be assigned. * @return void * @throws ErrorException Invalid type for index. * @throws ErrorException Non-existing index. * @throws ErrorException Incorrect type of the element. */ public function offsetSet($offset, $value) { switch ($this->type) { case GPBType::INT32: GPBUtil::checkInt32($value); break; case GPBType::UINT32: GPBUtil::checkUint32($value); break; case GPBType::INT64: GPBUtil::checkInt64($value); break; case GPBType::UINT64: GPBUtil::checkUint64($value); break; case GPBType::FLOAT: GPBUtil::checkFloat($value); break; case GPBType::DOUBLE: GPBUtil::checkDouble($value); break; case GPBType::BOOL: GPBUtil::checkBool($value); break; case GPBType::STRING: GPBUtil::checkString($value, true); break; case GPBType::MESSAGE: GPBUtil::checkMessage($value, $this->klass); break; default: break; } if (is_null($offset)) { $this->container[] = $value; } else { $count = count($this->container); if (!is_numeric($offset) || $offset < 0 || $offset >= $count) { trigger_error( "Cannot modify element at the given index", E_USER_ERROR); return; } $this->container[$offset] = $value; } } /** * Remove the element at the given index. * * This will also be called for: unset($arr) * * @param long $offset The index of the element to be removed. * @return void * @throws ErrorException Invalid type for index. * @throws ErrorException The element to be removed is not at the end of the * RepeatedField. */ public function offsetUnset($offset) { $count = count($this->container); if (!is_numeric($offset) || $count === 0 || $offset !== $count - 1) { trigger_error( "Cannot remove element at the given index", E_USER_ERROR); return; } array_pop($this->container); } /** * Check the existence of the element at the given index. * * This will also be called for: isset($arr) * * @param long $offset The index of the element to be removed. * @return bool True if the element at the given offset exists. * @throws ErrorException Invalid type for index. */ public function offsetExists($offset) { return isset($this->container[$offset]); } /** * @ignore */ public function getIterator() { return new RepeatedFieldIter($this->container); } /** * Return the number of stored elements. * * This will also be called for: count($arr) * * @return integer The number of stored elements. */ public function count() { return count($this->container); } } src/Google/Protobuf/Internal/Type.php000064400000011341146412221520013554 0ustar00low = $value & 0xFFFFFFFF; if (PHP_INT_SIZE === 8) { $this->high = ($value >> 32) & 0xFFFFFFFF; } } // Return 0 for unsigned integers and 1 for signed integers. protected function sign() { trigger_error("Not implemented", E_ERROR); } public function leftShift($count) { if ($count > 63) { $this->low = 0; $this->high = 0; return; } if ($count > 32) { $this->high = $this->low; $this->low = 0; $count -= 32; } $mask = (1 << $count) - 1; $this->high = (($this->high << $count) & 0xFFFFFFFF) | (($this->low >> (32 - $count)) & $mask); $this->low = ($this->low << $count) & 0xFFFFFFFF; $this->high &= 0xFFFFFFFF; $this->low &= 0xFFFFFFFF; return $this; } public function rightShift($count) { $sign = (($this->high & 0x80000000) >> 31) & $this->sign(); if ($count > 63) { $this->low = -$sign; $this->high = -$sign; return; } if ($count > 32) { $this->low = $this->high; $this->high = -$sign; $count -= 32; } $this->low = (($this->low >> $count) & 0xFFFFFFFF) | (($this->high << (32 - $count)) & 0xFFFFFFFF); $this->high = (($this->high >> $count) | (-$sign << $count)); $this->high &= 0xFFFFFFFF; $this->low &= 0xFFFFFFFF; return $this; } public function bitOr($var) { $this->high |= $var->high; $this->low |= $var->low; return $this; } public function bitXor($var) { $this->high ^= $var->high; $this->low ^= $var->low; return $this; } public function bitAnd($var) { $this->high &= $var->high; $this->low &= $var->low; return $this; } // Even: all zero; Odd: all one. public function oddMask() { $low = (-($this->low & 1)) & 0xFFFFFFFF; $high = $low; return UInt64::newValue($high, $low); } public function toInteger() { if (PHP_INT_SIZE === 8) { return ($this->high << 32) | $this->low; } else { return $this->low; } } public function copy() { return static::newValue($this->high, $this->low); } } class Uint64 extends GPBInteger { public static function newValue($high, $low) { $uint64 = new Uint64(0); $uint64->high = $high; $uint64->low = $low; return $uint64; } protected function sign() { return 0; } } class Int64 extends GPBInteger { public static function newValue($high, $low) { $int64 = new Int64(0); $int64->high = $high; $int64->low = $low; return $int64; } protected function sign() { return 1; } } src/Google/Protobuf/descriptor.php000064400000030773146412221520013247 0ustar00package = $package; } public function getPackage() { return $this->package; } public function getMessageType() { return $this->message_type; } public function addMessageType($desc) { $this->message_type[] = $desc; } public function getEnumType() { return $this->enum_type; } public function addEnumType($desc) { $this->enum_type[]= $desc; } public static function buildFromProto($proto) { $file = new FileDescriptor(); $file->setPackage($proto->getPackage()); foreach ($proto->getMessageType() as $message_proto) { $file->addMessageType(Descriptor::buildFromProto( $message_proto, $file->getPackage(), "")); } foreach ($proto->getEnumType() as $enum_proto) { $file->getEnumType()[] = $file->addEnumType( EnumDescriptor::buildFromProto( $enum_proto, $file->getPackage(), "")); } return $file; } } class Descriptor { private $full_name; private $field = []; private $nested_type = []; private $enum_type = []; private $klass; private $options; private $oneof_decl = []; public function addOneofDecl($oneof) { $this->oneof_decl[] = $oneof; } public function getOneofDecl() { return $this->oneof_decl; } public function setFullName($full_name) { $this->full_name = $full_name; } public function getFullName() { return $this->full_name; } public function addField($field) { $this->field[$field->getNumber()] = $field; } public function getField() { return $this->field; } public function addNestedType($desc) { $this->nested_type[] = $desc; } public function getNestedType() { return $this->nested_type; } public function addEnumType($desc) { $this->enum_type[] = $desc; } public function getEnumType() { return $this->enum_type; } public function getFieldByNumber($number) { return $this->field[$number]; } public function setClass($klass) { $this->klass = $klass; } public function getClass() { return $this->klass; } public function setOptions($options) { $this->options = $options; } public function getOptions() { return $this->options; } public static function buildFromProto($proto, $package, $containing) { $desc = new Descriptor(); $message_name_without_package = ""; $classname = ""; $fullname = ""; getFullClassName( $proto, $containing, $package, $message_name_without_package, $classname, $fullname); $desc->setFullName($fullname); $desc->setClass($classname); $desc->setOptions($proto->getOptions()); foreach ($proto->getField() as $field_proto) { $desc->addField(FieldDescriptor::buildFromProto($field_proto)); } // Handle nested types. foreach ($proto->getNestedType() as $nested_proto) { $desc->addNestedType(Descriptor::buildFromProto( $nested_proto, $package, $message_name_without_package)); } // Handle oneof fields. foreach ($proto->getOneofDecl() as $oneof_proto) { $desc->addOneofDecl( OneofDescriptor::buildFromProto($oneof_proto, $desc)); } return $desc; } } function getFullClassName( $proto, $containing, $package, &$message_name_without_package, &$classname, &$fullname) { // Full name needs to start with '.'. $message_name_without_package = $proto->getName(); if ($containing !== "") { $message_name_without_package = $containing . "." . $message_name_without_package; } if ($package === "") { $fullname = "." . $message_name_without_package; } else { $fullname = "." . $package . "." . $message_name_without_package; } // Nested message class names are seperated by '_', and package names are // seperated by '\'. $class_name_without_package = implode('_', array_map('ucwords', explode('.', $message_name_without_package))); $classname = implode('\\', array_map('ucwords', explode('.', $package))). "\\".$class_name_without_package; } class OneofDescriptor { private $name; private $fields; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function addField(&$field) { $this->fields[] = $field; } public function getFields() { return $this->fields; } public static function buildFromProto($oneof_proto) { $oneof = new OneofDescriptor(); $oneof->setName($oneof_proto->getName()); return $oneof; } } class EnumDescriptor { private $klass; private $full_name; private $value; public function setFullName($full_name) { $this->full_name = $full_name; } public function getFullName() { return $this->full_name; } public function addValue($number, $value) { $this->value[$number] = $value; } public function setClass($klass) { $this->klass = $klass; } public function getClass() { return $this->klass; } public static function buildFromProto($proto, $package, $containing) { $desc = new EnumDescriptor(); $enum_name_without_package = ""; $classname = ""; $fullname = ""; getFullClassName( $proto, $containing, $package, $enum_name_without_package, $classname, $fullname); $desc->setFullName($fullname); $desc->setClass($classname); return $desc; } } class EnumValueDescriptor { } class FieldDescriptor { private $name; private $setter; private $getter; private $number; private $label; private $type; private $message_type; private $enum_type; private $packed; private $is_map; private $oneof_index = -1; public function setOneofIndex($index) { $this->oneof_index = $index; } public function getOneofIndex() { return $this->oneof_index; } public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } public function setSetter($setter) { $this->setter = $setter; } public function getSetter() { return $this->setter; } public function setGetter($getter) { $this->getter = $getter; } public function getGetter() { return $this->getter; } public function setNumber($number) { $this->number = $number; } public function getNumber() { return $this->number; } public function setLabel($label) { $this->label = $label; } public function getLabel() { return $this->label; } public function isRepeated() { return $this->label === GPBLabel::REPEATED; } public function setType($type) { $this->type = $type; } public function getType() { return $this->type; } public function setMessageType($message_type) { $this->message_type = $message_type; } public function getMessageType() { return $this->message_type; } public function setEnumType($enum_type) { $this->enum_type = $enum_type; } public function getEnumType() { return $this->enum_type; } public function setPacked($packed) { $this->packed = $packed; } public function getPacked() { return $this->packed; } public function isPackable() { return $this->isRepeated() && self::isTypePackable($this->type); } public function isMap() { return $this->getType() == GPBType::MESSAGE && !is_null($this->getMessageType()->getOptions()) && $this->getMessageType()->getOptions()->getMapEntry(); } private static function isTypePackable($field_type) { return ($field_type !== GPBType::STRING && $field_type !== GPBType::GROUP && $field_type !== GPBType::MESSAGE && $field_type !== GPBType::BYTES); } public static function getFieldDescriptor( $name, $label, $type, $number, $oneof_index, $packed, $type_name = null) { $field = new FieldDescriptor(); $field->setName($name); $camel_name = implode('', array_map('ucwords', explode('_', $name))); $field->setGetter('get' . $camel_name); $field->setSetter('set' . $camel_name); $field->setType($type); $field->setNumber($number); $field->setLabel($label); $field->setPacked($packed); $field->setOneofIndex($oneof_index); // At this time, the message/enum type may have not been added to pool. // So we use the type name as place holder and will replace it with the // actual descriptor in cross building. switch ($type) { case GPBType::MESSAGE: $field->setMessageType($type_name); break; case GPBType::ENUM: $field->setEnumType($type_name); break; default: break; } return $field; } public static function buildFromProto($proto) { $type_name = null; switch ($proto->getType()) { case GPBType::MESSAGE: case GPBType::GROUP: case GPBType::ENUM: $type_name = $proto->getTypeName(); break; default: break; } $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; $packed = false; $options = $proto->getOptions(); if ($options !== null) { $packed = $options->getPacked(); } return FieldDescriptor::getFieldDescriptor( $proto->getName(), $proto->getLabel(), $proto->getType(), $proto->getNumber(), $oneof_index, $packed, $type_name); } } src/Google/Protobuf/descriptor_internal.pb.php000064400000173065146412221520015545 0ustar00file; } public function setFile(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); $this->file = $var; $this->has_file = true; } public function hasFile() { return $this->has_file; } } class FileDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $package = ''; private $has_package = false; private $dependency; private $has_dependency = false; private $public_dependency; private $has_public_dependency = false; private $weak_dependency; private $has_weak_dependency = false; private $message_type; private $has_message_type = false; private $enum_type; private $has_enum_type = false; private $service; private $has_service = false; private $extension; private $has_extension = false; private $options = null; private $has_options = false; private $source_code_info = null; private $has_source_code_info = false; private $syntax = ''; private $has_syntax = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getPackage() { return $this->package; } public function setPackage($var) { GPBUtil::checkString($var, True); $this->package = $var; $this->has_package = true; } public function hasPackage() { return $this->has_package; } public function getDependency() { return $this->dependency; } public function setDependency(&$var) { GPBUtil::checkRepeatedField($var, GPBType::STRING); $this->dependency = $var; $this->has_dependency = true; } public function hasDependency() { return $this->has_dependency; } public function getPublicDependency() { return $this->public_dependency; } public function setPublicDependency(&$var) { GPBUtil::checkRepeatedField($var, GPBType::INT32); $this->public_dependency = $var; $this->has_public_dependency = true; } public function hasPublicDependency() { return $this->has_public_dependency; } public function getWeakDependency() { return $this->weak_dependency; } public function setWeakDependency(&$var) { GPBUtil::checkRepeatedField($var, GPBType::INT32); $this->weak_dependency = $var; $this->has_weak_dependency = true; } public function hasWeakDependency() { return $this->has_weak_dependency; } public function getMessageType() { return $this->message_type; } public function setMessageType(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->message_type = $var; $this->has_message_type = true; } public function hasMessageType() { return $this->has_message_type; } public function getEnumType() { return $this->enum_type; } public function setEnumType(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $var; $this->has_enum_type = true; } public function hasEnumType() { return $this->has_enum_type; } public function getService() { return $this->service; } public function setService(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); $this->service = $var; $this->has_service = true; } public function hasService() { return $this->has_service; } public function getExtension() { return $this->extension; } public function setExtension(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $var; $this->has_extension = true; } public function hasExtension() { return $this->has_extension; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } public function getSourceCodeInfo() { return $this->source_code_info; } public function setSourceCodeInfo(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); $this->source_code_info = $var; $this->has_source_code_info = true; } public function hasSourceCodeInfo() { return $this->has_source_code_info; } public function getSyntax() { return $this->syntax; } public function setSyntax($var) { GPBUtil::checkString($var, True); $this->syntax = $var; $this->has_syntax = true; } public function hasSyntax() { return $this->has_syntax; } } class DescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $field; private $has_field = false; private $extension; private $has_extension = false; private $nested_type; private $has_nested_type = false; private $enum_type; private $has_enum_type = false; private $extension_range; private $has_extension_range = false; private $oneof_decl; private $has_oneof_decl = false; private $options = null; private $has_options = false; private $reserved_range; private $has_reserved_range = false; private $reserved_name; private $has_reserved_name = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getField() { return $this->field; } public function setField(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->field = $var; $this->has_field = true; } public function hasField() { return $this->has_field; } public function getExtension() { return $this->extension; } public function setExtension(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $var; $this->has_extension = true; } public function hasExtension() { return $this->has_extension; } public function getNestedType() { return $this->nested_type; } public function setNestedType(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->nested_type = $var; $this->has_nested_type = true; } public function hasNestedType() { return $this->has_nested_type; } public function getEnumType() { return $this->enum_type; } public function setEnumType(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $var; $this->has_enum_type = true; } public function hasEnumType() { return $this->has_enum_type; } public function getExtensionRange() { return $this->extension_range; } public function setExtensionRange(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class); $this->extension_range = $var; $this->has_extension_range = true; } public function hasExtensionRange() { return $this->has_extension_range; } public function getOneofDecl() { return $this->oneof_decl; } public function setOneofDecl(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); $this->oneof_decl = $var; $this->has_oneof_decl = true; } public function hasOneofDecl() { return $this->has_oneof_decl; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } public function getReservedRange() { return $this->reserved_range; } public function setReservedRange(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class); $this->reserved_range = $var; $this->has_reserved_range = true; } public function hasReservedRange() { return $this->has_reserved_range; } public function getReservedName() { return $this->reserved_name; } public function setReservedName(&$var) { GPBUtil::checkRepeatedField($var, GPBType::STRING); $this->reserved_name = $var; $this->has_reserved_name = true; } public function hasReservedName() { return $this->has_reserved_name; } } class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message { private $start = 0; private $has_start = false; private $end = 0; private $has_end = false; public function getStart() { return $this->start; } public function setStart($var) { GPBUtil::checkInt32($var); $this->start = $var; $this->has_start = true; } public function hasStart() { return $this->has_start; } public function getEnd() { return $this->end; } public function setEnd($var) { GPBUtil::checkInt32($var); $this->end = $var; $this->has_end = true; } public function hasEnd() { return $this->has_end; } } class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message { private $start = 0; private $has_start = false; private $end = 0; private $has_end = false; public function getStart() { return $this->start; } public function setStart($var) { GPBUtil::checkInt32($var); $this->start = $var; $this->has_start = true; } public function hasStart() { return $this->has_start; } public function getEnd() { return $this->end; } public function setEnd($var) { GPBUtil::checkInt32($var); $this->end = $var; $this->has_end = true; } public function hasEnd() { return $this->has_end; } } class FieldDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $number = 0; private $has_number = false; private $label = 0; private $has_label = false; private $type = 0; private $has_type = false; private $type_name = ''; private $has_type_name = false; private $extendee = ''; private $has_extendee = false; private $default_value = ''; private $has_default_value = false; private $oneof_index = 0; private $has_oneof_index = false; private $json_name = ''; private $has_json_name = false; private $options = null; private $has_options = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getNumber() { return $this->number; } public function setNumber($var) { GPBUtil::checkInt32($var); $this->number = $var; $this->has_number = true; } public function hasNumber() { return $this->has_number; } public function getLabel() { return $this->label; } public function setLabel($var) { GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class); $this->label = $var; $this->has_label = true; } public function hasLabel() { return $this->has_label; } public function getType() { return $this->type; } public function setType($var) { GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class); $this->type = $var; $this->has_type = true; } public function hasType() { return $this->has_type; } public function getTypeName() { return $this->type_name; } public function setTypeName($var) { GPBUtil::checkString($var, True); $this->type_name = $var; $this->has_type_name = true; } public function hasTypeName() { return $this->has_type_name; } public function getExtendee() { return $this->extendee; } public function setExtendee($var) { GPBUtil::checkString($var, True); $this->extendee = $var; $this->has_extendee = true; } public function hasExtendee() { return $this->has_extendee; } public function getDefaultValue() { return $this->default_value; } public function setDefaultValue($var) { GPBUtil::checkString($var, True); $this->default_value = $var; $this->has_default_value = true; } public function hasDefaultValue() { return $this->has_default_value; } public function getOneofIndex() { return $this->oneof_index; } public function setOneofIndex($var) { GPBUtil::checkInt32($var); $this->oneof_index = $var; $this->has_oneof_index = true; } public function hasOneofIndex() { return $this->has_oneof_index; } public function getJsonName() { return $this->json_name; } public function setJsonName($var) { GPBUtil::checkString($var, True); $this->json_name = $var; $this->has_json_name = true; } public function hasJsonName() { return $this->has_json_name; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } } class FieldDescriptorProto_Type { const TYPE_DOUBLE = 1; const TYPE_FLOAT = 2; const TYPE_INT64 = 3; const TYPE_UINT64 = 4; const TYPE_INT32 = 5; const TYPE_FIXED64 = 6; const TYPE_FIXED32 = 7; const TYPE_BOOL = 8; const TYPE_STRING = 9; const TYPE_GROUP = 10; const TYPE_MESSAGE = 11; const TYPE_BYTES = 12; const TYPE_UINT32 = 13; const TYPE_ENUM = 14; const TYPE_SFIXED32 = 15; const TYPE_SFIXED64 = 16; const TYPE_SINT32 = 17; const TYPE_SINT64 = 18; } class FieldDescriptorProto_Label { const LABEL_OPTIONAL = 1; const LABEL_REQUIRED = 2; const LABEL_REPEATED = 3; } class OneofDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $options = null; private $has_options = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } } class EnumDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $value; private $has_value = false; private $options = null; private $has_options = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getValue() { return $this->value; } public function setValue(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); $this->value = $var; $this->has_value = true; } public function hasValue() { return $this->has_value; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } } class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $number = 0; private $has_number = false; private $options = null; private $has_options = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getNumber() { return $this->number; } public function setNumber($var) { GPBUtil::checkInt32($var); $this->number = $var; $this->has_number = true; } public function hasNumber() { return $this->has_number; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } } class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $method; private $has_method = false; private $options = null; private $has_options = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getMethod() { return $this->method; } public function setMethod(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class); $this->method = $var; $this->has_method = true; } public function hasMethod() { return $this->has_method; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } } class MethodDescriptorProto extends \Google\Protobuf\Internal\Message { private $name = ''; private $has_name = false; private $input_type = ''; private $has_input_type = false; private $output_type = ''; private $has_output_type = false; private $options = null; private $has_options = false; private $client_streaming = false; private $has_client_streaming = false; private $server_streaming = false; private $has_server_streaming = false; public function getName() { return $this->name; } public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getInputType() { return $this->input_type; } public function setInputType($var) { GPBUtil::checkString($var, True); $this->input_type = $var; $this->has_input_type = true; } public function hasInputType() { return $this->has_input_type; } public function getOutputType() { return $this->output_type; } public function setOutputType($var) { GPBUtil::checkString($var, True); $this->output_type = $var; $this->has_output_type = true; } public function hasOutputType() { return $this->has_output_type; } public function getOptions() { return $this->options; } public function setOptions(&$var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class); $this->options = $var; $this->has_options = true; } public function hasOptions() { return $this->has_options; } public function getClientStreaming() { return $this->client_streaming; } public function setClientStreaming($var) { GPBUtil::checkBool($var); $this->client_streaming = $var; $this->has_client_streaming = true; } public function hasClientStreaming() { return $this->has_client_streaming; } public function getServerStreaming() { return $this->server_streaming; } public function setServerStreaming($var) { GPBUtil::checkBool($var); $this->server_streaming = $var; $this->has_server_streaming = true; } public function hasServerStreaming() { return $this->has_server_streaming; } } class FileOptions extends \Google\Protobuf\Internal\Message { private $java_package = ''; private $has_java_package = false; private $java_outer_classname = ''; private $has_java_outer_classname = false; private $java_multiple_files = false; private $has_java_multiple_files = false; private $java_generate_equals_and_hash = false; private $has_java_generate_equals_and_hash = false; private $java_string_check_utf8 = false; private $has_java_string_check_utf8 = false; private $optimize_for = 0; private $has_optimize_for = false; private $go_package = ''; private $has_go_package = false; private $cc_generic_services = false; private $has_cc_generic_services = false; private $java_generic_services = false; private $has_java_generic_services = false; private $py_generic_services = false; private $has_py_generic_services = false; private $deprecated = false; private $has_deprecated = false; private $cc_enable_arenas = false; private $has_cc_enable_arenas = false; private $objc_class_prefix = ''; private $has_objc_class_prefix = false; private $csharp_namespace = ''; private $has_csharp_namespace = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getJavaPackage() { return $this->java_package; } public function setJavaPackage($var) { GPBUtil::checkString($var, True); $this->java_package = $var; $this->has_java_package = true; } public function hasJavaPackage() { return $this->has_java_package; } public function getJavaOuterClassname() { return $this->java_outer_classname; } public function setJavaOuterClassname($var) { GPBUtil::checkString($var, True); $this->java_outer_classname = $var; $this->has_java_outer_classname = true; } public function hasJavaOuterClassname() { return $this->has_java_outer_classname; } public function getJavaMultipleFiles() { return $this->java_multiple_files; } public function setJavaMultipleFiles($var) { GPBUtil::checkBool($var); $this->java_multiple_files = $var; $this->has_java_multiple_files = true; } public function hasJavaMultipleFiles() { return $this->has_java_multiple_files; } public function getJavaGenerateEqualsAndHash() { return $this->java_generate_equals_and_hash; } public function setJavaGenerateEqualsAndHash($var) { GPBUtil::checkBool($var); $this->java_generate_equals_and_hash = $var; $this->has_java_generate_equals_and_hash = true; } public function hasJavaGenerateEqualsAndHash() { return $this->has_java_generate_equals_and_hash; } public function getJavaStringCheckUtf8() { return $this->java_string_check_utf8; } public function setJavaStringCheckUtf8($var) { GPBUtil::checkBool($var); $this->java_string_check_utf8 = $var; $this->has_java_string_check_utf8 = true; } public function hasJavaStringCheckUtf8() { return $this->has_java_string_check_utf8; } public function getOptimizeFor() { return $this->optimize_for; } public function setOptimizeFor($var) { GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class); $this->optimize_for = $var; $this->has_optimize_for = true; } public function hasOptimizeFor() { return $this->has_optimize_for; } public function getGoPackage() { return $this->go_package; } public function setGoPackage($var) { GPBUtil::checkString($var, True); $this->go_package = $var; $this->has_go_package = true; } public function hasGoPackage() { return $this->has_go_package; } public function getCcGenericServices() { return $this->cc_generic_services; } public function setCcGenericServices($var) { GPBUtil::checkBool($var); $this->cc_generic_services = $var; $this->has_cc_generic_services = true; } public function hasCcGenericServices() { return $this->has_cc_generic_services; } public function getJavaGenericServices() { return $this->java_generic_services; } public function setJavaGenericServices($var) { GPBUtil::checkBool($var); $this->java_generic_services = $var; $this->has_java_generic_services = true; } public function hasJavaGenericServices() { return $this->has_java_generic_services; } public function getPyGenericServices() { return $this->py_generic_services; } public function setPyGenericServices($var) { GPBUtil::checkBool($var); $this->py_generic_services = $var; $this->has_py_generic_services = true; } public function hasPyGenericServices() { return $this->has_py_generic_services; } public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getCcEnableArenas() { return $this->cc_enable_arenas; } public function setCcEnableArenas($var) { GPBUtil::checkBool($var); $this->cc_enable_arenas = $var; $this->has_cc_enable_arenas = true; } public function hasCcEnableArenas() { return $this->has_cc_enable_arenas; } public function getObjcClassPrefix() { return $this->objc_class_prefix; } public function setObjcClassPrefix($var) { GPBUtil::checkString($var, True); $this->objc_class_prefix = $var; $this->has_objc_class_prefix = true; } public function hasObjcClassPrefix() { return $this->has_objc_class_prefix; } public function getCsharpNamespace() { return $this->csharp_namespace; } public function setCsharpNamespace($var) { GPBUtil::checkString($var, True); $this->csharp_namespace = $var; $this->has_csharp_namespace = true; } public function hasCsharpNamespace() { return $this->has_csharp_namespace; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class FileOptions_OptimizeMode { const SPEED = 1; const CODE_SIZE = 2; const LITE_RUNTIME = 3; } class MessageOptions extends \Google\Protobuf\Internal\Message { private $message_set_wire_format = false; private $has_message_set_wire_format = false; private $no_standard_descriptor_accessor = false; private $has_no_standard_descriptor_accessor = false; private $deprecated = false; private $has_deprecated = false; private $map_entry = false; private $has_map_entry = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getMessageSetWireFormat() { return $this->message_set_wire_format; } public function setMessageSetWireFormat($var) { GPBUtil::checkBool($var); $this->message_set_wire_format = $var; $this->has_message_set_wire_format = true; } public function hasMessageSetWireFormat() { return $this->has_message_set_wire_format; } public function getNoStandardDescriptorAccessor() { return $this->no_standard_descriptor_accessor; } public function setNoStandardDescriptorAccessor($var) { GPBUtil::checkBool($var); $this->no_standard_descriptor_accessor = $var; $this->has_no_standard_descriptor_accessor = true; } public function hasNoStandardDescriptorAccessor() { return $this->has_no_standard_descriptor_accessor; } public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getMapEntry() { return $this->map_entry; } public function setMapEntry($var) { GPBUtil::checkBool($var); $this->map_entry = $var; $this->has_map_entry = true; } public function hasMapEntry() { return $this->has_map_entry; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class FieldOptions extends \Google\Protobuf\Internal\Message { private $ctype = 0; private $has_ctype = false; private $packed = false; private $has_packed = false; private $jstype = 0; private $has_jstype = false; private $lazy = false; private $has_lazy = false; private $deprecated = false; private $has_deprecated = false; private $weak = false; private $has_weak = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getCtype() { return $this->ctype; } public function setCtype($var) { GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class); $this->ctype = $var; $this->has_ctype = true; } public function hasCtype() { return $this->has_ctype; } public function getPacked() { return $this->packed; } public function setPacked($var) { GPBUtil::checkBool($var); $this->packed = $var; $this->has_packed = true; } public function hasPacked() { return $this->has_packed; } public function getJstype() { return $this->jstype; } public function setJstype($var) { GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class); $this->jstype = $var; $this->has_jstype = true; } public function hasJstype() { return $this->has_jstype; } public function getLazy() { return $this->lazy; } public function setLazy($var) { GPBUtil::checkBool($var); $this->lazy = $var; $this->has_lazy = true; } public function hasLazy() { return $this->has_lazy; } public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getWeak() { return $this->weak; } public function setWeak($var) { GPBUtil::checkBool($var); $this->weak = $var; $this->has_weak = true; } public function hasWeak() { return $this->has_weak; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class FieldOptions_CType { const STRING = 0; const CORD = 1; const STRING_PIECE = 2; } class FieldOptions_JSType { const JS_NORMAL = 0; const JS_STRING = 1; const JS_NUMBER = 2; } class OneofOptions extends \Google\Protobuf\Internal\Message { private $uninterpreted_option; private $has_uninterpreted_option = false; public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class EnumOptions extends \Google\Protobuf\Internal\Message { private $allow_alias = false; private $has_allow_alias = false; private $deprecated = false; private $has_deprecated = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getAllowAlias() { return $this->allow_alias; } public function setAllowAlias($var) { GPBUtil::checkBool($var); $this->allow_alias = $var; $this->has_allow_alias = true; } public function hasAllowAlias() { return $this->has_allow_alias; } public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class EnumValueOptions extends \Google\Protobuf\Internal\Message { private $deprecated = false; private $has_deprecated = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class ServiceOptions extends \Google\Protobuf\Internal\Message { private $deprecated = false; private $has_deprecated = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class MethodOptions extends \Google\Protobuf\Internal\Message { private $deprecated = false; private $has_deprecated = false; private $uninterpreted_option; private $has_uninterpreted_option = false; public function getDeprecated() { return $this->deprecated; } public function setDeprecated($var) { GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; } public function hasDeprecated() { return $this->has_deprecated; } public function getUninterpretedOption() { return $this->uninterpreted_option; } public function setUninterpretedOption(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $var; $this->has_uninterpreted_option = true; } public function hasUninterpretedOption() { return $this->has_uninterpreted_option; } } class UninterpretedOption extends \Google\Protobuf\Internal\Message { private $name; private $has_name = false; private $identifier_value = ''; private $has_identifier_value = false; private $positive_int_value = 0; private $has_positive_int_value = false; private $negative_int_value = 0; private $has_negative_int_value = false; private $double_value = 0.0; private $has_double_value = false; private $string_value = ''; private $has_string_value = false; private $aggregate_value = ''; private $has_aggregate_value = false; public function getName() { return $this->name; } public function setName(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class); $this->name = $var; $this->has_name = true; } public function hasName() { return $this->has_name; } public function getIdentifierValue() { return $this->identifier_value; } public function setIdentifierValue($var) { GPBUtil::checkString($var, True); $this->identifier_value = $var; $this->has_identifier_value = true; } public function hasIdentifierValue() { return $this->has_identifier_value; } public function getPositiveIntValue() { return $this->positive_int_value; } public function setPositiveIntValue($var) { GPBUtil::checkUint64($var); $this->positive_int_value = $var; $this->has_positive_int_value = true; } public function hasPositiveIntValue() { return $this->has_positive_int_value; } public function getNegativeIntValue() { return $this->negative_int_value; } public function setNegativeIntValue($var) { GPBUtil::checkInt64($var); $this->negative_int_value = $var; $this->has_negative_int_value = true; } public function hasNegativeIntValue() { return $this->has_negative_int_value; } public function getDoubleValue() { return $this->double_value; } public function setDoubleValue($var) { GPBUtil::checkDouble($var); $this->double_value = $var; $this->has_double_value = true; } public function hasDoubleValue() { return $this->has_double_value; } public function getStringValue() { return $this->string_value; } public function setStringValue($var) { GPBUtil::checkString($var, False); $this->string_value = $var; $this->has_string_value = true; } public function hasStringValue() { return $this->has_string_value; } public function getAggregateValue() { return $this->aggregate_value; } public function setAggregateValue($var) { GPBUtil::checkString($var, True); $this->aggregate_value = $var; $this->has_aggregate_value = true; } public function hasAggregateValue() { return $this->has_aggregate_value; } } class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message { private $name_part = ''; private $has_name_part = false; private $is_extension = false; private $has_is_extension = false; public function getNamePart() { return $this->name_part; } public function setNamePart($var) { GPBUtil::checkString($var, True); $this->name_part = $var; $this->has_name_part = true; } public function hasNamePart() { return $this->has_name_part; } public function getIsExtension() { return $this->is_extension; } public function setIsExtension($var) { GPBUtil::checkBool($var); $this->is_extension = $var; $this->has_is_extension = true; } public function hasIsExtension() { return $this->has_is_extension; } } class SourceCodeInfo extends \Google\Protobuf\Internal\Message { private $location; private $has_location = false; public function getLocation() { return $this->location; } public function setLocation(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class); $this->location = $var; $this->has_location = true; } public function hasLocation() { return $this->has_location; } } class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message { private $path; private $has_path = false; private $span; private $has_span = false; private $leading_comments = ''; private $has_leading_comments = false; private $trailing_comments = ''; private $has_trailing_comments = false; private $leading_detached_comments; private $has_leading_detached_comments = false; public function getPath() { return $this->path; } public function setPath(&$var) { GPBUtil::checkRepeatedField($var, GPBType::INT32); $this->path = $var; $this->has_path = true; } public function hasPath() { return $this->has_path; } public function getSpan() { return $this->span; } public function setSpan(&$var) { GPBUtil::checkRepeatedField($var, GPBType::INT32); $this->span = $var; $this->has_span = true; } public function hasSpan() { return $this->has_span; } public function getLeadingComments() { return $this->leading_comments; } public function setLeadingComments($var) { GPBUtil::checkString($var, True); $this->leading_comments = $var; $this->has_leading_comments = true; } public function hasLeadingComments() { return $this->has_leading_comments; } public function getTrailingComments() { return $this->trailing_comments; } public function setTrailingComments($var) { GPBUtil::checkString($var, True); $this->trailing_comments = $var; $this->has_trailing_comments = true; } public function hasTrailingComments() { return $this->has_trailing_comments; } public function getLeadingDetachedComments() { return $this->leading_detached_comments; } public function setLeadingDetachedComments(&$var) { GPBUtil::checkRepeatedField($var, GPBType::STRING); $this->leading_detached_comments = $var; $this->has_leading_detached_comments = true; } public function hasLeadingDetachedComments() { return $this->has_leading_detached_comments; } } class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message { private $annotation; private $has_annotation = false; public function getAnnotation() { return $this->annotation; } public function setAnnotation(&$var) { GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class); $this->annotation = $var; $this->has_annotation = true; } public function hasAnnotation() { return $this->has_annotation; } } class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message { private $path; private $has_path = false; private $source_file = ''; private $has_source_file = false; private $begin = 0; private $has_begin = false; private $end = 0; private $has_end = false; public function getPath() { return $this->path; } public function setPath(&$var) { GPBUtil::checkRepeatedField($var, GPBType::INT32); $this->path = $var; $this->has_path = true; } public function hasPath() { return $this->has_path; } public function getSourceFile() { return $this->source_file; } public function setSourceFile($var) { GPBUtil::checkString($var, True); $this->source_file = $var; $this->has_source_file = true; } public function hasSourceFile() { return $this->has_source_file; } public function getBegin() { return $this->begin; } public function setBegin($var) { GPBUtil::checkInt32($var); $this->begin = $var; $this->has_begin = true; } public function hasBegin() { return $this->has_begin; } public function getEnd() { return $this->end; } public function setEnd($var) { GPBUtil::checkInt32($var); $this->end = $var; $this->has_end = true; } public function hasEnd() { return $this->has_end; } } $pool = DescriptorPool::getGeneratedPool(); $pool->addMessage('google.protobuf.internal.FileDescriptorSet', FileDescriptorSet::class) ->repeated('file', GPBType::MESSAGE, 1, 'google.protobuf.internal.FileDescriptorProto') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.FileDescriptorProto', FileDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->optional('package', GPBType::STRING, 2) ->repeated('dependency', GPBType::STRING, 3) ->repeated('public_dependency', GPBType::INT32, 10) ->repeated('weak_dependency', GPBType::INT32, 11) ->repeated('message_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.DescriptorProto') ->repeated('enum_type', GPBType::MESSAGE, 5, 'google.protobuf.internal.EnumDescriptorProto') ->repeated('service', GPBType::MESSAGE, 6, 'google.protobuf.internal.ServiceDescriptorProto') ->repeated('extension', GPBType::MESSAGE, 7, 'google.protobuf.internal.FieldDescriptorProto') ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FileOptions') ->optional('source_code_info', GPBType::MESSAGE, 9, 'google.protobuf.internal.SourceCodeInfo') ->optional('syntax', GPBType::STRING, 12) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.DescriptorProto', DescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->repeated('field', GPBType::MESSAGE, 2, 'google.protobuf.internal.FieldDescriptorProto') ->repeated('extension', GPBType::MESSAGE, 6, 'google.protobuf.internal.FieldDescriptorProto') ->repeated('nested_type', GPBType::MESSAGE, 3, 'google.protobuf.internal.DescriptorProto') ->repeated('enum_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.EnumDescriptorProto') ->repeated('extension_range', GPBType::MESSAGE, 5, 'google.protobuf.internal.DescriptorProto.ExtensionRange') ->repeated('oneof_decl', GPBType::MESSAGE, 8, 'google.protobuf.internal.OneofDescriptorProto') ->optional('options', GPBType::MESSAGE, 7, 'google.protobuf.internal.MessageOptions') ->repeated('reserved_range', GPBType::MESSAGE, 9, 'google.protobuf.internal.DescriptorProto.ReservedRange') ->repeated('reserved_name', GPBType::STRING, 10) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.DescriptorProto.ExtensionRange', DescriptorProto_ExtensionRange::class) ->optional('start', GPBType::INT32, 1) ->optional('end', GPBType::INT32, 2) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.DescriptorProto.ReservedRange', DescriptorProto_ReservedRange::class) ->optional('start', GPBType::INT32, 1) ->optional('end', GPBType::INT32, 2) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.FieldDescriptorProto', FieldDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->optional('number', GPBType::INT32, 3) ->optional('label', GPBType::ENUM, 4, 'google.protobuf.internal.FieldDescriptorProto.Label') ->optional('type', GPBType::ENUM, 5, 'google.protobuf.internal.FieldDescriptorProto.Type') ->optional('type_name', GPBType::STRING, 6) ->optional('extendee', GPBType::STRING, 2) ->optional('default_value', GPBType::STRING, 7) ->optional('oneof_index', GPBType::INT32, 9) ->optional('json_name', GPBType::STRING, 10) ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions') ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', Type::class) ->value("TYPE_DOUBLE", 1) ->value("TYPE_FLOAT", 2) ->value("TYPE_INT64", 3) ->value("TYPE_UINT64", 4) ->value("TYPE_INT32", 5) ->value("TYPE_FIXED64", 6) ->value("TYPE_FIXED32", 7) ->value("TYPE_BOOL", 8) ->value("TYPE_STRING", 9) ->value("TYPE_GROUP", 10) ->value("TYPE_MESSAGE", 11) ->value("TYPE_BYTES", 12) ->value("TYPE_UINT32", 13) ->value("TYPE_ENUM", 14) ->value("TYPE_SFIXED32", 15) ->value("TYPE_SFIXED64", 16) ->value("TYPE_SINT32", 17) ->value("TYPE_SINT64", 18) ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Label', Label::class) ->value("LABEL_OPTIONAL", 1) ->value("LABEL_REQUIRED", 2) ->value("LABEL_REPEATED", 3) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.OneofDescriptorProto', OneofDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->optional('options', GPBType::MESSAGE, 2, 'google.protobuf.internal.OneofOptions') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.EnumDescriptorProto', EnumDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->repeated('value', GPBType::MESSAGE, 2, 'google.protobuf.internal.EnumValueDescriptorProto') ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumOptions') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.EnumValueDescriptorProto', EnumValueDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->optional('number', GPBType::INT32, 2) ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumValueOptions') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.ServiceDescriptorProto', ServiceDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->repeated('method', GPBType::MESSAGE, 2, 'google.protobuf.internal.MethodDescriptorProto') ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.ServiceOptions') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.MethodDescriptorProto', MethodDescriptorProto::class) ->optional('name', GPBType::STRING, 1) ->optional('input_type', GPBType::STRING, 2) ->optional('output_type', GPBType::STRING, 3) ->optional('options', GPBType::MESSAGE, 4, 'google.protobuf.internal.MethodOptions') ->optional('client_streaming', GPBType::BOOL, 5) ->optional('server_streaming', GPBType::BOOL, 6) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.FileOptions', FileOptions::class) ->optional('java_package', GPBType::STRING, 1) ->optional('java_outer_classname', GPBType::STRING, 8) ->optional('java_multiple_files', GPBType::BOOL, 10) ->optional('java_generate_equals_and_hash', GPBType::BOOL, 20) ->optional('java_string_check_utf8', GPBType::BOOL, 27) ->optional('optimize_for', GPBType::ENUM, 9, 'google.protobuf.internal.FileOptions.OptimizeMode') ->optional('go_package', GPBType::STRING, 11) ->optional('cc_generic_services', GPBType::BOOL, 16) ->optional('java_generic_services', GPBType::BOOL, 17) ->optional('py_generic_services', GPBType::BOOL, 18) ->optional('deprecated', GPBType::BOOL, 23) ->optional('cc_enable_arenas', GPBType::BOOL, 31) ->optional('objc_class_prefix', GPBType::STRING, 36) ->optional('csharp_namespace', GPBType::STRING, 37) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FileOptions.OptimizeMode', OptimizeMode::class) ->value("SPEED", 1) ->value("CODE_SIZE", 2) ->value("LITE_RUNTIME", 3) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.MessageOptions', MessageOptions::class) ->optional('message_set_wire_format', GPBType::BOOL, 1) ->optional('no_standard_descriptor_accessor', GPBType::BOOL, 2) ->optional('deprecated', GPBType::BOOL, 3) ->optional('map_entry', GPBType::BOOL, 7) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.FieldOptions', FieldOptions::class) ->optional('ctype', GPBType::ENUM, 1, 'google.protobuf.internal.FieldOptions.CType') ->optional('packed', GPBType::BOOL, 2) ->optional('jstype', GPBType::ENUM, 6, 'google.protobuf.internal.FieldOptions.JSType') ->optional('lazy', GPBType::BOOL, 5) ->optional('deprecated', GPBType::BOOL, 3) ->optional('weak', GPBType::BOOL, 10) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FieldOptions.CType', CType::class) ->value("STRING", 0) ->value("CORD", 1) ->value("STRING_PIECE", 2) ->finalizeToPool(); $pool->addEnum('google.protobuf.internal.FieldOptions.JSType', JSType::class) ->value("JS_NORMAL", 0) ->value("JS_STRING", 1) ->value("JS_NUMBER", 2) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.OneofOptions', OneofOptions::class) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.EnumOptions', EnumOptions::class) ->optional('allow_alias', GPBType::BOOL, 2) ->optional('deprecated', GPBType::BOOL, 3) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.EnumValueOptions', EnumValueOptions::class) ->optional('deprecated', GPBType::BOOL, 1) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.ServiceOptions', ServiceOptions::class) ->optional('deprecated', GPBType::BOOL, 33) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.MethodOptions', MethodOptions::class) ->optional('deprecated', GPBType::BOOL, 33) ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.UninterpretedOption', UninterpretedOption::class) ->repeated('name', GPBType::MESSAGE, 2, 'google.protobuf.internal.UninterpretedOption.NamePart') ->optional('identifier_value', GPBType::STRING, 3) ->optional('positive_int_value', GPBType::UINT64, 4) ->optional('negative_int_value', GPBType::INT64, 5) ->optional('double_value', GPBType::DOUBLE, 6) ->optional('string_value', GPBType::BYTES, 7) ->optional('aggregate_value', GPBType::STRING, 8) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.UninterpretedOption.NamePart', UninterpretedOption_NamePart::class) ->required('name_part', GPBType::STRING, 1) ->required('is_extension', GPBType::BOOL, 2) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.SourceCodeInfo', SourceCodeInfo::class) ->repeated('location', GPBType::MESSAGE, 1, 'google.protobuf.internal.SourceCodeInfo.Location') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.SourceCodeInfo.Location', SourceCodeInfo_Location::class) ->repeated('path', GPBType::INT32, 1) ->repeated('span', GPBType::INT32, 2) ->optional('leading_comments', GPBType::STRING, 3) ->optional('trailing_comments', GPBType::STRING, 4) ->repeated('leading_detached_comments', GPBType::STRING, 6) ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo', GeneratedCodeInfo::class) ->repeated('annotation', GPBType::MESSAGE, 1, 'google.protobuf.internal.GeneratedCodeInfo.Annotation') ->finalizeToPool(); $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo.Annotation', GeneratedCodeInfo_Annotation::class) ->repeated('path', GPBType::INT32, 1) ->optional('source_file', GPBType::STRING, 2) ->optional('begin', GPBType::INT32, 3) ->optional('end', GPBType::INT32, 4) ->finalizeToPool(); $pool->finish(); src/phpdoc.dist.xml000064400000000624146412221520010275 0ustar00 doc doc Google/Protobuf/Internal/MapField.php Google/Protobuf/Internal/Message.php Google/Protobuf/Internal/RepeatedField.php