From 83ea4c147718666ce6a9b9332ac2aa588c9211eb Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 9 Jan 2024 22:12:32 +0000 Subject: [PATCH 1/4] 3.25.2 sync From d8240e8cb95efc80a97823dccbf8e949d24ad710 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 25 Jan 2024 15:48:59 +0000 Subject: [PATCH 2/4] 4.26.0RC1 sync --- src/Google/Protobuf/Internal/Message.php | 52 +++++++++++++++++++ .../Protobuf/Internal/RepeatedField.php | 13 +++++ 2 files changed, 65 insertions(+) diff --git a/src/Google/Protobuf/Internal/Message.php b/src/Google/Protobuf/Internal/Message.php index 578e606..a427e48 100644 --- a/src/Google/Protobuf/Internal/Message.php +++ b/src/Google/Protobuf/Internal/Message.php @@ -2014,4 +2014,56 @@ public function jsonByteSize() } return $size; } + + public function __debugInfo() + { + if (is_a($this, 'Google\Protobuf\FieldMask')) { + return ['paths' => $this->getPaths()->__debugInfo()]; + } + + if (is_a($this, 'Google\Protobuf\Value')) { + switch ($this->getKind()) { + case 'null_value': + return ['nullValue' => $this->getNullValue()]; + case 'number_value': + return ['numberValue' => $this->getNumberValue()]; + case 'string_value': + return ['stringValue' => $this->getStringValue()]; + case 'bool_value': + return ['boolValue' => $this->getBoolValue()]; + case 'struct_value': + return ['structValue' => $this->getStructValue()->__debugInfo()]; + case 'list_value': + return ['listValue' => $this->getListValue()->__debugInfo()]; + } + return []; + } + + if (is_a($this, 'Google\Protobuf\BoolValue') + || is_a($this, 'Google\Protobuf\BytesValue') + || is_a($this, 'Google\Protobuf\DoubleValue') + || is_a($this, 'Google\Protobuf\FloatValue') + || is_a($this, 'Google\Protobuf\StringValue') + || is_a($this, 'Google\Protobuf\Int32Value') + || is_a($this, 'Google\Protobuf\Int64Value') + || is_a($this, 'Google\Protobuf\UInt32Value') + || is_a($this, 'Google\Protobuf\UInt64Value') + ) { + return [ + 'value' => json_decode($this->serializeToJsonString(), true), + ]; + } + + if ( + is_a($this, 'Google\Protobuf\Duration') + || is_a($this, 'Google\Protobuf\Timestamp') + ) { + return [ + 'seconds' => $this->getSeconds(), + 'nanos' => $this->getNanos(), + ]; + } + + return json_decode($this->serializeToJsonString(), true); + } } diff --git a/src/Google/Protobuf/Internal/RepeatedField.php b/src/Google/Protobuf/Internal/RepeatedField.php index 8f56863..3d9e66d 100644 --- a/src/Google/Protobuf/Internal/RepeatedField.php +++ b/src/Google/Protobuf/Internal/RepeatedField.php @@ -238,4 +238,17 @@ public function count(): int { return count($this->container); } + + public function __debugInfo() + { + return array_map( + function ($item) { + if ($item instanceof Message || $item instanceof RepeatedField) { + return $item->__debugInfo(); + } + return $item; + }, + iterator_to_array($this) + ); + } } From ef037c44f44fb0b7b39807ecdcceb33213d0ab21 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 6 Feb 2024 18:54:43 +0000 Subject: [PATCH 3/4] 4.26.0RC2 sync --- src/Google/Protobuf/Internal/GPBUtil.php | 4 ++++ src/Google/Protobuf/Internal/Message.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Google/Protobuf/Internal/GPBUtil.php b/src/Google/Protobuf/Internal/GPBUtil.php index cac2a4a..4c1fadc 100644 --- a/src/Google/Protobuf/Internal/GPBUtil.php +++ b/src/Google/Protobuf/Internal/GPBUtil.php @@ -462,6 +462,10 @@ public static function parseTimestamp($timestamp) $nanoseconds = substr($timestamp, $periodIndex + 1, $nanosecondsLength); $nanoseconds = intval($nanoseconds); + if ($nanosecondsLength < 9) { + $nanoseconds = $nanoseconds * pow(10, 9 - $nanosecondsLength); + } + // remove the nanoseconds and preceding period from the timestamp $date = substr($timestamp, 0, $periodIndex); $timezone = substr($timestamp, $periodIndex + $nanosecondsLength + 1); diff --git a/src/Google/Protobuf/Internal/Message.php b/src/Google/Protobuf/Internal/Message.php index a427e48..21d9c98 100644 --- a/src/Google/Protobuf/Internal/Message.php +++ b/src/Google/Protobuf/Internal/Message.php @@ -1314,7 +1314,7 @@ public function parseFromJsonStream($input, $ignore_unknown) try { $this->mergeFromJsonArray($array, $ignore_unknown); } catch (\Exception $e) { - throw new GPBDecodeException($e->getMessage()); + throw new GPBDecodeException($e->getMessage(), $e->getCode(), $e); } } From 983a87f4f8798a90ca3a25b0f300b8fda38df643 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 15 Feb 2024 21:11:49 +0000 Subject: [PATCH 4/4] 3.25.3 sync --- src/Google/Protobuf/Internal/GPBUtil.php | 4 -- src/Google/Protobuf/Internal/Message.php | 54 +------------------ .../Protobuf/Internal/RepeatedField.php | 13 ----- 3 files changed, 1 insertion(+), 70 deletions(-) diff --git a/src/Google/Protobuf/Internal/GPBUtil.php b/src/Google/Protobuf/Internal/GPBUtil.php index 4c1fadc..cac2a4a 100644 --- a/src/Google/Protobuf/Internal/GPBUtil.php +++ b/src/Google/Protobuf/Internal/GPBUtil.php @@ -462,10 +462,6 @@ public static function parseTimestamp($timestamp) $nanoseconds = substr($timestamp, $periodIndex + 1, $nanosecondsLength); $nanoseconds = intval($nanoseconds); - if ($nanosecondsLength < 9) { - $nanoseconds = $nanoseconds * pow(10, 9 - $nanosecondsLength); - } - // remove the nanoseconds and preceding period from the timestamp $date = substr($timestamp, 0, $periodIndex); $timezone = substr($timestamp, $periodIndex + $nanosecondsLength + 1); diff --git a/src/Google/Protobuf/Internal/Message.php b/src/Google/Protobuf/Internal/Message.php index 21d9c98..578e606 100644 --- a/src/Google/Protobuf/Internal/Message.php +++ b/src/Google/Protobuf/Internal/Message.php @@ -1314,7 +1314,7 @@ public function parseFromJsonStream($input, $ignore_unknown) try { $this->mergeFromJsonArray($array, $ignore_unknown); } catch (\Exception $e) { - throw new GPBDecodeException($e->getMessage(), $e->getCode(), $e); + throw new GPBDecodeException($e->getMessage()); } } @@ -2014,56 +2014,4 @@ public function jsonByteSize() } return $size; } - - public function __debugInfo() - { - if (is_a($this, 'Google\Protobuf\FieldMask')) { - return ['paths' => $this->getPaths()->__debugInfo()]; - } - - if (is_a($this, 'Google\Protobuf\Value')) { - switch ($this->getKind()) { - case 'null_value': - return ['nullValue' => $this->getNullValue()]; - case 'number_value': - return ['numberValue' => $this->getNumberValue()]; - case 'string_value': - return ['stringValue' => $this->getStringValue()]; - case 'bool_value': - return ['boolValue' => $this->getBoolValue()]; - case 'struct_value': - return ['structValue' => $this->getStructValue()->__debugInfo()]; - case 'list_value': - return ['listValue' => $this->getListValue()->__debugInfo()]; - } - return []; - } - - if (is_a($this, 'Google\Protobuf\BoolValue') - || is_a($this, 'Google\Protobuf\BytesValue') - || is_a($this, 'Google\Protobuf\DoubleValue') - || is_a($this, 'Google\Protobuf\FloatValue') - || is_a($this, 'Google\Protobuf\StringValue') - || is_a($this, 'Google\Protobuf\Int32Value') - || is_a($this, 'Google\Protobuf\Int64Value') - || is_a($this, 'Google\Protobuf\UInt32Value') - || is_a($this, 'Google\Protobuf\UInt64Value') - ) { - return [ - 'value' => json_decode($this->serializeToJsonString(), true), - ]; - } - - if ( - is_a($this, 'Google\Protobuf\Duration') - || is_a($this, 'Google\Protobuf\Timestamp') - ) { - return [ - 'seconds' => $this->getSeconds(), - 'nanos' => $this->getNanos(), - ]; - } - - return json_decode($this->serializeToJsonString(), true); - } } diff --git a/src/Google/Protobuf/Internal/RepeatedField.php b/src/Google/Protobuf/Internal/RepeatedField.php index 3d9e66d..8f56863 100644 --- a/src/Google/Protobuf/Internal/RepeatedField.php +++ b/src/Google/Protobuf/Internal/RepeatedField.php @@ -238,17 +238,4 @@ public function count(): int { return count($this->container); } - - public function __debugInfo() - { - return array_map( - function ($item) { - if ($item instanceof Message || $item instanceof RepeatedField) { - return $item->__debugInfo(); - } - return $item; - }, - iterator_to_array($this) - ); - } }