Skip to content

Commit b760544

Browse files
committed
v3.13.0.1
1 parent ee8f63b commit b760544

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1486
-1197
lines changed

src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GPBMetadata/Google/Protobuf/Struct.php

+2-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Google/Protobuf/Any.php

+7-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Google/Protobuf/Descriptor.php

+8
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,12 @@ public function getOneofDeclCount()
9797
{
9898
return count($this->internal_desc->getOneofDecl());
9999
}
100+
101+
/**
102+
* @return int Number of real oneofs in message
103+
*/
104+
public function getRealOneofDeclCount()
105+
{
106+
return $this->internal_desc->getRealOneofDeclCount();
107+
}
100108
}

src/Google/Protobuf/FieldDescriptor.php

+8
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,12 @@ public function isMap()
114114
{
115115
return $this->internal_desc->isMap();
116116
}
117+
118+
/**
119+
* @return boolean
120+
*/
121+
public function hasOptionalKeyword()
122+
{
123+
return $this->internal_desc->hasOptionalKeyword();
124+
}
117125
}

src/Google/Protobuf/Internal/CodedInputStream.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function readVarintSizeAsInt(&$var)
220220
}
221221

222222
/**
223-
* Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes,
223+
* Read 32-bit unsigned integer to $var. If the buffer has less than 4 bytes,
224224
* return false. Advance buffer with consumed bytes.
225225
* @param $var.
226226
*/
@@ -236,7 +236,7 @@ public function readLittleEndian32(&$var)
236236
}
237237

238238
/**
239-
* Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes,
239+
* Read 64-bit unsigned integer to $var. If the buffer has less than 8 bytes,
240240
* return false. Advance buffer with consumed bytes.
241241
* @param $var.
242242
*/
@@ -283,7 +283,7 @@ public function readTag()
283283
}
284284

285285
$result = 0;
286-
// The larget tag is 2^29 - 1, which can be represented by int32.
286+
// The largest tag is 2^29 - 1, which can be represented by int32.
287287
$success = $this->readVarint32($result);
288288
if ($success) {
289289
return $result;
@@ -299,8 +299,12 @@ public function readRaw($size, &$buffer)
299299
return false;
300300
}
301301

302-
$buffer = substr($this->buffer, $this->current, $size);
303-
$this->advance($size);
302+
if ($size === 0) {
303+
$buffer = "";
304+
} else {
305+
$buffer = substr($this->buffer, $this->current, $size);
306+
$this->advance($size);
307+
}
304308

305309
return true;
306310
}

src/Google/Protobuf/Internal/Descriptor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ public static function buildFromProto($proto, $file_proto, $containing)
185185
$containing,
186186
$file_proto,
187187
$message_name_without_package,
188-
$legacy_classname,
189188
$classname,
189+
$legacy_classname,
190190
$fullname);
191191
$desc->setFullName($fullname);
192192
$desc->setClass($classname);

src/Google/Protobuf/Internal/DescriptorPool.php

+29-15
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,29 @@ public static function getGeneratedPool()
5555
return self::$pool;
5656
}
5757

58-
public function internalAddGeneratedFile($data)
58+
public function internalAddGeneratedFile($data, $use_nested = false)
5959
{
6060
$files = new FileDescriptorSet();
6161
$files->mergeFromString($data);
62-
$file = FileDescriptor::buildFromProto($files->getFile()[0]);
6362

64-
foreach ($file->getMessageType() as $desc) {
65-
$this->addDescriptor($desc);
66-
}
67-
unset($desc);
63+
foreach($files->getFile() as $file_proto) {
64+
$file = FileDescriptor::buildFromProto($file_proto);
6865

69-
foreach ($file->getEnumType() as $desc) {
70-
$this->addEnumDescriptor($desc);
71-
}
72-
unset($desc);
66+
foreach ($file->getMessageType() as $desc) {
67+
$this->addDescriptor($desc);
68+
}
69+
unset($desc);
7370

74-
foreach ($file->getMessageType() as $desc) {
75-
$this->crossLink($desc);
71+
foreach ($file->getEnumType() as $desc) {
72+
$this->addEnumDescriptor($desc);
73+
}
74+
unset($desc);
75+
76+
foreach ($file->getMessageType() as $desc) {
77+
$this->crossLink($desc);
78+
}
79+
unset($desc);
7680
}
77-
unset($desc);
7881
}
7982

8083
public function addMessage($name, $klass)
@@ -149,11 +152,22 @@ private function crossLink(Descriptor $desc)
149152
switch ($field->getType()) {
150153
case GPBType::MESSAGE:
151154
$proto = $field->getMessageType();
152-
$field->setMessageType(
153-
$this->getDescriptorByProtoName($proto));
155+
if ($proto[0] == '.') {
156+
$proto = substr($proto, 1);
157+
}
158+
$subdesc = $this->getDescriptorByProtoName($proto);
159+
if (is_null($subdesc)) {
160+
trigger_error(
161+
'proto not added: ' . $proto
162+
. " for " . $desc->getFullName(), E_ERROR);
163+
}
164+
$field->setMessageType($subdesc);
154165
break;
155166
case GPBType::ENUM:
156167
$proto = $field->getEnumType();
168+
if ($proto[0] == '.') {
169+
$proto = substr($proto, 1);
170+
}
157171
$field->setEnumType(
158172
$this->getEnumDescriptorByProtoName($proto));
159173
break;

0 commit comments

Comments
 (0)