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) - ); - } }