aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google
diff options
context:
space:
mode:
Diffstat (limited to 'php/src/Google')
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php16
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php16
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php16
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php16
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php16
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions_CType.php16
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions_JSType.php16
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php16
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php11
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php16
-rw-r--r--php/src/Google/Protobuf/Internal/MapField.php31
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php12
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php16
-rw-r--r--php/src/Google/Protobuf/Internal/RepeatedField.php10
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php16
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php16
-rw-r--r--php/src/Google/Protobuf/Timestamp.php9
17 files changed, 234 insertions, 31 deletions
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php
new file mode 100644
index 00000000..c928fbe5
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\DescriptorProto\ExtensionRange instead.
+ * @deprecated
+ */
+ class DescriptorProto_ExtensionRange {}
+}
+class_exists(DescriptorProto\ExtensionRange::class);
+@trigger_error('Google\Protobuf\Internal\DescriptorProto_ExtensionRange is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\DescriptorProto\ExtensionRange instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php
new file mode 100644
index 00000000..e49e945f
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\DescriptorProto\ReservedRange instead.
+ * @deprecated
+ */
+ class DescriptorProto_ReservedRange {}
+}
+class_exists(DescriptorProto\ReservedRange::class);
+@trigger_error('Google\Protobuf\Internal\DescriptorProto_ReservedRange is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\DescriptorProto\ReservedRange instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php
new file mode 100644
index 00000000..b1b59ed9
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto_EnumReservedRange.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange instead.
+ * @deprecated
+ */
+ class EnumDescriptorProto_EnumReservedRange {}
+}
+class_exists(EnumDescriptorProto\EnumReservedRange::class);
+@trigger_error('Google\Protobuf\Internal\EnumDescriptorProto_EnumReservedRange is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\EnumDescriptorProto\EnumReservedRange instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php
new file mode 100644
index 00000000..218a846e
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\FieldDescriptorProto\Label instead.
+ * @deprecated
+ */
+ class FieldDescriptorProto_Label {}
+}
+class_exists(FieldDescriptorProto\Label::class);
+@trigger_error('Google\Protobuf\Internal\FieldDescriptorProto_Label is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\FieldDescriptorProto\Label instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php
new file mode 100644
index 00000000..fd8d449a
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\FieldDescriptorProto\Type instead.
+ * @deprecated
+ */
+ class FieldDescriptorProto_Type {}
+}
+class_exists(FieldDescriptorProto\Type::class);
+@trigger_error('Google\Protobuf\Internal\FieldDescriptorProto_Type is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\FieldDescriptorProto\Type instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_CType.php b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php
new file mode 100644
index 00000000..4d18783e
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\FieldOptions\CType instead.
+ * @deprecated
+ */
+ class FieldOptions_CType {}
+}
+class_exists(FieldOptions\CType::class);
+@trigger_error('Google\Protobuf\Internal\FieldOptions_CType is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\FieldOptions\CType instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php
new file mode 100644
index 00000000..9db07822
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\FieldOptions\JSType instead.
+ * @deprecated
+ */
+ class FieldOptions_JSType {}
+}
+class_exists(FieldOptions\JSType::class);
+@trigger_error('Google\Protobuf\Internal\FieldOptions_JSType is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\FieldOptions\JSType instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php
new file mode 100644
index 00000000..8926e63b
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\FileOptions\OptimizeMode instead.
+ * @deprecated
+ */
+ class FileOptions_OptimizeMode {}
+}
+class_exists(FileOptions\OptimizeMode::class);
+@trigger_error('Google\Protobuf\Internal\FileOptions_OptimizeMode is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\FileOptions\OptimizeMode instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index b75d9bab..7b5cc7d1 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -305,11 +305,8 @@ class GPBUtil
$name,
$file_proto)
{
- $parts = explode('.', $name);
- foreach ($parts as $i => $part) {
- $parts[$i] = static::getClassNamePrefix($parts[$i], $file_proto) . $parts[$i];
- }
- return implode('\\', $parts);
+ $classname = implode('_', explode('.', $name));
+ return static::getClassNamePrefix($classname, $file_proto) . $classname;
}
public static function getClassNameWithoutPackage(
@@ -441,8 +438,8 @@ class GPBUtil
$nanoseconds = intval($nanoseconds);
// remove the nanoseconds and preceding period from the timestamp
- $date = substr($timestamp, 0, $periodIndex - 1);
- $timezone = substr($timestamp, $periodIndex + $nanosecondsLength);
+ $date = substr($timestamp, 0, $periodIndex);
+ $timezone = substr($timestamp, $periodIndex + $nanosecondsLength + 1);
$timestamp = $date.$timezone;
}
}
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
new file mode 100644
index 00000000..e36f1e57
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\GeneratedCodeInfo\Annotation instead.
+ * @deprecated
+ */
+ class GeneratedCodeInfo_Annotation {}
+}
+class_exists(GeneratedCodeInfo\Annotation::class);
+@trigger_error('Google\Protobuf\Internal\GeneratedCodeInfo_Annotation is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\GeneratedCodeInfo\Annotation instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php
index f7d7b710..1b2b0cf0 100644
--- a/php/src/Google/Protobuf/Internal/MapField.php
+++ b/php/src/Google/Protobuf/Internal/MapField.php
@@ -156,15 +156,22 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
$this->checkKey($this->key_type, $key);
switch ($this->value_type) {
+ case GPBType::SFIXED32:
+ case GPBType::SINT32:
case GPBType::INT32:
+ case GPBType::ENUM:
GPBUtil::checkInt32($value);
break;
+ case GPBType::FIXED32:
case GPBType::UINT32:
GPBUtil::checkUint32($value);
break;
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
case GPBType::INT64:
GPBUtil::checkInt64($value);
break;
+ case GPBType::FIXED64:
case GPBType::UINT64:
GPBUtil::checkUint64($value);
break;
@@ -249,36 +256,24 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
private function checkKey($key_type, &$key)
{
switch ($key_type) {
+ case GPBType::SFIXED32:
+ case GPBType::SINT32:
case GPBType::INT32:
GPBUtil::checkInt32($key);
break;
+ case GPBType::FIXED32:
case GPBType::UINT32:
GPBUtil::checkUint32($key);
break;
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
case GPBType::INT64:
GPBUtil::checkInt64($key);
break;
- case GPBType::UINT64:
- GPBUtil::checkUint64($key);
- break;
case GPBType::FIXED64:
+ case GPBType::UINT64:
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;
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index 8ff141ca..147aaab8 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -1157,9 +1157,17 @@ class Message
public function parseFromJsonStream($input)
{
$array = json_decode($input->getData(), true, 512, JSON_BIGINT_AS_STRING);
+ if ($this instanceof \Google\Protobuf\ListValue) {
+ $array = ["values"=>$array];
+ }
if (is_null($array)) {
- throw new GPBDecodeException(
- "Cannot decode json string.");
+ if ($this instanceof \Google\Protobuf\Value) {
+ $this->setNullValue(\Google\Protobuf\NullValue::NULL_VALUE);
+ return;
+ } else {
+ throw new GPBDecodeException(
+ "Cannot decode json string: " . $input->getData());
+ }
}
try {
$this->mergeFromJsonArray($array);
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php
new file mode 100644
index 00000000..a2913114
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\MethodOptions\IdempotencyLevel instead.
+ * @deprecated
+ */
+ class MethodOptions_IdempotencyLevel {}
+}
+class_exists(MethodOptions\IdempotencyLevel::class);
+@trigger_error('Google\Protobuf\Internal\MethodOptions_IdempotencyLevel is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\MethodOptions\IdempotencyLevel instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/RepeatedField.php b/php/src/Google/Protobuf/Internal/RepeatedField.php
index e0ddef50..e9b92d8d 100644
--- a/php/src/Google/Protobuf/Internal/RepeatedField.php
+++ b/php/src/Google/Protobuf/Internal/RepeatedField.php
@@ -141,15 +141,22 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
public function offsetSet($offset, $value)
{
switch ($this->type) {
+ case GPBType::SFIXED32:
+ case GPBType::SINT32:
case GPBType::INT32:
+ case GPBType::ENUM:
GPBUtil::checkInt32($value);
break;
+ case GPBType::FIXED32:
case GPBType::UINT32:
GPBUtil::checkUint32($value);
break;
+ case GPBType::SFIXED64:
+ case GPBType::SINT64:
case GPBType::INT64:
GPBUtil::checkInt64($value);
break;
+ case GPBType::FIXED64:
case GPBType::UINT64:
GPBUtil::checkUint64($value);
break;
@@ -162,6 +169,9 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
case GPBType::BOOL:
GPBUtil::checkBool($value);
break;
+ case GPBType::BYTES:
+ GPBUtil::checkString($value, false);
+ break;
case GPBType::STRING:
GPBUtil::checkString($value, true);
break;
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
new file mode 100644
index 00000000..1346492d
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\SourceCodeInfo\Location instead.
+ * @deprecated
+ */
+ class SourceCodeInfo_Location {}
+}
+class_exists(SourceCodeInfo\Location::class);
+@trigger_error('Google\Protobuf\Internal\SourceCodeInfo_Location is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\SourceCodeInfo\Location instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
new file mode 100644
index 00000000..9750eb01
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
@@ -0,0 +1,16 @@
+<?php
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: google/protobuf/descriptor.proto
+
+namespace Google\Protobuf\Internal;
+
+if (false) {
+ /**
+ * This class is deprecated. Use Google\Protobuf\Internal\UninterpretedOption\NamePart instead.
+ * @deprecated
+ */
+ class UninterpretedOption_NamePart {}
+}
+class_exists(UninterpretedOption\NamePart::class);
+@trigger_error('Google\Protobuf\Internal\UninterpretedOption_NamePart is deprecated and will be removed in the next major release. Use Google\Protobuf\Internal\UninterpretedOption\NamePart instead', E_USER_DEPRECATED);
+
diff --git a/php/src/Google/Protobuf/Timestamp.php b/php/src/Google/Protobuf/Timestamp.php
index a793c7e3..6d26f6c5 100644
--- a/php/src/Google/Protobuf/Timestamp.php
+++ b/php/src/Google/Protobuf/Timestamp.php
@@ -182,18 +182,19 @@ class Timestamp extends \Google\Protobuf\Internal\Message
*/
public function fromDateTime(\DateTime $datetime)
{
- $this->seconds = $datetime->format('U');
- $this->nanos = 0;
+ $this->seconds = $datetime->getTimestamp();
+ $this->nanos = 1000 * $datetime->format('u');
}
/**
- * Converts Timestamp to PHP DateTime. Nano second is ignored.
+ * Converts Timestamp to PHP DateTime.
*
* @return \DateTime $datetime
*/
public function toDateTime()
{
- return \DateTime::createFromFormat('U', $this->seconds);
+ $time = sprintf('%s.%06d', $this->seconds, $this->nanos / 1000);
+ return \DateTime::createFromFormat('U.u', $time);
}
}