aboutsummaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2019-06-21 20:31:00 +0000
committerBo Yang <teboring@google.com>2019-06-21 20:31:00 +0000
commitd581c76063e3a4cf468febda2ce8221418f0b813 (patch)
tree03891c75b30d569e0e4dd4b7a3f8fc5e68119e64 /php
parent1f0d8172da990a05811ce975afd2d68948eeeb60 (diff)
parent54288a01cebfd0bfa62ca581dd07ffd6f9c77f2c (diff)
downloadplatform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.tar.gz
platform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.tar.bz2
platform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.zip
Merge branch 'master' into 3.9.x
Conflicts: java/lite/pom.xml java/util/pom.xml
Diffstat (limited to 'php')
-rw-r--r--php/ext/google/protobuf/upb.c41
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptor.php15
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorSet.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php26
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MessageOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php2
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption.php2
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php2
-rw-r--r--php/tests/proto/test_wrapper_type_setters.proto11
-rw-r--r--php/tests/wrapper_type_setters_test.php142
32 files changed, 139 insertions, 150 deletions
diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c
index 1d977437f..cc5a54ab8 100644
--- a/php/ext/google/protobuf/upb.c
+++ b/php/ext/google/protobuf/upb.c
@@ -12431,18 +12431,32 @@ static size_t fmt_bool(bool val, char* buf, size_t length) {
return n;
}
-static size_t fmt_int64(long val, char* buf, size_t length) {
- size_t n = _upb_snprintf(buf, length, "%ld", val);
+static size_t fmt_int64_as_number(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "%lld", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
-static size_t fmt_uint64(unsigned long long val, char* buf, size_t length) {
+static size_t fmt_uint64_as_number(
+ unsigned long long val, char* buf, size_t length) {
size_t n = _upb_snprintf(buf, length, "%llu", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
+static size_t fmt_int64_as_string(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%lld\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
+static size_t fmt_uint64_as_string(
+ unsigned long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%llu\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
/* Print a map key given a field name. Called by scalar field handlers and by
* startseq for repeated fields. */
static bool putkey(void *closure, const void *handler_data) {
@@ -12486,8 +12500,11 @@ static bool putkey(void *closure, const void *handler_data) {
static bool putmapkey_##type(void *closure, const void *handler_data, \
type val) { \
upb_json_printer *p = closure; \
+ char data[64]; \
+ size_t length = fmt_func(val, data, sizeof(data)); \
+ UPB_UNUSED(handler_data); \
print_data(p, "\"", 1); \
- CHK(put##type(closure, handler_data, val)); \
+ print_data(p, data, length); \
print_data(p, "\":", 2); \
return true; \
}
@@ -12495,17 +12512,17 @@ static bool putkey(void *closure, const void *handler_data) {
TYPE_HANDLERS(double, fmt_double)
TYPE_HANDLERS(float, fmt_float)
TYPE_HANDLERS(bool, fmt_bool)
-TYPE_HANDLERS(int32_t, fmt_int64)
-TYPE_HANDLERS(uint32_t, fmt_int64)
-TYPE_HANDLERS(int64_t, fmt_int64)
-TYPE_HANDLERS(uint64_t, fmt_uint64)
+TYPE_HANDLERS(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS(int64_t, fmt_int64_as_string)
+TYPE_HANDLERS(uint64_t, fmt_uint64_as_string)
/* double and float are not allowed to be map keys. */
TYPE_HANDLERS_MAPKEY(bool, fmt_bool)
-TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64)
+TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64_as_number)
#undef TYPE_HANDLERS
#undef TYPE_HANDLERS_MAPKEY
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index 3b215d52a..2d5283145 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto</code>
*/
-class DescriptorProto extends \Google\Protobuf\Internal\Message
+final class DescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
index a2057fd5d..fb98f7d5a 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ExtensionRange</code>
*/
-class ExtensionRange extends \Google\Protobuf\Internal\Message
+final class ExtensionRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
index 73c964faa..fa46419a5 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ReservedRange</code>
*/
-class ReservedRange extends \Google\Protobuf\Internal\Message
+final class ReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
index 82a427670..7af4f8401 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
@@ -39,17 +39,26 @@ class EnumDescriptor
public function getValueByNumber($number)
{
- return $this->value[$number];
+ if (isset($this->value[$number])) {
+ return $this->value[$number];
+ }
+ return null;
}
public function getValueByName($name)
{
- return $this->name_to_value[$name];
+ if (isset($this->name_to_value[$name])) {
+ return $this->name_to_value[$name];
+ }
+ return null;
}
public function getValueDescriptorByIndex($index)
{
- return $this->value_descriptor[$index];
+ if (isset($this->value_descriptor[$index])) {
+ return $this->value_descriptor[$index];
+ }
+ return null;
}
public function getValueCount()
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index da30fa990..b7c3a208b 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto</code>
*/
-class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
index e1079585e..0103a1b30 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto.EnumReservedRange</code>
*/
-class EnumReservedRange extends \Google\Protobuf\Internal\Message
+final class EnumReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
index 3d74c81c2..4c73d5274 100644
--- a/php/src/Google/Protobuf/Internal/EnumOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumOptions</code>
*/
-class EnumOptions extends \Google\Protobuf\Internal\Message
+final class EnumOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set this option to true to allow mapping different tag names to the same
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 50bda008e..d5a0a9afb 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumValueDescriptorProto</code>
*/
-class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
index a267c6d5e..50ac904ff 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumValueOptions</code>
*/
-class EnumValueOptions extends \Google\Protobuf\Internal\Message
+final class EnumValueOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this enum value deprecated?
diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
index 00fbebeca..97ad2c055 100644
--- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
+++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ExtensionRangeOptions</code>
*/
-class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
+final class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
{
/**
* The parser stores options it doesn't recognize here. See above.
diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
index e57819751..6f8643c8d 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FieldDescriptorProto</code>
*/
-class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
index 751c278d7..47d1951d1 100644
--- a/php/src/Google/Protobuf/Internal/FieldOptions.php
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FieldOptions</code>
*/
-class FieldOptions extends \Google\Protobuf\Internal\Message
+final class FieldOptions extends \Google\Protobuf\Internal\Message
{
/**
* The ctype option instructs the C++ code generator to use a different
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index cb10aa793..e95205476 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorProto</code>
*/
-class FileDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* file name, relative to root of source tree
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
index 9907b17d7..c9a38808f 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorSet</code>
*/
-class FileDescriptorSet extends \Google\Protobuf\Internal\Message
+final class FileDescriptorSet extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
index 6fea195ec..911000501 100644
--- a/php/src/Google/Protobuf/Internal/FileOptions.php
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FileOptions</code>
*/
-class FileOptions extends \Google\Protobuf\Internal\Message
+final class FileOptions extends \Google\Protobuf\Internal\Message
{
/**
* Sets the Java package where classes generated from this .proto will be
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 0beedba33..7ec3ca229 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -504,17 +504,29 @@ class GPBUtil
public static function formatDuration($value)
{
- if (bccomp($value->getSeconds(), "315576000001") != -1) {
- throw new GPBDecodeException("Duration number too large.");
+ if (bccomp($value->getSeconds(), '315576000001') != -1) {
+ throw new GPBDecodeException('Duration number too large.');
}
- if (bccomp($value->getSeconds(), "-315576000001") != 1) {
- throw new GPBDecodeException("Duration number too small.");
+ if (bccomp($value->getSeconds(), '-315576000001') != 1) {
+ throw new GPBDecodeException('Duration number too small.');
+ }
+
+ $nanos = $value->getNanos();
+ if ($nanos === 0) {
+ return (string) $value->getSeconds();
}
- return strval(bcadd($value->getSeconds(),
- $value->getNanos() / 1000000000.0, 9));
- }
+ if ($nanos % 1000000 === 0) {
+ $digits = 3;
+ } elseif ($nanos % 1000 === 0) {
+ $digits = 6;
+ } else {
+ $digits = 9;
+ }
+ $nanos = bcdiv($nanos, '1000000000', $digits);
+ return bcadd($value->getSeconds(), $nanos, $digits);
+ }
public static function parseFieldMask($paths_string)
{
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index f5a65bea4..c99d77afa 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo</code>
*/
-class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
+final class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* An Annotation connects some span of text in generated code to an element
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
index 09f958d25..8cc3cdf45 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo.Annotation</code>
*/
-class Annotation extends \Google\Protobuf\Internal\Message
+final class Annotation extends \Google\Protobuf\Internal\Message
{
/**
* Identifies the element in the original source .proto file. This field
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 445394211..9032c97e9 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MessageOptions</code>
*/
-class MessageOptions extends \Google\Protobuf\Internal\Message
+final class MessageOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set true to use the old proto1 MessageSet wire format for extensions.
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index 1bd5dd3e1..25a2c166f 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.MethodDescriptorProto</code>
*/
-class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
+final class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index a2c729a9b..a9c093ad5 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MethodOptions</code>
*/
-class MethodOptions extends \Google\Protobuf\Internal\Message
+final class MethodOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this method deprecated?
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 9ecfe5cbf..a703fcb70 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.OneofDescriptorProto</code>
*/
-class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
+final class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index 46b516f30..749051f31 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.OneofOptions</code>
*/
-class OneofOptions extends \Google\Protobuf\Internal\Message
+final class OneofOptions extends \Google\Protobuf\Internal\Message
{
/**
* The parser stores options it doesn't recognize here. See above.
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 8de7afd0b..9534f0480 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.ServiceDescriptorProto</code>
*/
-class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
+final class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index 67162f376..55bf7a775 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ServiceOptions</code>
*/
-class ServiceOptions extends \Google\Protobuf\Internal\Message
+final class ServiceOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this service deprecated?
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index dfeb69ff6..3ddd89226 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo</code>
*/
-class SourceCodeInfo extends \Google\Protobuf\Internal\Message
+final class SourceCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* A Location identifies a piece of source code in a .proto file which
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
index bad247a11..470d64c6e 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo.Location</code>
*/
-class Location extends \Google\Protobuf\Internal\Message
+final class Location extends \Google\Protobuf\Internal\Message
{
/**
* Identifies which part of the FileDescriptorProto was defined at this
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index 3b517ec55..39273d62f 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -20,7 +20,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption</code>
*/
-class UninterpretedOption extends \Google\Protobuf\Internal\Message
+final class UninterpretedOption extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
index 92ee4b44b..a2f9250f9 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption.NamePart</code>
*/
-class NamePart extends \Google\Protobuf\Internal\Message
+final class NamePart extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>required string name_part = 1;</code>
diff --git a/php/tests/proto/test_wrapper_type_setters.proto b/php/tests/proto/test_wrapper_type_setters.proto
index 119bd2547..41ca7f3f3 100644
--- a/php/tests/proto/test_wrapper_type_setters.proto
+++ b/php/tests/proto/test_wrapper_type_setters.proto
@@ -24,14 +24,3 @@ message TestWrapperSetters {
map<string, google.protobuf.StringValue> map_string_value = 13;
}
-
-message TestWrapperAccessorConflicts {
- int32 normal_vs_wrapper_value = 1;
- google.protobuf.Int32Value normal_vs_wrapper = 2;
-
- int32 normal_vs_normal_value = 3;
- int32 normal_vs_normal = 4;
-
- google.protobuf.Int32Value wrapper_vs_wrapper_value = 5;
- google.protobuf.Int32Value wrapper_vs_wrapper = 6;
-}
diff --git a/php/tests/wrapper_type_setters_test.php b/php/tests/wrapper_type_setters_test.php
index 35e3a7dec..ad9f7181d 100644
--- a/php/tests/wrapper_type_setters_test.php
+++ b/php/tests/wrapper_type_setters_test.php
@@ -16,44 +16,6 @@ use Google\Protobuf\UInt64Value;
class WrapperTypeSettersTest extends TestBase
{
- public function testConflictNormalVsWrapper()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setNormalVsWrapperValue1(1);
- $this->assertSame(1, $m->getNormalVsWrapperValue1());
-
- $m->setNormalVsWrapperValue2(1);
- $this->assertSame(1, $m->getNormalVsWrapperValue2());
-
- $wrapper = new Int32Value(["value" => 1]);
- $m->setNormalVsWrapper($wrapper);
- $this->assertSame(1, $m->getNormalVsWrapper()->getValue());
- }
-
- public function testConflictNormalVsNormal()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setNormalVsNormalValue(1);
- $this->assertSame(1, $m->getNormalVsNormalValue());
-
- $m->setNormalVsNormal(1);
- $this->assertSame(1, $m->getNormalVsNormal());
- }
-
- public function testConflictWrapperVsWrapper()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setWrapperVsWrapperValueValue(1);
- $this->assertSame(1, $m->getWrapperVsWrapperValueValue());
-
- $wrapper = new Int32Value(["value" => 1]);
- $m->setWrapperVsWrapperValue5($wrapper);
- $this->assertSame(1, $m->getWrapperVsWrapperValue5()->getValue());
- }
-
/**
* @dataProvider gettersAndSettersDataProvider
*/
@@ -98,26 +60,26 @@ class WrapperTypeSettersTest extends TestBase
public function gettersAndSettersDataProvider()
{
return [
- [TestWrapperSetters::class, DoubleValue::class, "setDoubleValue", "setDoubleValueValue", "getDoubleValue", "getDoubleValueValue", [
+ [TestWrapperSetters::class, DoubleValue::class, "setDoubleValue", "setDoubleValueUnwrapped", "getDoubleValue", "getDoubleValueUnwrapped", [
[1.1, new DoubleValue(["value" => 1.1])],
[2.2, new DoubleValue(["value" => 2.2])],
[null, null],
[0, new DoubleValue()],
]],
- [TestWrapperSetters::class, FloatValue::class, "setFloatValue", "setFloatValueValue", "getFloatValue", "getFloatValueValue", [
+ [TestWrapperSetters::class, FloatValue::class, "setFloatValue", "setFloatValueUnwrapped", "getFloatValue", "getFloatValueUnwrapped", [
[1.1, new FloatValue(["value" => 1.1])],
[2.2, new FloatValue(["value" => 2.2])],
[null, null],
[0, new FloatValue()],
]],
- [TestWrapperSetters::class, Int64Value::class, "setInt64Value", "setInt64ValueValue", "getInt64Value", "getInt64ValueValue", [
+ [TestWrapperSetters::class, Int64Value::class, "setInt64Value", "setInt64ValueUnwrapped", "getInt64Value", "getInt64ValueUnwrapped", [
[123, new Int64Value(["value" => 123])],
[-789, new Int64Value(["value" => -789])],
[null, null],
[0, new Int64Value()],
[5.5, new Int64Value(["value" => 5])], // Test conversion from float to int
]],
- [TestWrapperSetters::class, UInt64Value::class, "setUInt64Value", "setUInt64ValueValue", "getUInt64Value", "getUInt64ValueValue", [
+ [TestWrapperSetters::class, UInt64Value::class, "setUInt64Value", "setUInt64ValueUnwrapped", "getUInt64Value", "getUInt64ValueUnwrapped", [
[123, new UInt64Value(["value" => 123])],
[789, new UInt64Value(["value" => 789])],
[null, null],
@@ -125,14 +87,14 @@ class WrapperTypeSettersTest extends TestBase
[5.5, new UInt64Value(["value" => 5])], // Test conversion from float to int
[-7, new UInt64Value(["value" => -7])], // Test conversion from -ve to +ve
]],
- [TestWrapperSetters::class, Int32Value::class, "setInt32Value", "setInt32ValueValue", "getInt32Value", "getInt32ValueValue", [
+ [TestWrapperSetters::class, Int32Value::class, "setInt32Value", "setInt32ValueUnwrapped", "getInt32Value", "getInt32ValueUnwrapped", [
[123, new Int32Value(["value" => 123])],
[-789, new Int32Value(["value" => -789])],
[null, null],
[0, new Int32Value()],
[5.5, new Int32Value(["value" => 5])], // Test conversion from float to int
]],
- [TestWrapperSetters::class, UInt32Value::class, "setUInt32Value", "setUInt32ValueValue", "getUInt32Value", "getUInt32ValueValue", [
+ [TestWrapperSetters::class, UInt32Value::class, "setUInt32Value", "setUInt32ValueUnwrapped", "getUInt32Value", "getUInt32ValueUnwrapped", [
[123, new UInt32Value(["value" => 123])],
[789, new UInt32Value(["value" => 789])],
[null, null],
@@ -140,12 +102,12 @@ class WrapperTypeSettersTest extends TestBase
[5.5, new UInt32Value(["value" => 5])], // Test conversion from float to int
[-7, new UInt32Value(["value" => -7])], // Test conversion from -ve to +ve
]],
- [TestWrapperSetters::class, BoolValue::class, "setBoolValue", "setBoolValueValue", "getBoolValue", "getBoolValueValue", [
+ [TestWrapperSetters::class, BoolValue::class, "setBoolValue", "setBoolValueUnwrapped", "getBoolValue", "getBoolValueUnwrapped", [
[true, new BoolValue(["value" => true])],
[false, new BoolValue(["value" => false])],
[null, null],
]],
- [TestWrapperSetters::class, StringValue::class, "setStringValue", "setStringValueValue", "getStringValue", "getStringValueValue", [
+ [TestWrapperSetters::class, StringValue::class, "setStringValue", "setStringValueUnwrapped", "getStringValue", "getStringValueUnwrapped", [
["asdf", new StringValue(["value" => "asdf"])],
["", new StringValue(["value" => ""])],
[null, null],
@@ -155,7 +117,7 @@ class WrapperTypeSettersTest extends TestBase
[-7, new StringValue(["value" => "-7"])], // Test conversion from number to string
[-7.5, new StringValue(["value" => "-7.5"])], // Test conversion from number to string
]],
- [TestWrapperSetters::class, BytesValue::class, "setBytesValue", "setBytesValueValue", "getBytesValue", "getBytesValueValue", [
+ [TestWrapperSetters::class, BytesValue::class, "setBytesValue", "setBytesValueUnwrapped", "getBytesValue", "getBytesValueUnwrapped", [
["asdf", new BytesValue(["value" => "asdf"])],
["", new BytesValue(["value" => ""])],
[null, null],
@@ -165,12 +127,12 @@ class WrapperTypeSettersTest extends TestBase
[-7, new BytesValue(["value" => "-7"])], // Test conversion from number to bytes
[-7.5, new BytesValue(["value" => "-7.5"])], // Test conversion from number to bytes
]],
- [TestWrapperSetters::class, DoubleValue::class, "setDoubleValueOneof", "setDoubleValueOneofValue", "getDoubleValueOneof", "getDoubleValueOneofValue", [
+ [TestWrapperSetters::class, DoubleValue::class, "setDoubleValueOneof", "setDoubleValueOneofUnwrapped", "getDoubleValueOneof", "getDoubleValueOneofUnwrapped", [
[1.1, new DoubleValue(["value" => 1.1])],
[2.2, new DoubleValue(["value" => 2.2])],
[null, null],
[0, new DoubleValue()],
- ]],[TestWrapperSetters::class, StringValue::class, "setStringValueOneof", "setStringValueOneofValue", "getStringValueOneof", "getStringValueOneofValue", [
+ ]],[TestWrapperSetters::class, StringValue::class, "setStringValueOneof", "setStringValueOneofUnwrapped", "getStringValueOneof", "getStringValueOneofUnwrapped", [
["asdf", new StringValue(["value" => "asdf"])],
["", new StringValue(["value" => ""])],
[null, null],
@@ -195,47 +157,47 @@ class WrapperTypeSettersTest extends TestBase
public function invalidSettersDataProvider()
{
return [
- [TestWrapperSetters::class, "setDoubleValueValue", "abc"],
- [TestWrapperSetters::class, "setDoubleValueValue", []],
- [TestWrapperSetters::class, "setDoubleValueValue", new stdClass()],
- [TestWrapperSetters::class, "setDoubleValueValue", new DoubleValue()],
-
- [TestWrapperSetters::class, "setFloatValueValue", "abc"],
- [TestWrapperSetters::class, "setFloatValueValue", []],
- [TestWrapperSetters::class, "setFloatValueValue", new stdClass()],
- [TestWrapperSetters::class, "setFloatValueValue", new FloatValue()],
-
- [TestWrapperSetters::class, "setInt64ValueValue", "abc"],
- [TestWrapperSetters::class, "setInt64ValueValue", []],
- [TestWrapperSetters::class, "setInt64ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setInt64ValueValue", new Int64Value()],
-
- [TestWrapperSetters::class, "setUInt64ValueValue", "abc"],
- [TestWrapperSetters::class, "setUInt64ValueValue", []],
- [TestWrapperSetters::class, "setUInt64ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setUInt64ValueValue", new UInt64Value()],
-
- [TestWrapperSetters::class, "setInt32ValueValue", "abc"],
- [TestWrapperSetters::class, "setInt32ValueValue", []],
- [TestWrapperSetters::class, "setInt32ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setInt32ValueValue", new Int32Value()],
-
- [TestWrapperSetters::class, "setUInt32ValueValue", "abc"],
- [TestWrapperSetters::class, "setUInt32ValueValue", []],
- [TestWrapperSetters::class, "setUInt32ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setUInt32ValueValue", new UInt32Value()],
-
- [TestWrapperSetters::class, "setBoolValueValue", []],
- [TestWrapperSetters::class, "setBoolValueValue", new stdClass()],
- [TestWrapperSetters::class, "setBoolValueValue", new BoolValue()],
-
- [TestWrapperSetters::class, "setStringValueValue", []],
- [TestWrapperSetters::class, "setStringValueValue", new stdClass()],
- [TestWrapperSetters::class, "setStringValueValue", new StringValue()],
-
- [TestWrapperSetters::class, "setBytesValueValue", []],
- [TestWrapperSetters::class, "setBytesValueValue", new stdClass()],
- [TestWrapperSetters::class, "setBytesValueValue", new BytesValue()],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", []],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", new DoubleValue()],
+
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", []],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", new FloatValue()],
+
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", new Int64Value()],
+
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", new UInt64Value()],
+
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", new Int32Value()],
+
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", new UInt32Value()],
+
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", []],
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", new BoolValue()],
+
+ [TestWrapperSetters::class, "setStringValueUnwrapped", []],
+ [TestWrapperSetters::class, "setStringValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setStringValueUnwrapped", new StringValue()],
+
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", []],
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", new BytesValue()],
];
}