From 282fb9e68ec101b7b7616a45279427944afc3e6b Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 29 May 2017 15:30:47 -0700 Subject: Add ARRAY for reserved name (#3150) --- php/src/Google/Protobuf/descriptor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'php/src/Google/Protobuf') diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php index fb69eda0..35e4929b 100644 --- a/php/src/Google/Protobuf/descriptor.php +++ b/php/src/Google/Protobuf/descriptor.php @@ -236,7 +236,7 @@ function getClassNamePrefix( return $prefix; } - $reserved_words = array("Empty"); + $reserved_words = array("Empty", "ECHO", "ARRAY"); foreach ($reserved_words as $reserved_word) { if ($classname === $reserved_word) { if ($file_proto->getPackage() === "google.protobuf") { -- cgit v1.2.3 From 1e86ef4e9f0b9c9e8bd8d62a61e141f139366920 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 29 May 2017 22:04:20 -0700 Subject: Oneof field should be serialized even it's equal to default. (#3153) --- php/ext/google/protobuf/encode_decode.c | 4 +++- php/src/Google/Protobuf/Internal/Message.php | 7 +++++++ php/tests/encode_decode_test.php | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'php/src/Google/Protobuf') diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 28bf18f4..6e3c606b 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -1167,6 +1167,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, upb_msg_field_next(&i)) { upb_fielddef* f = upb_msg_iter_field(&i); uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset; + bool containing_oneof = false; if (upb_fielddef_containingoneof(f)) { uint32_t oneof_case_offset = @@ -1179,6 +1180,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, } // Otherwise, fall through to the appropriate singular-field handler // below. + containing_oneof = true; } if (is_map_field(f)) { @@ -1209,7 +1211,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, #define T(upbtypeconst, upbtype, ctype, default_value) \ case upbtypeconst: { \ ctype value = DEREF(message_data(msg), offset, ctype); \ - if (value != default_value) { \ + if (containing_oneof || value != default_value) { \ upb_sink_put##upbtype(sink, sel, value); \ } \ } break; diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index cd15e0f0..10c639ac 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -739,6 +739,13 @@ class Message */ private function existField($field) { + $oneof_index = $field->getOneofIndex(); + if ($oneof_index !== -1) { + $oneof = $this->desc->getOneofDecl()[$oneof_index]; + $oneof_name = $oneof->getName(); + return $this->$oneof_name->getNumber() === $field->getNumber(); + } + $getter = $field->getGetter(); $value = $this->$getter(); return $value !== $this->defaultValue($field); diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index 288df569..b4cfed42 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -88,6 +88,13 @@ class EncodeDecodeTest extends TestBase $n = new TestMessage(); $n->mergeFromString($data); $this->assertSame(1, $n->getOneofMessage()->getA()); + + // Encode default value + $m->setOneofEnum(TestEnum::ZERO); + $data = $m->serializeToString(); + $n = new TestMessage(); + $n->mergeFromString($data); + $this->assertSame("oneof_enum", $n->getMyOneof()); } public function testPackedEncode() -- cgit v1.2.3 From 6f325805c0bc956f927b0e2dbfb4dd8133b4ed69 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 5 Jun 2017 00:10:18 -0700 Subject: Add new file option php_namespace. (#3162) * Add new file option php_namespace. Use this option to change the namespace of php generated classes. Default is empty. When this option is empty, the package name will be used for determining the namespace. * Uncomment commented tests * Revert gdb test change * Update csharp descriptor. * Add test for empty php_namespace. --- Makefile.am | 4 +- .../src/Google.Protobuf/Reflection/Descriptor.cs | 143 ++++--- php/ext/google/protobuf/def.c | 27 +- php/ext/google/protobuf/upb.c | 377 +++++++++--------- php/ext/google/protobuf/upb.h | 33 +- .../Google/Protobuf/Internal/Descriptor.php | 1 + .../Google/Protobuf/Internal/DescriptorProto.php | 20 + .../Internal/DescriptorProto_ExtensionRange.php | 4 + .../Internal/DescriptorProto_ReservedRange.php | 4 + .../Protobuf/Internal/EnumDescriptorProto.php | 6 + php/src/Google/Protobuf/Internal/EnumOptions.php | 6 + .../Protobuf/Internal/EnumValueDescriptorProto.php | 6 + .../Google/Protobuf/Internal/EnumValueOptions.php | 4 + .../Protobuf/Internal/FieldDescriptorProto.php | 20 + php/src/Google/Protobuf/Internal/FieldOptions.php | 14 + .../Protobuf/Internal/FileDescriptorProto.php | 24 ++ .../Google/Protobuf/Internal/FileDescriptorSet.php | 2 + php/src/Google/Protobuf/Internal/FileOptions.php | 82 ++++ .../Google/Protobuf/Internal/GeneratedCodeInfo.php | 2 + .../Internal/GeneratedCodeInfo_Annotation.php | 8 + .../Google/Protobuf/Internal/MessageOptions.php | 10 + .../Protobuf/Internal/MethodDescriptorProto.php | 12 + php/src/Google/Protobuf/Internal/MethodOptions.php | 6 + .../Protobuf/Internal/OneofDescriptorProto.php | 4 + php/src/Google/Protobuf/Internal/OneofOptions.php | 2 + .../Protobuf/Internal/ServiceDescriptorProto.php | 6 + .../Google/Protobuf/Internal/ServiceOptions.php | 4 + .../Google/Protobuf/Internal/SourceCodeInfo.php | 2 + .../Protobuf/Internal/SourceCodeInfo_Location.php | 10 + .../Protobuf/Internal/UninterpretedOption.php | 14 + .../Internal/UninterpretedOption_NamePart.php | 4 + php/src/Google/Protobuf/descriptor.php | 13 + php/tests/generated_class_test.php | 21 ++ php/tests/memory_leak_test.php | 5 + php/tests/proto/test.proto | 7 + php/tests/proto/test_empty_php_namespace.proto | 8 + php/tests/proto/test_php_namespace.proto | 8 + src/google/protobuf/compiler/php/php_generator.cc | 27 +- src/google/protobuf/descriptor.pb.cc | 420 +++++++++++++-------- src/google/protobuf/descriptor.pb.h | 135 +++++-- src/google/protobuf/descriptor.proto | 5 + tests.sh | 2 +- 42 files changed, 1070 insertions(+), 442 deletions(-) create mode 100644 php/tests/proto/test_empty_php_namespace.proto create mode 100644 php/tests/proto/test_php_namespace.proto (limited to 'php/src/Google/Protobuf') diff --git a/Makefile.am b/Makefile.am index 3c3ca13d..385531ed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -654,11 +654,13 @@ php_EXTRA_DIST= \ php/tests/map_field_test.php \ php/tests/memory_leak_test.php \ php/tests/php_implementation_test.php \ + php/tests/proto/test_empty_php_namespace.proto \ php/tests/proto/test_import_descriptor_proto.proto \ php/tests/proto/test_include.proto \ php/tests/proto/test.proto \ - php/tests/proto/test_prefix.proto \ php/tests/proto/test_no_namespace.proto \ + php/tests/proto/test_php_namespace.proto \ + php/tests/proto/test_prefix.proto \ php/tests/test.sh \ php/tests/test_base.php \ php/tests/test_util.php \ diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 2960d1cd..c3517802 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection { "ASgJEhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5n", "b29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFt", "aW5nGAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVm", - "YWxzZSK0BQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", + "YWxzZSLLBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", "FGphdmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVf", "ZmlsZXMYCiABKAg6BWZhbHNlEikKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2Fu", "ZF9oYXNoGBQgASgIQgIYARIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg", @@ -92,61 +92,61 @@ namespace Google.Protobuf.Reflection { "ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs", "c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz", "cGFjZRglIAEoCRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSGAoQcGhwX2NsYXNz", - "X3ByZWZpeBgoIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsy", - "JC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRp", - "bWl6ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JV", - "TlRJTUUQAyoJCOgHEICAgIACSgQIJhAnIvIBCg5NZXNzYWdlT3B0aW9ucxIm", - "ChdtZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9f", - "c3RhbmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoK", - "ZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMK", - "FHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1", - "Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAJKBAgIEAlKBAgJEAoi", - "ngMKDEZpZWxkT3B0aW9ucxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90", - "b2J1Zi5GaWVsZE9wdGlvbnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiAB", - "KAgSPwoGanN0eXBlGAYgASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0", - "aW9ucy5KU1R5cGU6CUpTX05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZ", - "CgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxz", - "ZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJv", - "dG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQ", - "ABIICgRDT1JEEAESEAoMU1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpT", - "X05PUk1BTBAAEg0KCUpTX1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQ", - "gICAgAJKBAgEEAUiXgoMT25lb2ZPcHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRf", - "b3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVk", - "T3B0aW9uKgkI6AcQgICAgAIikwEKC0VudW1PcHRpb25zEhMKC2FsbG93X2Fs", - "aWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEkMKFHVuaW50", + "X3ByZWZpeBgoIAEoCRIVCg1waHBfbmFtZXNwYWNlGCkgASgJEkMKFHVuaW50", "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", - "dGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAJKBAgFEAYifQoQRW51bVZhbHVl", - "T3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxzZRJDChR1bmludGVy", - "cHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRl", - "cnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZpY2VPcHRpb25zEhkK", - "CmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0", + "dGVycHJldGVkT3B0aW9uIjoKDE9wdGltaXplTW9kZRIJCgVTUEVFRBABEg0K", + "CUNPREVfU0laRRACEhAKDExJVEVfUlVOVElNRRADKgkI6AcQgICAgAJKBAgm", + "ECci8gEKDk1lc3NhZ2VPcHRpb25zEiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9y", + "bWF0GAEgASgIOgVmYWxzZRIuCh9ub19zdGFuZGFyZF9kZXNjcmlwdG9yX2Fj", + "Y2Vzc29yGAIgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz", + "ZRIRCgltYXBfZW50cnkYByABKAgSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y", + "5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24q", + "CQjoBxCAgICAAkoECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0", + "eXBlGAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlw", + "ZToGU1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5n", + "b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFM", + "EhMKBGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh", + "bHNlEhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0", "aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0", - "aW9uKgkI6AcQgICAgAIirQIKDU1ldGhvZE9wdGlvbnMSGQoKZGVwcmVjYXRl", - "ZBghIAEoCDoFZmFsc2USXwoRaWRlbXBvdGVuY3lfbGV2ZWwYIiABKA4yLy5n", - "b29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucy5JZGVtcG90ZW5jeUxldmVs", - "OhNJREVNUE9URU5DWV9VTktOT1dOEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9u", - "GOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9u", - "IlAKEElkZW1wb3RlbmN5TGV2ZWwSFwoTSURFTVBPVEVOQ1lfVU5LTk9XThAA", - "EhMKD05PX1NJREVfRUZGRUNUUxABEg4KCklERU1QT1RFTlQQAioJCOgHEICA", - "gIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5hbWUYAiADKAsyLS5n", - "b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbi5OYW1lUGFydBIY", - "ChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0aXZlX2ludF92YWx1", - "ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoMZG91Ymxl", - "X3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEoDBIXCg9hZ2dyZWdh", - "dGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0GAEgAigJ", - "EhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNlQ29kZUluZm8SOgoI", - "bG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYuU291cmNlQ29kZUlu", - "Zm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgYASADKAVCAhABEhAK", - "BHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVudHMYAyABKAkSGQoR", - "dHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGluZ19kZXRhY2hlZF9j", - "b21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUluZm8SQQoKYW5ub3Rh", - "dGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRDb2RlSW5m", - "by5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0aBgBIAMoBUICEAES", - "EwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyABKAUSCwoDZW5kGAQg", - "ASgFQowBChNjb20uZ29vZ2xlLnByb3RvYnVmQhBEZXNjcmlwdG9yUHJvdG9z", - "SAFaPmdpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3Byb3RvYy1nZW4tZ28v", - "ZGVzY3JpcHRvcjtkZXNjcmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVm", - "LlJlZmxlY3Rpb24=")); + "aW9uIi8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdf", + "UElFQ0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5H", + "EAESDQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9w", + "dGlvbnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xl", + "LnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoL", + "RW51bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRl", + "ZBgDIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL", + "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCA", + "gICAAkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQY", + "ASABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIk", + "Lmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICA", + "gAIiewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFs", + "c2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy", + "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0", + "aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVt", + "cG90ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RP", + "cHRpb25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04S", + "QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv", + "YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIX", + "ChNJREVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAES", + "DgoKSURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRP", + "cHRpb24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy", + "cHJldGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyAB", + "KAkSGgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2lu", + "dF92YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5n", + "X3ZhbHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1l", + "UGFydBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigI", + "ItUBCg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2ds", + "ZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRp", + "b24SEAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVh", + "ZGluZ19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEo", + "CRIhChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5l", + "cmF0ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnBy", + "b3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3Rh", + "dGlvbhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRIN", + "CgViZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCjAEKE2NvbS5nb29nbGUucHJv", + "dG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcv", + "cHJvdG9idWYvcHJvdG9jLWdlbi1nby9kZXNjcmlwdG9yO2Rlc2NyaXB0b3Ki", + "AgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -160,7 +160,7 @@ namespace Google.Protobuf.Reflection { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null), @@ -2810,6 +2810,7 @@ namespace Google.Protobuf.Reflection { csharpNamespace_ = other.csharpNamespace_; swiftPrefix_ = other.swiftPrefix_; phpClassPrefix_ = other.phpClassPrefix_; + phpNamespace_ = other.phpNamespace_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3073,6 +3074,22 @@ namespace Google.Protobuf.Reflection { } } + /// Field number for the "php_namespace" field. + public const int PhpNamespaceFieldNumber = 41; + private string phpNamespace_ = ""; + /// + /// Use this option to change the namespace of php generated classes. Default + /// is empty. When this option is empty, the package name will be used for + /// determining the namespace. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string PhpNamespace { + get { return phpNamespace_; } + set { + phpNamespace_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// Field number for the "uninterpreted_option" field. public const int UninterpretedOptionFieldNumber = 999; private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec @@ -3115,6 +3132,7 @@ namespace Google.Protobuf.Reflection { if (CsharpNamespace != other.CsharpNamespace) return false; if (SwiftPrefix != other.SwiftPrefix) return false; if (PhpClassPrefix != other.PhpClassPrefix) return false; + if (PhpNamespace != other.PhpNamespace) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; return true; } @@ -3138,6 +3156,7 @@ namespace Google.Protobuf.Reflection { if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); if (SwiftPrefix.Length != 0) hash ^= SwiftPrefix.GetHashCode(); if (PhpClassPrefix.Length != 0) hash ^= PhpClassPrefix.GetHashCode(); + if (PhpNamespace.Length != 0) hash ^= PhpNamespace.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); return hash; } @@ -3213,6 +3232,10 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(194, 2); output.WriteString(PhpClassPrefix); } + if (PhpNamespace.Length != 0) { + output.WriteRawTag(202, 2); + output.WriteString(PhpNamespace); + } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } @@ -3267,6 +3290,9 @@ namespace Google.Protobuf.Reflection { if (PhpClassPrefix.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpClassPrefix); } + if (PhpNamespace.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(PhpNamespace); + } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3324,6 +3350,9 @@ namespace Google.Protobuf.Reflection { if (other.PhpClassPrefix.Length != 0) { PhpClassPrefix = other.PhpClassPrefix; } + if (other.PhpNamespace.Length != 0) { + PhpNamespace = other.PhpNamespace; + } uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -3399,6 +3428,10 @@ namespace Google.Protobuf.Reflection { PhpClassPrefix = input.ReadString(); break; } + case 330: { + PhpNamespace = input.ReadString(); + break; + } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 099ebd05..332616b2 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -405,23 +405,34 @@ static const char *classname_prefix(const char *classname, } static void convert_to_class_name_inplace(const char *package, + const char *namespace_given, const char *prefix, char *classname) { - size_t package_len = package == NULL ? 0 : strlen(package); size_t prefix_len = prefix == NULL ? 0 : strlen(prefix); size_t classname_len = strlen(classname); int i = 0, j; bool first_char = true; - int offset = package_len != 0 ? 2 : 0; + size_t package_len = package == NULL ? 0 : strlen(package); + size_t namespace_given_len = + namespace_given == NULL ? 0 : strlen(namespace_given); + bool use_namespace_given = namespace_given != NULL; + size_t namespace_len = + use_namespace_given ? namespace_given_len : package_len; + + int offset = namespace_len != 0 ? 2 : 0; for (j = 0; j < classname_len; j++) { - classname[package_len + prefix_len + classname_len + offset - 1 - j] = + classname[namespace_len + prefix_len + classname_len + offset - 1 - j] = classname[classname_len - j - 1]; } - if (package_len != 0) { + if (namespace_len != 0) { classname[i++] = '\\'; - for (j = 0; j < package_len; j++) { + for (j = 0; j < namespace_len; j++) { + if (use_namespace_given) { + classname[i++] = namespace_given[j]; + continue; + } // php packages are divided by '\'. if (package[j] == '.') { classname[i++] = '\\'; @@ -490,16 +501,20 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) { * bytes allocated, one for '.', one for trailing 0, and 3 for 'GPB' if \ * given message is google.protobuf.Empty.*/ \ const char *fullname = upb_##def_type_lower##_fullname(def_type_lower); \ + const char *php_namespace = upb_filedef_phpnamespace(files[0]); \ const char *prefix_given = upb_filedef_phpprefix(files[0]); \ size_t classname_len = strlen(fullname) + 5; \ if (prefix_given != NULL) { \ classname_len += strlen(prefix_given); \ } \ + if (php_namespace != NULL) { \ + classname_len += strlen(php_namespace); \ + } \ char *classname = ecalloc(sizeof(char), classname_len); \ const char *package = upb_filedef_package(files[0]); \ classname_no_prefix(fullname, package, classname); \ const char *prefix = classname_prefix(classname, prefix_given, package); \ - convert_to_class_name_inplace(package, prefix, classname); \ + convert_to_class_name_inplace(package, php_namespace, prefix, classname); \ PHP_PROTO_CE_DECLARE pce; \ if (php_proto_zend_lookup_class(classname, strlen(classname), &pce) == \ FAILURE) { \ diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index 70983016..cac2b401 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -1859,6 +1859,7 @@ static void freefiledef(upb_refcounted *r) { upb_gfree((void*)f->name); upb_gfree((void*)f->package); upb_gfree((void*)f->phpprefix); + upb_gfree((void*)f->phpnamespace); upb_gfree(f); } @@ -1874,6 +1875,7 @@ upb_filedef *upb_filedef_new(const void *owner) { f->package = NULL; f->name = NULL; f->phpprefix = NULL; + f->phpnamespace = NULL; f->syntax = UPB_SYNTAX_PROTO2; if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &upb_filedef_vtbl, @@ -1912,6 +1914,10 @@ const char *upb_filedef_phpprefix(const upb_filedef *f) { return f->phpprefix; } +const char *upb_filedef_phpnamespace(const upb_filedef *f) { + return f->phpnamespace; +} + upb_syntax_t upb_filedef_syntax(const upb_filedef *f) { return f->syntax; } @@ -1980,6 +1986,18 @@ bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix, return true; } +bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace, + upb_status *s) { + phpnamespace = upb_gstrdup(phpnamespace); + if (!phpnamespace) { + upb_upberr_setoom(s); + return false; + } + upb_gfree((void*)f->phpnamespace); + f->phpnamespace = phpnamespace; + return true; +} + bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s) { UPB_UNUSED(s); @@ -6419,14 +6437,14 @@ size_t upb_env_bytesallocated(const upb_env *e) { static const upb_msgdef msgs[22]; -static const upb_fielddef fields[106]; +static const upb_fielddef fields[107]; static const upb_enumdef enums[5]; static const upb_tabent strentries[236]; static const upb_tabent intentries[18]; -static const upb_tabval arrays[186]; +static const upb_tabval arrays[187]; #ifdef UPB_DEBUG_REFS -static upb_inttable reftables[266]; +static upb_inttable reftables[268]; #endif static const upb_msgdef msgs[22] = { @@ -6441,20 +6459,20 @@ static const upb_msgdef msgs[22] = { UPB_MSGDEF_INIT("google.protobuf.FieldOptions", 12, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[4], &arrays[42], 11, 6), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[56]), false, UPB_SYNTAX_PROTO2, &reftables[16], &reftables[17]), UPB_MSGDEF_INIT("google.protobuf.FileDescriptorProto", 42, 6, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[53], 13, 12), UPB_STRTABLE_INIT(12, 15, UPB_CTYPE_PTR, 4, &strentries[72]), false, UPB_SYNTAX_PROTO2, &reftables[18], &reftables[19]), UPB_MSGDEF_INIT("google.protobuf.FileDescriptorSet", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[66], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[88]), false, UPB_SYNTAX_PROTO2, &reftables[20], &reftables[21]), - UPB_MSGDEF_INIT("google.protobuf.FileOptions", 34, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 41, 16), UPB_STRTABLE_INIT(17, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]), - UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[109], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]), - UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[117], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]), - UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[124], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]), - UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[125], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]), - UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[127], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]), - UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[131], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[132], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]), - UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[134], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[141], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]), - UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[150], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]), + UPB_MSGDEF_INIT("google.protobuf.FileOptions", 37, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[6], &arrays[68], 42, 17), UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_PTR, 5, &strentries[92]), false, UPB_SYNTAX_PROTO2, &reftables[22], &reftables[23]), + UPB_MSGDEF_INIT("google.protobuf.MessageOptions", 10, 1, UPB_INTTABLE_INIT(1, 1, UPB_CTYPE_PTR, 1, &intentries[8], &arrays[110], 8, 4), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[124]), false, UPB_SYNTAX_PROTO2, &reftables[24], &reftables[25]), + UPB_MSGDEF_INIT("google.protobuf.MethodDescriptorProto", 15, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[118], 7, 6), UPB_STRTABLE_INIT(6, 7, UPB_CTYPE_PTR, 3, &strentries[132]), false, UPB_SYNTAX_PROTO2, &reftables[26], &reftables[27]), + UPB_MSGDEF_INIT("google.protobuf.MethodOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[10], &arrays[125], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[140]), false, UPB_SYNTAX_PROTO2, &reftables[28], &reftables[29]), + UPB_MSGDEF_INIT("google.protobuf.OneofDescriptorProto", 5, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[126], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[144]), false, UPB_SYNTAX_PROTO2, &reftables[30], &reftables[31]), + UPB_MSGDEF_INIT("google.protobuf.ServiceDescriptorProto", 11, 2, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[128], 4, 3), UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_PTR, 2, &strentries[148]), false, UPB_SYNTAX_PROTO2, &reftables[32], &reftables[33]), + UPB_MSGDEF_INIT("google.protobuf.ServiceOptions", 7, 1, UPB_INTTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &intentries[14], &arrays[132], 1, 0), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[152]), false, UPB_SYNTAX_PROTO2, &reftables[34], &reftables[35]), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo", 6, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[133], 2, 1), UPB_STRTABLE_INIT(1, 3, UPB_CTYPE_PTR, 2, &strentries[156]), false, UPB_SYNTAX_PROTO2, &reftables[36], &reftables[37]), + UPB_MSGDEF_INIT("google.protobuf.SourceCodeInfo.Location", 19, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[135], 7, 5), UPB_STRTABLE_INIT(5, 7, UPB_CTYPE_PTR, 3, &strentries[160]), false, UPB_SYNTAX_PROTO2, &reftables[38], &reftables[39]), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption", 18, 1, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[142], 9, 7), UPB_STRTABLE_INIT(7, 15, UPB_CTYPE_PTR, 4, &strentries[168]), false, UPB_SYNTAX_PROTO2, &reftables[40], &reftables[41]), + UPB_MSGDEF_INIT("google.protobuf.UninterpretedOption.NamePart", 6, 0, UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_PTR, 0, NULL, &arrays[151], 3, 2), UPB_STRTABLE_INIT(2, 3, UPB_CTYPE_PTR, 2, &strentries[184]), false, UPB_SYNTAX_PROTO2, &reftables[42], &reftables[43]), }; -static const upb_fielddef fields[106] = { +static const upb_fielddef fields[107] = { UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "aggregate_value", 8, &msgs[20], NULL, 15, 6, {0},&reftables[44], &reftables[45]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "allow_alias", 2, &msgs[4], NULL, 6, 1, {0},&reftables[46], &reftables[47]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "cc_enable_arenas", 31, &msgs[11], NULL, 23, 12, {0},&reftables[48], &reftables[49]), @@ -6505,77 +6523,78 @@ static const upb_fielddef fields[106] = { UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[138], &reftables[139]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 6, 0, {0},&reftables[140], &reftables[141]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[142], &reftables[143]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[144], &reftables[145]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[146], &reftables[147]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[148], &reftables[149]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[144], &reftables[145]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[146], &reftables[147]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[148], &reftables[149]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[150], &reftables[151]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[152], &reftables[153]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[154], &reftables[155]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[152], &reftables[153]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[154], &reftables[155]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[156], &reftables[157]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[158], &reftables[159]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[158], &reftables[159]), UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 2, 0, {0},&reftables[160], &reftables[161]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 10, 3, {0},&reftables[162], &reftables[163]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 15, 1, {0},&reftables[164], &reftables[165]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 7, 2, {0},&reftables[166], &reftables[167]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[168], &reftables[169]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[170], &reftables[171]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[168], &reftables[169]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[170], &reftables[171]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 24, 13, {0},&reftables[172], &reftables[173]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 28, 6, {0},&reftables[174], &reftables[175]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 19, 8, {0},&reftables[176], &reftables[177]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 12, 3, {0},&reftables[178], &reftables[179]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[180], &reftables[181]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[182], &reftables[183]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[184], &reftables[185]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[186], &reftables[187]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[188], &reftables[189]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[190], &reftables[191]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[192], &reftables[193]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[180], &reftables[181]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[182], &reftables[183]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[184], &reftables[185]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[186], &reftables[187]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[188], &reftables[189]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[190], &reftables[191]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[192], &reftables[193]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 10, 3, {0},&reftables[194], &reftables[195]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 25, 7, {0},&reftables[196], &reftables[197]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 7, 2, {0},&reftables[198], &reftables[199]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "path", 1, &msgs[19], NULL, 4, 0, {0},&reftables[200], &reftables[201]), UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_class_prefix", 40, &msgs[11], NULL, 31, 16, {0},&reftables[202], &reftables[203]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[204], &reftables[205]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[206], &reftables[207]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[208], &reftables[209]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[210], &reftables[211]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[212], &reftables[213]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[214], &reftables[215]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[216], &reftables[217]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[218], &reftables[219]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[220], &reftables[221]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[222], &reftables[223]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[224], &reftables[225]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[226], &reftables[227]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[228], &reftables[229]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[230], &reftables[231]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[232], &reftables[233]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[234], &reftables[235]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[236], &reftables[237]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "php_namespace", 41, &msgs[11], NULL, 34, 17, {0},&reftables[204], &reftables[205]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_UINT64, UPB_INTFMT_VARIABLE, false, false, false, false, "positive_int_value", 4, &msgs[20], NULL, 9, 2, {0},&reftables[206], &reftables[207]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "public_dependency", 10, &msgs[9], NULL, 35, 9, {0},&reftables[208], &reftables[209]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "py_generic_services", 18, &msgs[11], NULL, 19, 8, {0},&reftables[210], &reftables[211]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "reserved_name", 10, &msgs[0], NULL, 37, 9, {0},&reftables[212], &reftables[213]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "reserved_range", 9, &msgs[0], (const upb_def*)(&msgs[2]), 31, 7, {0},&reftables[214], &reftables[215]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "server_streaming", 6, &msgs[13], NULL, 14, 5, {0},&reftables[216], &reftables[217]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[218], &reftables[219]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[220], &reftables[221]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[222], &reftables[223]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[224], &reftables[225]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[226], &reftables[227]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[228], &reftables[229]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[230], &reftables[231]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[232], &reftables[233]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[234], &reftables[235]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[236], &reftables[237]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]), UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[248], &reftables[249]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[250], &reftables[251]), - UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[252], &reftables[253]), - UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[254], &reftables[255]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[248], &reftables[249]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[250], &reftables[251]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[252], &reftables[253]), + UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[254], &reftables[255]), + UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[256], &reftables[257]), }; static const upb_enumdef enums[5] = { - UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[153], 4, 3), 0, &reftables[256], &reftables[257]), - UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[157], 19, 18), 0, &reftables[258], &reftables[259]), - UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[176], 3, 3), 0, &reftables[260], &reftables[261]), - UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[179], 3, 3), 0, &reftables[262], &reftables[263]), - UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[182], 4, 3), 0, &reftables[264], &reftables[265]), + UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Label", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[188]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[154], 4, 3), 0, &reftables[258], &reftables[259]), + UPB_ENUMDEF_INIT("google.protobuf.FieldDescriptorProto.Type", UPB_STRTABLE_INIT(18, 31, UPB_CTYPE_INT32, 5, &strentries[192]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[158], 19, 18), 0, &reftables[260], &reftables[261]), + UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.CType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[224]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[177], 3, 3), 0, &reftables[262], &reftables[263]), + UPB_ENUMDEF_INIT("google.protobuf.FieldOptions.JSType", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[228]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 3, 3), 0, &reftables[264], &reftables[265]), + UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[183], 4, 3), 0, &reftables[266], &reftables[267]), }; static const upb_tabent strentries[236] = { {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), NULL}, + {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6584,31 +6603,31 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), NULL}, + {UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "oneof_decl"), UPB_TABVALUE_PTR_INIT(&fields[65]), NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), &strentries[13]}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[90]), NULL}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[91]), NULL}, {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[89]), NULL}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[90]), NULL}, {UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), &strentries[26]}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, + {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), &strentries[26]}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), NULL}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), &strentries[34]}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), &strentries[34]}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6620,17 +6639,17 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), &strentries[53]}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), &strentries[53]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL}, - {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL}, + {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "json_name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[94]), &strentries[50]}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[95]), &strentries[50]}, {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[105]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6645,21 +6664,21 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[23]), NULL}, - {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[105]), NULL}, + {UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[106]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[87]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[87]), NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[92]), NULL}, + {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "syntax"), UPB_TABVALUE_PTR_INIT(&fields[93]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL}, {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), &strentries[86]}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[86]}, {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), NULL}, - {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[81]), &strentries[85]}, + {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[82]), &strentries[85]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6680,17 +6699,17 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, + {UPB_TABKEY_STR("\015", "\000", "\000", "\000", "php_namespace"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[113]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_TABVALUE_PTR_INIT(&fields[33]), &strentries[117]}, - {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, {UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[32]), &strentries[118]}, {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_TABVALUE_PTR_INIT(&fields[31]), NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "php_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[79]), NULL}, {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "javanano_use_deprecated_package"), UPB_TABVALUE_PTR_INIT(&fields[37]), &strentries[123]}, - {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[82]), NULL}, + {UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[67]), NULL}, {UPB_TABKEY_STR("\026", "\000", "\000", "\000", "java_string_check_utf8"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), &strentries[119]}, @@ -6706,22 +6725,22 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[61]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "client_streaming"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL}, - {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[52]), NULL}, + {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[29]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL}, - {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL}, + {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), &strentries[150]}, + {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[150]}, {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL}, {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[149]}, {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, @@ -6735,9 +6754,9 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[88]), &strentries[167]}, + {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_TABVALUE_PTR_INIT(&fields[89]), &strentries[167]}, {UPB_TABKEY_STR("\031", "\000", "\000", "\000", "leading_detached_comments"), UPB_TABVALUE_PTR_INIT(&fields[43]), &strentries[165]}, - {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[93]), NULL}, + {UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_TABVALUE_PTR_INIT(&fields[42]), &strentries[164]}, {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_TABVALUE_PTR_INIT(&fields[78]), NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL}, @@ -6753,9 +6772,9 @@ static const upb_tabent strentries[236] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[80]), NULL}, + {UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL}, {UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_TABVALUE_PTR_INIT(&fields[28]), NULL}, - {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[91]), &strentries[182]}, + {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_TABVALUE_PTR_INIT(&fields[92]), &strentries[182]}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_TABVALUE_PTR_INIT(&fields[30]), NULL}, @@ -6811,6 +6830,8 @@ static const upb_tabent strentries[236] = { }; static const upb_tabent intentries[18] = { + {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, @@ -6818,60 +6839,58 @@ static const upb_tabent intentries[18] = { {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, - {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, - {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL}, + {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL}, {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL}, {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL}, }; -static const upb_tabval arrays[186] = { +static const upb_tabval arrays[187] = { UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[50]), + UPB_TABVALUE_PTR_INIT(&fields[57]), UPB_TABVALUE_PTR_INIT(&fields[25]), UPB_TABVALUE_PTR_INIT(&fields[60]), UPB_TABVALUE_PTR_INIT(&fields[20]), UPB_TABVALUE_PTR_INIT(&fields[24]), UPB_TABVALUE_PTR_INIT(&fields[22]), - UPB_TABVALUE_PTR_INIT(&fields[69]), + UPB_TABVALUE_PTR_INIT(&fields[68]), UPB_TABVALUE_PTR_INIT(&fields[65]), + UPB_TABVALUE_PTR_INIT(&fields[85]), UPB_TABVALUE_PTR_INIT(&fields[84]), - UPB_TABVALUE_PTR_INIT(&fields[83]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[90]), + UPB_TABVALUE_PTR_INIT(&fields[91]), UPB_TABVALUE_PTR_INIT(&fields[18]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[89]), + UPB_TABVALUE_PTR_INIT(&fields[90]), UPB_TABVALUE_PTR_INIT(&fields[17]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[54]), - UPB_TABVALUE_PTR_INIT(&fields[103]), - UPB_TABVALUE_PTR_INIT(&fields[74]), + UPB_TABVALUE_PTR_INIT(&fields[52]), + UPB_TABVALUE_PTR_INIT(&fields[104]), + UPB_TABVALUE_PTR_INIT(&fields[73]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[1]), UPB_TABVALUE_PTR_INIT(&fields[14]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[51]), - UPB_TABVALUE_PTR_INIT(&fields[62]), - UPB_TABVALUE_PTR_INIT(&fields[72]), + UPB_TABVALUE_PTR_INIT(&fields[50]), + UPB_TABVALUE_PTR_INIT(&fields[63]), + UPB_TABVALUE_PTR_INIT(&fields[74]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[13]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[56]), UPB_TABVALUE_PTR_INIT(&fields[21]), - UPB_TABVALUE_PTR_INIT(&fields[63]), + UPB_TABVALUE_PTR_INIT(&fields[62]), UPB_TABVALUE_PTR_INIT(&fields[40]), - UPB_TABVALUE_PTR_INIT(&fields[94]), UPB_TABVALUE_PTR_INIT(&fields[95]), + UPB_TABVALUE_PTR_INIT(&fields[96]), UPB_TABVALUE_PTR_INIT(&fields[7]), - UPB_TABVALUE_PTR_INIT(&fields[71]), + UPB_TABVALUE_PTR_INIT(&fields[70]), UPB_TABVALUE_PTR_INIT(&fields[66]), UPB_TABVALUE_PTR_INIT(&fields[38]), UPB_TABVALUE_EMPTY_INIT, @@ -6884,20 +6903,20 @@ static const upb_tabval arrays[186] = { UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[104]), + UPB_TABVALUE_PTR_INIT(&fields[105]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[57]), + UPB_TABVALUE_PTR_INIT(&fields[51]), UPB_TABVALUE_PTR_INIT(&fields[76]), UPB_TABVALUE_PTR_INIT(&fields[8]), UPB_TABVALUE_PTR_INIT(&fields[47]), UPB_TABVALUE_PTR_INIT(&fields[19]), - UPB_TABVALUE_PTR_INIT(&fields[86]), - UPB_TABVALUE_PTR_INIT(&fields[23]), - UPB_TABVALUE_PTR_INIT(&fields[68]), UPB_TABVALUE_PTR_INIT(&fields[87]), - UPB_TABVALUE_PTR_INIT(&fields[81]), - UPB_TABVALUE_PTR_INIT(&fields[105]), - UPB_TABVALUE_PTR_INIT(&fields[92]), + UPB_TABVALUE_PTR_INIT(&fields[23]), + UPB_TABVALUE_PTR_INIT(&fields[69]), + UPB_TABVALUE_PTR_INIT(&fields[88]), + UPB_TABVALUE_PTR_INIT(&fields[82]), + UPB_TABVALUE_PTR_INIT(&fields[106]), + UPB_TABVALUE_PTR_INIT(&fields[93]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[26]), UPB_TABVALUE_EMPTY_INIT, @@ -6918,7 +6937,7 @@ static const upb_tabval arrays[186] = { UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[3]), UPB_TABVALUE_PTR_INIT(&fields[32]), - UPB_TABVALUE_PTR_INIT(&fields[82]), + UPB_TABVALUE_PTR_INIT(&fields[83]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[31]), UPB_TABVALUE_EMPTY_INIT, @@ -6941,6 +6960,7 @@ static const upb_tabval arrays[186] = { UPB_TABVALUE_PTR_INIT(&fields[37]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[79]), + UPB_TABVALUE_PTR_INIT(&fields[80]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[46]), UPB_TABVALUE_PTR_INIT(&fields[61]), @@ -6950,37 +6970,37 @@ static const upb_tabval arrays[186] = { UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[45]), UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[52]), + UPB_TABVALUE_PTR_INIT(&fields[55]), UPB_TABVALUE_PTR_INIT(&fields[29]), UPB_TABVALUE_PTR_INIT(&fields[75]), - UPB_TABVALUE_PTR_INIT(&fields[70]), + UPB_TABVALUE_PTR_INIT(&fields[71]), UPB_TABVALUE_PTR_INIT(&fields[4]), - UPB_TABVALUE_PTR_INIT(&fields[85]), + UPB_TABVALUE_PTR_INIT(&fields[86]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, - UPB_TABVALUE_PTR_INIT(&fields[55]), + UPB_TABVALUE_PTR_INIT(&fields[54]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[53]), UPB_TABVALUE_PTR_INIT(&fields[48]), - UPB_TABVALUE_PTR_INIT(&fields[73]), + UPB_TABVALUE_PTR_INIT(&fields[72]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[44]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[78]), - UPB_TABVALUE_PTR_INIT(&fields[88]), + UPB_TABVALUE_PTR_INIT(&fields[89]), UPB_TABVALUE_PTR_INIT(&fields[42]), - UPB_TABVALUE_PTR_INIT(&fields[93]), + UPB_TABVALUE_PTR_INIT(&fields[94]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[43]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[49]), UPB_TABVALUE_PTR_INIT(&fields[28]), - UPB_TABVALUE_PTR_INIT(&fields[80]), + UPB_TABVALUE_PTR_INIT(&fields[81]), UPB_TABVALUE_PTR_INIT(&fields[59]), UPB_TABVALUE_PTR_INIT(&fields[16]), - UPB_TABVALUE_PTR_INIT(&fields[91]), + UPB_TABVALUE_PTR_INIT(&fields[92]), UPB_TABVALUE_PTR_INIT(&fields[0]), UPB_TABVALUE_EMPTY_INIT, UPB_TABVALUE_PTR_INIT(&fields[58]), @@ -7021,7 +7041,9 @@ static const upb_tabval arrays[186] = { }; #ifdef UPB_DEBUG_REFS -static upb_inttable reftables[266] = { +static upb_inttable reftables[268] = { + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), + UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR), @@ -7565,6 +7587,34 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, return n; } +static void *file_startphpnamespace(void *closure, const void *hd, + size_t size_hint) { + upb_descreader *r = closure; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(size_hint); + + ok = upb_filedef_setphpnamespace(r->file, "", NULL); + UPB_ASSERT(ok); + return closure; +} + +static size_t file_onphpnamespace(void *closure, const void *hd, + const char *buf, size_t n, + const upb_bufhandle *handle) { + upb_descreader *r = closure; + char *php_namespace; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + + php_namespace = upb_gstrndup(buf, n); + ok = upb_filedef_setphpnamespace(r->file, php_namespace, NULL); + upb_gfree(php_namespace); + UPB_ASSERT(ok); + return n; +} + static size_t file_onphpprefix(void *closure, const void *hd, const char *buf, size_t n, const upb_bufhandle *handle) { upb_descreader *r = closure; @@ -8109,6 +8159,10 @@ static void reghandlers(const void *closure, upb_handlers *h) { } else if (upbdefs_google_protobuf_FileOptions_is(m)) { upb_handlers_setstring(h, F(FileOptions, php_class_prefix), &file_onphpprefix, NULL); + upb_handlers_setstartstr(h, F(FileOptions, php_namespace), + &file_startphpnamespace, NULL); + upb_handlers_setstring(h, F(FileOptions, php_namespace), + &file_onphpnamespace, NULL); } UPB_ASSERT(upb_ok(upb_handlers_status(h))); @@ -11271,57 +11325,6 @@ done: return r; } -/* Given an encoded varint v, returns an integer with a single bit set that - * indicates the end of the varint. Subtracting one from this value will - * yield a mask that leaves only bits that are part of the varint. Returns - * 0 if the varint is unterminated. */ -static uint64_t upb_get_vstopbit(uint64_t v) { - uint64_t cbits = v | 0x7f7f7f7f7f7f7f7fULL; - return ~cbits & (cbits+1); -} - -/* A branchless decoder. Credit to Pascal Massimino for the bit-twiddling. */ -upb_decoderet upb_vdecode_max8_massimino(upb_decoderet r) { - uint64_t b; - uint64_t stop_bit; - upb_decoderet my_r; - memcpy(&b, r.p, sizeof(b)); - stop_bit = upb_get_vstopbit(b); - b = (b & 0x7f7f7f7f7f7f7f7fULL) & (stop_bit - 1); - b += b & 0x007f007f007f007fULL; - b += 3 * (b & 0x0000ffff0000ffffULL); - b += 15 * (b & 0x00000000ffffffffULL); - if (stop_bit == 0) { - /* Error: unterminated varint. */ - upb_decoderet err_r = {(void*)0, 0}; - return err_r; - } - my_r = upb_decoderet_make(r.p + ((__builtin_ctzll(stop_bit) + 1) / 8), - r.val | (b << 7)); - return my_r; -} - -/* A branchless decoder. Credit to Daniel Wright for the bit-twiddling. */ -upb_decoderet upb_vdecode_max8_wright(upb_decoderet r) { - uint64_t b; - uint64_t stop_bit; - upb_decoderet my_r; - memcpy(&b, r.p, sizeof(b)); - stop_bit = upb_get_vstopbit(b); - b &= (stop_bit - 1); - b = ((b & 0x7f007f007f007f00ULL) >> 1) | (b & 0x007f007f007f007fULL); - b = ((b & 0xffff0000ffff0000ULL) >> 2) | (b & 0x0000ffff0000ffffULL); - b = ((b & 0xffffffff00000000ULL) >> 4) | (b & 0x00000000ffffffffULL); - if (stop_bit == 0) { - /* Error: unterminated varint. */ - upb_decoderet err_r = {(void*)0, 0}; - return err_r; - } - my_r = upb_decoderet_make(r.p + ((__builtin_ctzll(stop_bit) + 1) / 8), - r.val | (b << 14)); - return my_r; -} - #line 1 "upb/json/parser.rl" /* ** upb::json::Parser (upb_json_parser) diff --git a/php/ext/google/protobuf/upb.h b/php/ext/google/protobuf/upb.h index 78f255f9..4b51275d 100644 --- a/php/ext/google/protobuf/upb.h +++ b/php/ext/google/protobuf/upb.h @@ -2973,10 +2973,16 @@ class upb::FileDef { bool set_package(const char* package, Status* s); /* Sets the php class prefix which is prepended to all php generated classes - / from this .proto. Default is empty. */ + * from this .proto. Default is empty. */ const char* phpprefix() const; bool set_phpprefix(const char* phpprefix, Status* s); + /* Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. */ + const char* phpnamespace() const; + bool set_phpnamespace(const char* phpnamespace, Status* s); + /* Syntax for the file. Defaults to proto2. */ upb_syntax_t syntax() const; void set_syntax(upb_syntax_t syntax); @@ -3031,6 +3037,7 @@ UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast) const char *upb_filedef_name(const upb_filedef *f); const char *upb_filedef_package(const upb_filedef *f); const char *upb_filedef_phpprefix(const upb_filedef *f); +const char *upb_filedef_phpnamespace(const upb_filedef *f); upb_syntax_t upb_filedef_syntax(const upb_filedef *f); size_t upb_filedef_defcount(const upb_filedef *f); size_t upb_filedef_depcount(const upb_filedef *f); @@ -3042,6 +3049,8 @@ bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s); bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s); bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix, upb_status *s); +bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace, + upb_status *s); bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s); bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor, @@ -3806,6 +3815,12 @@ inline const char* FileDef::phpprefix() const { inline bool FileDef::set_phpprefix(const char* phpprefix, Status* s) { return upb_filedef_setphpprefix(this, phpprefix, s); } +inline const char* FileDef::phpnamespace() const { + return upb_filedef_phpnamespace(this); +} +inline bool FileDef::set_phpnamespace(const char* phpnamespace, Status* s) { + return upb_filedef_setphpnamespace(this, phpnamespace, s); +} inline int FileDef::def_count() const { return upb_filedef_defcount(this); } @@ -4021,6 +4036,7 @@ struct upb_filedef { const char *name; const char *package; const char *phpprefix; + const char *phpnamespace; upb_syntax_t syntax; upb_inttable defs; @@ -7228,6 +7244,7 @@ UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_us UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 40); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_php_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 41); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); } UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); } @@ -8326,16 +8343,8 @@ UPB_INLINE upb_decoderet upb_decoderet_make(const char *p, uint64_t val) { return ret; } -/* Four functions for decoding a varint of at most eight bytes. They are all - * functionally identical, but are implemented in different ways and likely have - * different performance profiles. We keep them around for performance testing. - * - * Note that these functions may not read byte-by-byte, so they must not be used - * unless there are at least eight bytes left in the buffer! */ upb_decoderet upb_vdecode_max8_branch32(upb_decoderet r); upb_decoderet upb_vdecode_max8_branch64(upb_decoderet r); -upb_decoderet upb_vdecode_max8_wright(upb_decoderet r); -upb_decoderet upb_vdecode_max8_massimino(upb_decoderet r); /* Template for a function that checks the first two bytes with branching * and dispatches 2-10 bytes with a separate function. Note that this may read @@ -8360,8 +8369,6 @@ UPB_INLINE upb_decoderet upb_vdecode_check2_ ## name(const char *_p) { \ UPB_VARINT_DECODER_CHECK2(branch32, upb_vdecode_max8_branch32) UPB_VARINT_DECODER_CHECK2(branch64, upb_vdecode_max8_branch64) -UPB_VARINT_DECODER_CHECK2(wright, upb_vdecode_max8_wright) -UPB_VARINT_DECODER_CHECK2(massimino, upb_vdecode_max8_massimino) #undef UPB_VARINT_DECODER_CHECK2 /* Our canonical functions for decoding varints, based on the currently @@ -8373,10 +8380,6 @@ UPB_INLINE upb_decoderet upb_vdecode_fast(const char *p) { return upb_vdecode_check2_branch32(p); } -UPB_INLINE upb_decoderet upb_vdecode_max8_fast(upb_decoderet r) { - return upb_vdecode_max8_massimino(r); -} - /* Encoding *******************************************************************/ diff --git a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php index 1b6b3d60..636a0ad4 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php @@ -145,6 +145,7 @@ class Descriptor ->optional('csharp_namespace', \Google\Protobuf\Internal\GPBType::STRING, 37) ->optional('swift_prefix', \Google\Protobuf\Internal\GPBType::STRING, 39) ->optional('php_class_prefix', \Google\Protobuf\Internal\GPBType::STRING, 40) + ->optional('php_namespace', \Google\Protobuf\Internal\GPBType::STRING, 41) ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') ->finalizeToPool(); diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index 948c5876..c72c0962 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -97,6 +97,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; + + return $this; } public function hasName() @@ -120,6 +122,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->field = $arr; $this->has_field = true; + + return $this; } public function hasField() @@ -143,6 +147,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $arr; $this->has_extension = true; + + return $this; } public function hasExtension() @@ -166,6 +172,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->nested_type = $arr; $this->has_nested_type = true; + + return $this; } public function hasNestedType() @@ -189,6 +197,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $arr; $this->has_enum_type = true; + + return $this; } public function hasEnumType() @@ -212,6 +222,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class); $this->extension_range = $arr; $this->has_extension_range = true; + + return $this; } public function hasExtensionRange() @@ -235,6 +247,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); $this->oneof_decl = $arr; $this->has_oneof_decl = true; + + return $this; } public function hasOneofDecl() @@ -258,6 +272,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); $this->options = $var; $this->has_options = true; + + return $this; } public function hasOptions() @@ -281,6 +297,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class); $this->reserved_range = $arr; $this->has_reserved_range = true; + + return $this; } public function hasReservedRange() @@ -314,6 +332,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->reserved_name = $arr; $this->has_reserved_name = true; + + return $this; } public function hasReservedName() diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php index 738a1738..b5e5453e 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php @@ -48,6 +48,8 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->start = $var; $this->has_start = true; + + return $this; } public function hasStart() @@ -71,6 +73,8 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->end = $var; $this->has_end = true; + + return $this; } public function hasEnd() diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php index be36b8aa..e5b7b05a 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php @@ -70,6 +70,8 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->start = $var; $this->has_start = true; + + return $this; } public function hasStart() @@ -101,6 +103,8 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->end = $var; $this->has_end = true; + + return $this; } public function hasEnd() diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index 73f6edbd..bf597436 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -57,6 +57,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; + + return $this; } public function hasName() @@ -80,6 +82,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); $this->value = $arr; $this->has_value = true; + + return $this; } public function hasValue() @@ -103,6 +107,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); $this->options = $var; $this->has_options = true; + + return $this; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index 4fa0bce7..cfa0cb3e 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -79,6 +79,8 @@ class EnumOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->allow_alias = $var; $this->has_allow_alias = true; + + return $this; } public function hasAllowAlias() @@ -116,6 +118,8 @@ class EnumOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; + + return $this; } public function hasDeprecated() @@ -147,6 +151,8 @@ class EnumOptions extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; $this->has_uninterpreted_option = true; + + return $this; } public function hasUninterpretedOption() diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 94dc36ec..43eee73f 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -57,6 +57,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; + + return $this; } public function hasName() @@ -80,6 +82,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->number = $var; $this->has_number = true; + + return $this; } public function hasNumber() @@ -103,6 +107,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); $this->options = $var; $this->has_options = true; + + return $this; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index 232a6738..d66c7684 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -73,6 +73,8 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; + + return $this; } public function hasDeprecated() @@ -104,6 +106,8 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; $this->has_uninterpreted_option = true; + + return $this; } public function hasUninterpretedOption() diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index 6ae2cd41..2af9c0a0 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -130,6 +130,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; + + return $this; } public function hasName() @@ -153,6 +155,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->number = $var; $this->has_number = true; + + return $this; } public function hasNumber() @@ -176,6 +180,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class); $this->label = $var; $this->has_label = true; + + return $this; } public function hasLabel() @@ -209,6 +215,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class); $this->type = $var; $this->has_type = true; + + return $this; } public function hasType() @@ -248,6 +256,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->type_name = $var; $this->has_type_name = true; + + return $this; } public function hasTypeName() @@ -281,6 +291,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->extendee = $var; $this->has_extendee = true; + + return $this; } public function hasExtendee() @@ -320,6 +332,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->default_value = $var; $this->has_default_value = true; + + return $this; } public function hasDefaultValue() @@ -353,6 +367,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkInt32($var); $this->oneof_index = $var; $this->has_oneof_index = true; + + return $this; } public function hasOneofIndex() @@ -390,6 +406,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->json_name = $var; $this->has_json_name = true; + + return $this; } public function hasJsonName() @@ -413,6 +431,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); $this->options = $var; $this->has_options = true; + + return $this; } public function hasOptions() diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 8db7ed67..b30caa75 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -156,6 +156,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class); $this->ctype = $var; $this->has_ctype = true; + + return $this; } public function hasCtype() @@ -195,6 +197,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->packed = $var; $this->has_packed = true; + + return $this; } public function hasPacked() @@ -242,6 +246,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class); $this->jstype = $var; $this->has_jstype = true; + + return $this; } public function hasJstype() @@ -319,6 +325,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->lazy = $var; $this->has_lazy = true; + + return $this; } public function hasLazy() @@ -356,6 +364,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->deprecated = $var; $this->has_deprecated = true; + + return $this; } public function hasDeprecated() @@ -387,6 +397,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message GPBUtil::checkBool($var); $this->weak = $var; $this->has_weak = true; + + return $this; } public function hasWeak() @@ -418,6 +430,8 @@ class FieldOptions extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; $this->has_uninterpreted_option = true; + + return $this; } public function hasUninterpretedOption() diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index 0363d9e9..b229522a 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -147,6 +147,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->name = $var; $this->has_name = true; + + return $this; } public function hasName() @@ -178,6 +180,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->package = $var; $this->has_package = true; + + return $this; } public function hasPackage() @@ -209,6 +213,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->dependency = $arr; $this->has_dependency = true; + + return $this; } public function hasDependency() @@ -240,6 +246,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->public_dependency = $arr; $this->has_public_dependency = true; + + return $this; } public function hasPublicDependency() @@ -273,6 +281,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->weak_dependency = $arr; $this->has_weak_dependency = true; + + return $this; } public function hasWeakDependency() @@ -304,6 +314,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->message_type = $arr; $this->has_message_type = true; + + return $this; } public function hasMessageType() @@ -327,6 +339,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $arr; $this->has_enum_type = true; + + return $this; } public function hasEnumType() @@ -350,6 +364,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); $this->service = $arr; $this->has_service = true; + + return $this; } public function hasService() @@ -373,6 +389,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $arr; $this->has_extension = true; + + return $this; } public function hasExtension() @@ -396,6 +414,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); $this->options = $var; $this->has_options = true; + + return $this; } public function hasOptions() @@ -433,6 +453,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); $this->source_code_info = $var; $this->has_source_code_info = true; + + return $this; } public function hasSourceCodeInfo() @@ -466,6 +488,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message GPBUtil::checkString($var, True); $this->syntax = $var; $this->has_syntax = true; + + return $this; } public function hasSyntax() diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php index 0bcc8051..8271ee66 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -48,6 +48,8 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); $this->file = $arr; $this->has_file = true; + + return $this; } public function hasFile() diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 22653a4f..332da3dc 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -186,6 +186,17 @@ class FileOptions extends \Google\Protobuf\Internal\Message */ private $php_class_prefix = ''; private $has_php_class_prefix = false; + /** + *
+     * Use this option to change the namespace of php generated classes. Default
+     * is empty. When this option is empty, the package name will be used for
+     * determining the namespace.
+     * 
+ * + * optional string php_namespace = 41; + */ + private $php_namespace = ''; + private $has_php_namespace = false; /** *
      * The parser stores options it doesn't recognize here. See above.
@@ -231,6 +242,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->java_package = $var;
         $this->has_java_package = true;
+
+        return $this;
     }
 
     public function hasJavaPackage()
@@ -270,6 +283,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->java_outer_classname = $var;
         $this->has_java_outer_classname = true;
+
+        return $this;
     }
 
     public function hasJavaOuterClassname()
@@ -311,6 +326,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->java_multiple_files = $var;
         $this->has_java_multiple_files = true;
+
+        return $this;
     }
 
     public function hasJavaMultipleFiles()
@@ -342,6 +359,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->java_generate_equals_and_hash = $var;
         $this->has_java_generate_equals_and_hash = true;
+
+        return $this;
     }
 
     public function hasJavaGenerateEqualsAndHash()
@@ -383,6 +402,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->java_string_check_utf8 = $var;
         $this->has_java_string_check_utf8 = true;
+
+        return $this;
     }
 
     public function hasJavaStringCheckUtf8()
@@ -406,6 +427,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class);
         $this->optimize_for = $var;
         $this->has_optimize_for = true;
+
+        return $this;
     }
 
     public function hasOptimizeFor()
@@ -445,6 +468,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->go_package = $var;
         $this->has_go_package = true;
+
+        return $this;
     }
 
     public function hasGoPackage()
@@ -492,6 +517,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->cc_generic_services = $var;
         $this->has_cc_generic_services = true;
+
+        return $this;
     }
 
     public function hasCcGenericServices()
@@ -515,6 +542,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->java_generic_services = $var;
         $this->has_java_generic_services = true;
+
+        return $this;
     }
 
     public function hasJavaGenericServices()
@@ -538,6 +567,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->py_generic_services = $var;
         $this->has_py_generic_services = true;
+
+        return $this;
     }
 
     public function hasPyGenericServices()
@@ -575,6 +606,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
         $this->has_deprecated = true;
+
+        return $this;
     }
 
     public function hasDeprecated()
@@ -608,6 +641,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->cc_enable_arenas = $var;
         $this->has_cc_enable_arenas = true;
+
+        return $this;
     }
 
     public function hasCcEnableArenas()
@@ -641,6 +676,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->objc_class_prefix = $var;
         $this->has_objc_class_prefix = true;
+
+        return $this;
     }
 
     public function hasObjcClassPrefix()
@@ -672,6 +709,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->csharp_namespace = $var;
         $this->has_csharp_namespace = true;
+
+        return $this;
     }
 
     public function hasCsharpNamespace()
@@ -709,6 +748,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->swift_prefix = $var;
         $this->has_swift_prefix = true;
+
+        return $this;
     }
 
     public function hasSwiftPrefix()
@@ -742,6 +783,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->php_class_prefix = $var;
         $this->has_php_class_prefix = true;
+
+        return $this;
     }
 
     public function hasPhpClassPrefix()
@@ -749,6 +792,43 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         return $this->has_php_class_prefix;
     }
 
+    /**
+     * 
+     * Use this option to change the namespace of php generated classes. Default
+     * is empty. When this option is empty, the package name will be used for
+     * determining the namespace.
+     * 
+ * + * optional string php_namespace = 41; + */ + public function getPhpNamespace() + { + return $this->php_namespace; + } + + /** + *
+     * Use this option to change the namespace of php generated classes. Default
+     * is empty. When this option is empty, the package name will be used for
+     * determining the namespace.
+     * 
+ * + * optional string php_namespace = 41; + */ + public function setPhpNamespace($var) + { + GPBUtil::checkString($var, True); + $this->php_namespace = $var; + $this->has_php_namespace = true; + + return $this; + } + + public function hasPhpNamespace() + { + return $this->has_php_namespace; + } + /** *
      * The parser stores options it doesn't recognize here. See above.
@@ -773,6 +853,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
         $this->has_uninterpreted_option = true;
+
+        return $this;
     }
 
     public function hasUninterpretedOption()
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index 450854f1..1e666f31 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -64,6 +64,8 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class);
         $this->annotation = $arr;
         $this->has_annotation = true;
+
+        return $this;
     }
 
     public function hasAnnotation()
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
index ed22cc38..8d227e1c 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php
@@ -88,6 +88,8 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->path = $arr;
         $this->has_path = true;
+
+        return $this;
     }
 
     public function hasPath()
@@ -119,6 +121,8 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->source_file = $var;
         $this->has_source_file = true;
+
+        return $this;
     }
 
     public function hasSourceFile()
@@ -152,6 +156,8 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
         GPBUtil::checkInt32($var);
         $this->begin = $var;
         $this->has_begin = true;
+
+        return $this;
     }
 
     public function hasBegin()
@@ -187,6 +193,8 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message
         GPBUtil::checkInt32($var);
         $this->end = $var;
         $this->has_end = true;
+
+        return $this;
     }
 
     public function hasEnd()
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 747f3294..a5835358 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -155,6 +155,8 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->message_set_wire_format = $var;
         $this->has_message_set_wire_format = true;
+
+        return $this;
     }
 
     public function hasMessageSetWireFormat()
@@ -190,6 +192,8 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->no_standard_descriptor_accessor = $var;
         $this->has_no_standard_descriptor_accessor = true;
+
+        return $this;
     }
 
     public function hasNoStandardDescriptorAccessor()
@@ -227,6 +231,8 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
         $this->has_deprecated = true;
+
+        return $this;
     }
 
     public function hasDeprecated()
@@ -292,6 +298,8 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->map_entry = $var;
         $this->has_map_entry = true;
+
+        return $this;
     }
 
     public function hasMapEntry()
@@ -323,6 +331,8 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
         $this->has_uninterpreted_option = true;
+
+        return $this;
     }
 
     public function hasUninterpretedOption()
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index 3d8df7af..c3f9f064 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -85,6 +85,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->name = $var;
         $this->has_name = true;
+
+        return $this;
     }
 
     public function hasName()
@@ -118,6 +120,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->input_type = $var;
         $this->has_input_type = true;
+
+        return $this;
     }
 
     public function hasInputType()
@@ -141,6 +145,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->output_type = $var;
         $this->has_output_type = true;
+
+        return $this;
     }
 
     public function hasOutputType()
@@ -164,6 +170,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class);
         $this->options = $var;
         $this->has_options = true;
+
+        return $this;
     }
 
     public function hasOptions()
@@ -195,6 +203,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->client_streaming = $var;
         $this->has_client_streaming = true;
+
+        return $this;
     }
 
     public function hasClientStreaming()
@@ -226,6 +236,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->server_streaming = $var;
         $this->has_server_streaming = true;
+
+        return $this;
     }
 
     public function hasServerStreaming()
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index 6dca5854..e8d36d3c 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -78,6 +78,8 @@ class MethodOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
         $this->has_deprecated = true;
+
+        return $this;
     }
 
     public function hasDeprecated()
@@ -101,6 +103,8 @@ class MethodOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions_IdempotencyLevel::class);
         $this->idempotency_level = $var;
         $this->has_idempotency_level = true;
+
+        return $this;
     }
 
     public function hasIdempotencyLevel()
@@ -132,6 +136,8 @@ class MethodOptions extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
         $this->has_uninterpreted_option = true;
+
+        return $this;
     }
 
     public function hasUninterpretedOption()
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index e5fbe370..744ca638 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -52,6 +52,8 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->name = $var;
         $this->has_name = true;
+
+        return $this;
     }
 
     public function hasName()
@@ -75,6 +77,8 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class);
         $this->options = $var;
         $this->has_options = true;
+
+        return $this;
     }
 
     public function hasOptions()
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index b61325d2..b3cd51ed 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -55,6 +55,8 @@ class OneofOptions extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
         $this->has_uninterpreted_option = true;
+
+        return $this;
     }
 
     public function hasUninterpretedOption()
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 47776202..7c85728a 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -57,6 +57,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->name = $var;
         $this->has_name = true;
+
+        return $this;
     }
 
     public function hasName()
@@ -80,6 +82,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class);
         $this->method = $arr;
         $this->has_method = true;
+
+        return $this;
     }
 
     public function hasMethod()
@@ -103,6 +107,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
         GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class);
         $this->options = $var;
         $this->has_options = true;
+
+        return $this;
     }
 
     public function hasOptions()
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index 62323dba..0f3a8d74 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -73,6 +73,8 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->deprecated = $var;
         $this->has_deprecated = true;
+
+        return $this;
     }
 
     public function hasDeprecated()
@@ -104,6 +106,8 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class);
         $this->uninterpreted_option = $arr;
         $this->has_uninterpreted_option = true;
+
+        return $this;
     }
 
     public function hasUninterpretedOption()
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index eab60880..7eef3424 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -180,6 +180,8 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class);
         $this->location = $arr;
         $this->has_location = true;
+
+        return $this;
     }
 
     public function hasLocation()
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
index 5a02b26c..cf23e38b 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php
@@ -182,6 +182,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->path = $arr;
         $this->has_path = true;
+
+        return $this;
     }
 
     public function hasPath()
@@ -221,6 +223,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32);
         $this->span = $arr;
         $this->has_span = true;
+
+        return $this;
     }
 
     public function hasSpan()
@@ -322,6 +326,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->leading_comments = $var;
         $this->has_leading_comments = true;
+
+        return $this;
     }
 
     public function hasLeadingComments()
@@ -345,6 +351,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->trailing_comments = $var;
         $this->has_trailing_comments = true;
+
+        return $this;
     }
 
     public function hasTrailingComments()
@@ -368,6 +376,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
         $this->leading_detached_comments = $arr;
         $this->has_leading_detached_comments = true;
+
+        return $this;
     }
 
     public function hasLeadingDetachedComments()
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index 28655019..08e071d4 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -87,6 +87,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class);
         $this->name = $arr;
         $this->has_name = true;
+
+        return $this;
     }
 
     public function hasName()
@@ -120,6 +122,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->identifier_value = $var;
         $this->has_identifier_value = true;
+
+        return $this;
     }
 
     public function hasIdentifierValue()
@@ -143,6 +147,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkUint64($var);
         $this->positive_int_value = $var;
         $this->has_positive_int_value = true;
+
+        return $this;
     }
 
     public function hasPositiveIntValue()
@@ -166,6 +172,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkInt64($var);
         $this->negative_int_value = $var;
         $this->has_negative_int_value = true;
+
+        return $this;
     }
 
     public function hasNegativeIntValue()
@@ -189,6 +197,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkDouble($var);
         $this->double_value = $var;
         $this->has_double_value = true;
+
+        return $this;
     }
 
     public function hasDoubleValue()
@@ -212,6 +222,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, False);
         $this->string_value = $var;
         $this->has_string_value = true;
+
+        return $this;
     }
 
     public function hasStringValue()
@@ -235,6 +247,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->aggregate_value = $var;
         $this->has_aggregate_value = true;
+
+        return $this;
     }
 
     public function hasAggregateValue()
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
index 86484d23..eb27754c 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php
@@ -56,6 +56,8 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message
         GPBUtil::checkString($var, True);
         $this->name_part = $var;
         $this->has_name_part = true;
+
+        return $this;
     }
 
     public function hasNamePart()
@@ -79,6 +81,8 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message
         GPBUtil::checkBool($var);
         $this->is_extension = $var;
         $this->has_is_extension = true;
+
+        return $this;
     }
 
     public function hasIsExtension()
diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php
index 35e4929b..b7a3a550 100644
--- a/php/src/Google/Protobuf/descriptor.php
+++ b/php/src/Google/Protobuf/descriptor.php
@@ -282,6 +282,19 @@ function getFullClassName(
 
     $class_name_without_package =
         getClassNameWithoutPackage($message_name_without_package, $file_proto);
+
+    $option = $file_proto->getOptions();
+    if (!is_null($option) && $option->hasPhpNamespace()) {
+        $namespace = $option->getPhpNamespace();
+        if ($namespace !== "") {
+            $classname = $namespace . "\\" . $class_name_without_package;
+            return;
+        } else {
+            $classname = $class_name_without_package;
+            return;
+        }
+    }
+
     if ($package === "") {
         $classname = $class_name_without_package;
     } else {
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index be641b6e..f7e645b3 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -9,9 +9,11 @@ use Google\Protobuf\Internal\RepeatedField;
 use Google\Protobuf\Internal\MapField;
 use Google\Protobuf\Internal\GPBType;
 use Foo\TestEnum;
+use Foo\TestIncludeNamespaceMessage;
 use Foo\TestIncludePrefixMessage;
 use Foo\TestMessage;
 use Foo\TestMessage_Sub;
+use Php\Test\TestNamespace;
 
 class GeneratedClassTest extends TestBase
 {
@@ -867,6 +869,25 @@ class GeneratedClassTest extends TestBase
         $this->assertSame(1, $m->getPrefixMessage()->getA());
     }
 
+    #########################################################
+    # Test message with given namespace.
+    #########################################################
+
+    public function testNamespaceMessage()
+    {
+        $m = new TestIncludeNamespaceMessage();
+
+        $n = new TestNamespace();
+        $n->setA(1);
+        $m->setNamespaceMessage($n);
+        $this->assertSame(1, $m->getNamespaceMessage()->getA());
+
+        $n = new TestEmptyNamespace();
+        $n->setA(1);
+        $m->setEmptyNamespaceMessage($n);
+        $this->assertSame(1, $m->getEmptyNamespaceMessage()->getA());
+    }
+
     #########################################################
     # Test prefix for reserved words.
     #########################################################
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 5eac56f0..4f951a89 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -7,10 +7,12 @@ require_once('generated/NoNamespaceMessage.php');
 require_once('generated/NoNamespaceMessage_NestedEnum.php');
 require_once('generated/PrefixEmpty.php');
 require_once('generated/PrefixTestPrefix.php');
+require_once('generated/TestEmptyNamespace.php');
 require_once('generated/Bar/TestInclude.php');
 require_once('generated/Foo/PBARRAY.php');
 require_once('generated/Foo/PBEmpty.php');
 require_once('generated/Foo/TestEnum.php');
+require_once('generated/Foo/TestIncludeNamespaceMessage.php');
 require_once('generated/Foo/TestIncludePrefixMessage.php');
 require_once('generated/Foo/TestMessage.php');
 require_once('generated/Foo/TestMessage_Empty.php');
@@ -20,9 +22,12 @@ require_once('generated/Foo/TestPackedMessage.php');
 require_once('generated/Foo/TestPhpDoc.php');
 require_once('generated/Foo/TestUnpackedMessage.php');
 require_once('generated/GPBMetadata/Proto/Test.php');
+require_once('generated/GPBMetadata/Proto/TestEmptyPhpNamespace.php');
 require_once('generated/GPBMetadata/Proto/TestInclude.php');
 require_once('generated/GPBMetadata/Proto/TestNoNamespace.php');
+require_once('generated/GPBMetadata/Proto/TestPhpNamespace.php');
 require_once('generated/GPBMetadata/Proto/TestPrefix.php');
+require_once('generated/Php/Test/TestNamespace.php');
 require_once('test_util.php');
 
 use Google\Protobuf\Internal\RepeatedField;
diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto
index 583bf8e1..dada8b48 100644
--- a/php/tests/proto/test.proto
+++ b/php/tests/proto/test.proto
@@ -2,6 +2,8 @@ syntax = "proto3";
 
 import 'proto/test_include.proto';
 import 'proto/test_no_namespace.proto';
+import 'proto/test_php_namespace.proto';
+import 'proto/test_empty_php_namespace.proto';
 import 'proto/test_prefix.proto';
 
 package foo;
@@ -174,3 +176,8 @@ message TestPhpDoc {
 message TestIncludePrefixMessage {
   TestPrefix prefix_message = 1;
 }
+
+message TestIncludeNamespaceMessage {
+  TestNamespace namespace_message = 1;
+  TestEmptyNamespace empty_namespace_message = 2;
+}
diff --git a/php/tests/proto/test_empty_php_namespace.proto b/php/tests/proto/test_empty_php_namespace.proto
new file mode 100644
index 00000000..7b4bc74d
--- /dev/null
+++ b/php/tests/proto/test_empty_php_namespace.proto
@@ -0,0 +1,8 @@
+syntax = "proto3";
+
+package foo;
+option php_namespace = "";
+
+message TestEmptyNamespace {
+  int32 a = 1;
+}
diff --git a/php/tests/proto/test_php_namespace.proto b/php/tests/proto/test_php_namespace.proto
new file mode 100644
index 00000000..713187b9
--- /dev/null
+++ b/php/tests/proto/test_php_namespace.proto
@@ -0,0 +1,8 @@
+syntax = "proto3";
+
+package foo;
+option php_namespace = "Php\\Test";
+
+message TestNamespace {
+  int32 a = 1;
+}
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index cbddee9e..78252817 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -145,6 +145,15 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) {
   }
   classname = ClassNamePrefix(classname, desc) + classname;
 
+  if (desc->file()->options().has_php_namespace()) {
+    const string& php_namespace = desc->file()->options().php_namespace();
+    if (php_namespace != "") {
+      return php_namespace + '\\' + classname;
+    } else {
+      return classname;
+    }
+  }
+
   if (desc->file()->package() == "") {
     return classname;
   } else {
@@ -822,7 +831,14 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
   std::string fullname = FilenameToClassname(filename);
   int lastindex = fullname.find_last_of("\\");
 
-  if (!file->package().empty()) {
+  if (file->options().has_php_namespace()) {
+    const string& php_namespace = file->options().php_namespace();
+    if (!php_namespace.empty()) {
+      printer.Print(
+          "namespace ^name^;\n\n",
+          "name", php_namespace);
+    }
+  } else if (!file->package().empty()) {
     printer.Print(
         "namespace ^name^;\n\n",
         "name", fullname.substr(0, lastindex));
@@ -874,7 +890,14 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
   std::string fullname = FilenameToClassname(filename);
   int lastindex = fullname.find_last_of("\\");
 
-  if (!file->package().empty()) {
+  if (file->options().has_php_namespace()) {
+    const string& php_namespace = file->options().php_namespace();
+    if (!php_namespace.empty()) {
+      printer.Print(
+          "namespace ^name^;\n\n",
+          "name", php_namespace);
+    }
+  } else if (!file->package().empty()) {
     printer.Print(
         "namespace ^name^;\n\n",
         "name", fullname.substr(0, lastindex));
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc
index 56c395e6..ff0819ec 100644
--- a/src/google/protobuf/descriptor.pb.cc
+++ b/src/google/protobuf/descriptor.pb.cc
@@ -303,23 +303,25 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = {
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_class_prefix_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_namespace_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_),
   0,
   1,
-  7,
   8,
   9,
-  15,
-  2,
   10,
+  16,
+  2,
   11,
   12,
   13,
   14,
+  15,
   3,
   4,
   5,
   6,
+  7,
   ~0u,
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_),
@@ -486,20 +488,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = {
   { 124, 132, sizeof(EnumValueDescriptorProto)},
   { 135, 143, sizeof(ServiceDescriptorProto)},
   { 146, 157, sizeof(MethodDescriptorProto)},
-  { 163, 185, sizeof(FileOptions)},
-  { 202, 212, sizeof(MessageOptions)},
-  { 217, 229, sizeof(FieldOptions)},
-  { 236, 242, sizeof(OneofOptions)},
-  { 243, 251, sizeof(EnumOptions)},
-  { 254, 261, sizeof(EnumValueOptions)},
-  { 263, 270, sizeof(ServiceOptions)},
-  { 272, 280, sizeof(MethodOptions)},
-  { 283, 290, sizeof(UninterpretedOption_NamePart)},
-  { 292, 304, sizeof(UninterpretedOption)},
-  { 311, 321, sizeof(SourceCodeInfo_Location)},
-  { 326, 332, sizeof(SourceCodeInfo)},
-  { 333, 342, sizeof(GeneratedCodeInfo_Annotation)},
-  { 346, 352, sizeof(GeneratedCodeInfo)},
+  { 163, 186, sizeof(FileOptions)},
+  { 204, 214, sizeof(MessageOptions)},
+  { 219, 231, sizeof(FieldOptions)},
+  { 238, 244, sizeof(OneofOptions)},
+  { 245, 253, sizeof(EnumOptions)},
+  { 256, 263, sizeof(EnumValueOptions)},
+  { 265, 272, sizeof(ServiceOptions)},
+  { 274, 282, sizeof(MethodOptions)},
+  { 285, 292, sizeof(UninterpretedOption_NamePart)},
+  { 294, 306, sizeof(UninterpretedOption)},
+  { 313, 323, sizeof(SourceCodeInfo_Location)},
+  { 328, 334, sizeof(SourceCodeInfo)},
+  { 335, 344, sizeof(GeneratedCodeInfo_Annotation)},
+  { 348, 354, sizeof(GeneratedCodeInfo)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -727,7 +729,7 @@ void AddDescriptorsImpl() {
       "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g"
       "oogle.protobuf.MethodOptions\022\037\n\020client_s"
       "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin"
-      "g\030\006 \001(\010:\005false\"\264\005\n\013FileOptions\022\024\n\014java_p"
+      "g\030\006 \001(\010:\005false\"\313\005\n\013FileOptions\022\024\n\014java_p"
       "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001"
       "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)"
       "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030"
@@ -741,70 +743,71 @@ void AddDescriptorsImpl() {
       "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre"
       "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s"
       "wift_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( "
-      "\001(\t\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goo"
-      "gle.protobuf.UninterpretedOption\":\n\014Opti"
-      "mizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LI"
-      "TE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016Messag"
-      "eOptions\022&\n\027message_set_wire_format\030\001 \001("
-      "\010:\005false\022.\n\037no_standard_descriptor_acces"
-      "sor\030\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005fa"
-      "lse\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_"
-      "option\030\347\007 \003(\0132$.google.protobuf.Uninterp"
-      "retedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014F"
-      "ieldOptions\022:\n\005ctype\030\001 \001(\0162#.google.prot"
-      "obuf.FieldOptions.CType:\006STRING\022\016\n\006packe"
-      "d\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google.protobu"
-      "f.FieldOptions.JSType:\tJS_NORMAL\022\023\n\004lazy"
-      "\030\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false"
-      "\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_o"
-      "ption\030\347\007 \003(\0132$.google.protobuf.Uninterpr"
-      "etedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020"
-      "\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORM"
-      "AL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020"
-      "\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpr"
-      "eted_option\030\347\007 \003(\0132$.google.protobuf.Uni"
-      "nterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOpti"
-      "ons\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003"
-      " \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003"
-      "(\0132$.google.protobuf.UninterpretedOption"
-      "*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n"
-      "\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterprete"
-      "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte"
-      "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptio"
-      "ns\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninter"
-      "preted_option\030\347\007 \003(\0132$.google.protobuf.U"
-      "ninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethod"
-      "Options\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021id"
-      "empotency_level\030\" \001(\0162/.google.protobuf."
-      "MethodOptions.IdempotencyLevel:\023IDEMPOTE"
-      "NCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003"
-      "(\0132$.google.protobuf.UninterpretedOption"
-      "\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKN"
-      "OWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT"
-      "\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n"
-      "\004name\030\002 \003(\0132-.google.protobuf.Uninterpre"
-      "tedOption.NamePart\022\030\n\020identifier_value\030\003"
-      " \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022nega"
-      "tive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001"
-      "(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_va"
-      "lue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t"
-      "\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInf"
-      "o\022:\n\010location\030\001 \003(\0132(.google.protobuf.So"
-      "urceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pa"
-      "th\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leadin"
-      "g_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 "
-      "\001(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\247"
-      "\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\013"
-      "2-.google.protobuf.GeneratedCodeInfo.Ann"
-      "otation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022"
-      "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e"
-      "nd\030\004 \001(\005B\214\001\n\023com.google.protobufB\020Descri"
-      "ptorProtosH\001Z>github.com/golang/protobuf"
-      "/protoc-gen-go/descriptor;descriptor\242\002\003G"
-      "PB\252\002\032Google.Protobuf.Reflection"
+      "\001(\t\022\025\n\rphp_namespace\030) \001(\t\022C\n\024uninterpre"
+      "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin"
+      "terpretedOption\":\n\014OptimizeMode\022\t\n\005SPEED"
+      "\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007"
+      "\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016MessageOptions\022&\n\027messa"
+      "ge_set_wire_format\030\001 \001(\010:\005false\022.\n\037no_st"
+      "andard_descriptor_accessor\030\002 \001(\010:\005false\022"
+      "\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030"
+      "\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.g"
+      "oogle.protobuf.UninterpretedOption*\t\010\350\007\020"
+      "\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ct"
+      "ype\030\001 \001(\0162#.google.protobuf.FieldOptions"
+      ".CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype"
+      "\030\006 \001(\0162$.google.protobuf.FieldOptions.JS"
+      "Type:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\n"
+      "deprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005f"
+      "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go"
+      "ogle.protobuf.UninterpretedOption\"/\n\005CTy"
+      "pe\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE"
+      "\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING"
+      "\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014On"
+      "eofOptions\022C\n\024uninterpreted_option\030\347\007 \003("
+      "\0132$.google.protobuf.UninterpretedOption*"
+      "\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alia"
+      "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un"
+      "interpreted_option\030\347\007 \003(\0132$.google.proto"
+      "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006"
+      "\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010"
+      ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$"
+      ".google.protobuf.UninterpretedOption*\t\010\350"
+      "\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030"
+      "! \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 "
+      "\003(\0132$.google.protobuf.UninterpretedOptio"
+      "n*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprec"
+      "ated\030! \001(\010:\005false\022_\n\021idempotency_level\030\""
+      " \001(\0162/.google.protobuf.MethodOptions.Ide"
+      "mpotencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024un"
+      "interpreted_option\030\347\007 \003(\0132$.google.proto"
+      "buf.UninterpretedOption\"P\n\020IdempotencyLe"
+      "vel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_"
+      "EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n"
+      "\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goo"
+      "gle.protobuf.UninterpretedOption.NamePar"
+      "t\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_"
+      "int_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 "
+      "\001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_valu"
+      "e\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010Name"
+      "Part\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030"
+      "\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003"
+      "(\0132(.google.protobuf.SourceCodeInfo.Loca"
+      "tion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004s"
+      "pan\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022"
+      "\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_de"
+      "tached_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeI"
+      "nfo\022A\n\nannotation\030\001 \003(\0132-.google.protobu"
+      "f.GeneratedCodeInfo.Annotation\032O\n\nAnnota"
+      "tion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 "
+      "\001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\214\001\n\023com."
+      "google.protobufB\020DescriptorProtosH\001Z>git"
+      "hub.com/golang/protobuf/protoc-gen-go/de"
+      "scriptor;descriptor\242\002\003GPB\252\002\032Google.Proto"
+      "buf.Reflection"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 5591);
+      descriptor, 5614);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "google/protobuf/descriptor.proto", &protobuf_RegisterTypes);
   ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
@@ -8255,6 +8258,7 @@ const int FileOptions::kObjcClassPrefixFieldNumber;
 const int FileOptions::kCsharpNamespaceFieldNumber;
 const int FileOptions::kSwiftPrefixFieldNumber;
 const int FileOptions::kPhpClassPrefixFieldNumber;
+const int FileOptions::kPhpNamespaceFieldNumber;
 const int FileOptions::kUninterpretedOptionFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 
@@ -8302,6 +8306,10 @@ FileOptions::FileOptions(const FileOptions& from)
   if (from.has_php_class_prefix()) {
     php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_);
   }
+  php_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.has_php_namespace()) {
+    php_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace_);
+  }
   ::memcpy(&java_multiple_files_, &from.java_multiple_files_,
     reinterpret_cast(&optimize_for_) -
     reinterpret_cast(&java_multiple_files_) + sizeof(optimize_for_));
@@ -8317,6 +8325,7 @@ void FileOptions::SharedCtor() {
   csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   php_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  php_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   ::memset(&java_multiple_files_, 0, reinterpret_cast(&cc_enable_arenas_) -
     reinterpret_cast(&java_multiple_files_) + sizeof(cc_enable_arenas_));
   optimize_for_ = 1;
@@ -8335,6 +8344,7 @@ void FileOptions::SharedDtor() {
   csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   php_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  php_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
 }
 
 void FileOptions::SetCachedSize(int size) const {
@@ -8364,7 +8374,7 @@ void FileOptions::Clear() {
 // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)
   _extensions_.Clear();
   uninterpreted_option_.Clear();
-  if (_has_bits_[0 / 32] & 127u) {
+  if (_has_bits_[0 / 32] & 255u) {
     if (has_java_package()) {
       GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
       (*java_package_.UnsafeRawStringPointer())->clear();
@@ -8393,13 +8403,16 @@ void FileOptions::Clear() {
       GOOGLE_DCHECK(!php_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
       (*php_class_prefix_.UnsafeRawStringPointer())->clear();
     }
+    if (has_php_namespace()) {
+      GOOGLE_DCHECK(!php_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+      (*php_namespace_.UnsafeRawStringPointer())->clear();
+    }
   }
-  java_multiple_files_ = false;
   if (_has_bits_[8 / 32] & 65280u) {
-    ::memset(&java_generate_equals_and_hash_, 0, reinterpret_cast(&cc_enable_arenas_) -
-      reinterpret_cast(&java_generate_equals_and_hash_) + sizeof(cc_enable_arenas_));
-    optimize_for_ = 1;
+    ::memset(&java_multiple_files_, 0, reinterpret_cast(&cc_enable_arenas_) -
+      reinterpret_cast(&java_multiple_files_) + sizeof(cc_enable_arenas_));
   }
+  optimize_for_ = 1;
   _has_bits_.Clear();
   _internal_metadata_.Clear();
 }
@@ -8657,6 +8670,22 @@ bool FileOptions::MergePartialFromCodedStream(
         break;
       }
 
+      // optional string php_namespace = 41;
+      case 41: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(330u)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_php_namespace()));
+          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+            this->php_namespace().data(), this->php_namespace().length(),
+            ::google::protobuf::internal::WireFormat::PARSE,
+            "google.protobuf.FileOptions.php_namespace");
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
       // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
       case 999: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
@@ -8724,13 +8753,13 @@ void FileOptions::SerializeWithCachedSizes(
   }
 
   // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
-  if (cached_has_bits & 0x00008000u) {
+  if (cached_has_bits & 0x00010000u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       9, this->optimize_for(), output);
   }
 
   // optional bool java_multiple_files = 10 [default = false];
-  if (cached_has_bits & 0x00000080u) {
+  if (cached_has_bits & 0x00000100u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output);
   }
 
@@ -8745,37 +8774,37 @@ void FileOptions::SerializeWithCachedSizes(
   }
 
   // optional bool cc_generic_services = 16 [default = false];
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output);
   }
 
   // optional bool java_generic_services = 17 [default = false];
-  if (cached_has_bits & 0x00000800u) {
+  if (cached_has_bits & 0x00001000u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output);
   }
 
   // optional bool py_generic_services = 18 [default = false];
-  if (cached_has_bits & 0x00001000u) {
+  if (cached_has_bits & 0x00002000u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output);
   }
 
   // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
-  if (cached_has_bits & 0x00000100u) {
+  if (cached_has_bits & 0x00000200u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output);
   }
 
   // optional bool deprecated = 23 [default = false];
-  if (cached_has_bits & 0x00002000u) {
+  if (cached_has_bits & 0x00004000u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output);
   }
 
   // optional bool java_string_check_utf8 = 27 [default = false];
-  if (cached_has_bits & 0x00000200u) {
+  if (cached_has_bits & 0x00000400u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(27, this->java_string_check_utf8(), output);
   }
 
   // optional bool cc_enable_arenas = 31 [default = false];
-  if (cached_has_bits & 0x00004000u) {
+  if (cached_has_bits & 0x00008000u) {
     ::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output);
   }
 
@@ -8819,6 +8848,16 @@ void FileOptions::SerializeWithCachedSizes(
       40, this->php_class_prefix(), output);
   }
 
+  // optional string php_namespace = 41;
+  if (cached_has_bits & 0x00000080u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->php_namespace().data(), this->php_namespace().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "google.protobuf.FileOptions.php_namespace");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      41, this->php_namespace(), output);
+  }
+
   // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
   for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
     ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
@@ -8866,13 +8905,13 @@ void FileOptions::SerializeWithCachedSizes(
   }
 
   // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
-  if (cached_has_bits & 0x00008000u) {
+  if (cached_has_bits & 0x00010000u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       9, this->optimize_for(), target);
   }
 
   // optional bool java_multiple_files = 10 [default = false];
-  if (cached_has_bits & 0x00000080u) {
+  if (cached_has_bits & 0x00000100u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target);
   }
 
@@ -8888,37 +8927,37 @@ void FileOptions::SerializeWithCachedSizes(
   }
 
   // optional bool cc_generic_services = 16 [default = false];
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target);
   }
 
   // optional bool java_generic_services = 17 [default = false];
-  if (cached_has_bits & 0x00000800u) {
+  if (cached_has_bits & 0x00001000u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target);
   }
 
   // optional bool py_generic_services = 18 [default = false];
-  if (cached_has_bits & 0x00001000u) {
+  if (cached_has_bits & 0x00002000u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target);
   }
 
   // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
-  if (cached_has_bits & 0x00000100u) {
+  if (cached_has_bits & 0x00000200u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target);
   }
 
   // optional bool deprecated = 23 [default = false];
-  if (cached_has_bits & 0x00002000u) {
+  if (cached_has_bits & 0x00004000u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target);
   }
 
   // optional bool java_string_check_utf8 = 27 [default = false];
-  if (cached_has_bits & 0x00000200u) {
+  if (cached_has_bits & 0x00000400u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(27, this->java_string_check_utf8(), target);
   }
 
   // optional bool cc_enable_arenas = 31 [default = false];
-  if (cached_has_bits & 0x00004000u) {
+  if (cached_has_bits & 0x00008000u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target);
   }
 
@@ -8966,6 +9005,17 @@ void FileOptions::SerializeWithCachedSizes(
         40, this->php_class_prefix(), target);
   }
 
+  // optional string php_namespace = 41;
+  if (cached_has_bits & 0x00000080u) {
+    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+      this->php_namespace().data(), this->php_namespace().length(),
+      ::google::protobuf::internal::WireFormat::SERIALIZE,
+      "google.protobuf.FileOptions.php_namespace");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        41, this->php_namespace(), target);
+  }
+
   // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
   for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {
     target = ::google::protobuf::internal::WireFormatLite::
@@ -9057,13 +9107,20 @@ size_t FileOptions::ByteSizeLong() const {
           this->php_class_prefix());
     }
 
+    // optional string php_namespace = 41;
+    if (has_php_namespace()) {
+      total_size += 2 +
+        ::google::protobuf::internal::WireFormatLite::StringSize(
+          this->php_namespace());
+    }
+
+  }
+  if (_has_bits_[8 / 32] & 65280u) {
     // optional bool java_multiple_files = 10 [default = false];
     if (has_java_multiple_files()) {
       total_size += 1 + 1;
     }
 
-  }
-  if (_has_bits_[8 / 32] & 65280u) {
     // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
     if (has_java_generate_equals_and_hash()) {
       total_size += 2 + 1;
@@ -9099,13 +9156,13 @@ size_t FileOptions::ByteSizeLong() const {
       total_size += 2 + 1;
     }
 
-    // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
-    if (has_optimize_for()) {
-      total_size += 1 +
-        ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
-    }
-
   }
+  // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
+  if (has_optimize_for()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
+  }
+
   int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
   GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
   _cached_size_ = cached_size;
@@ -9168,37 +9225,40 @@ void FileOptions::MergeFrom(const FileOptions& from) {
       php_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix_);
     }
     if (cached_has_bits & 0x00000080u) {
-      java_multiple_files_ = from.java_multiple_files_;
+      set_has_php_namespace();
+      php_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.php_namespace_);
     }
-    _has_bits_[0] |= cached_has_bits;
   }
   if (cached_has_bits & 65280u) {
     if (cached_has_bits & 0x00000100u) {
-      java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_;
+      java_multiple_files_ = from.java_multiple_files_;
     }
     if (cached_has_bits & 0x00000200u) {
-      java_string_check_utf8_ = from.java_string_check_utf8_;
+      java_generate_equals_and_hash_ = from.java_generate_equals_and_hash_;
     }
     if (cached_has_bits & 0x00000400u) {
-      cc_generic_services_ = from.cc_generic_services_;
+      java_string_check_utf8_ = from.java_string_check_utf8_;
     }
     if (cached_has_bits & 0x00000800u) {
-      java_generic_services_ = from.java_generic_services_;
+      cc_generic_services_ = from.cc_generic_services_;
     }
     if (cached_has_bits & 0x00001000u) {
-      py_generic_services_ = from.py_generic_services_;
+      java_generic_services_ = from.java_generic_services_;
     }
     if (cached_has_bits & 0x00002000u) {
-      deprecated_ = from.deprecated_;
+      py_generic_services_ = from.py_generic_services_;
     }
     if (cached_has_bits & 0x00004000u) {
-      cc_enable_arenas_ = from.cc_enable_arenas_;
+      deprecated_ = from.deprecated_;
     }
     if (cached_has_bits & 0x00008000u) {
-      optimize_for_ = from.optimize_for_;
+      cc_enable_arenas_ = from.cc_enable_arenas_;
     }
     _has_bits_[0] |= cached_has_bits;
   }
+  if (cached_has_bits & 0x00010000u) {
+    set_optimize_for(from.optimize_for());
+  }
 }
 
 void FileOptions::CopyFrom(const ::google::protobuf::Message& from) {
@@ -9237,6 +9297,7 @@ void FileOptions::InternalSwap(FileOptions* other) {
   csharp_namespace_.Swap(&other->csharp_namespace_);
   swift_prefix_.Swap(&other->swift_prefix_);
   php_class_prefix_.Swap(&other->php_class_prefix_);
+  php_namespace_.Swap(&other->php_namespace_);
   std::swap(java_multiple_files_, other->java_multiple_files_);
   std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_);
   std::swap(java_string_check_utf8_, other->java_string_check_utf8_);
@@ -9388,13 +9449,13 @@ void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_c
 
 // optional bool java_multiple_files = 10 [default = false];
 bool FileOptions::has_java_multiple_files() const {
-  return (_has_bits_[0] & 0x00000080u) != 0;
+  return (_has_bits_[0] & 0x00000100u) != 0;
 }
 void FileOptions::set_has_java_multiple_files() {
-  _has_bits_[0] |= 0x00000080u;
+  _has_bits_[0] |= 0x00000100u;
 }
 void FileOptions::clear_has_java_multiple_files() {
-  _has_bits_[0] &= ~0x00000080u;
+  _has_bits_[0] &= ~0x00000100u;
 }
 void FileOptions::clear_java_multiple_files() {
   java_multiple_files_ = false;
@@ -9412,13 +9473,13 @@ void FileOptions::set_java_multiple_files(bool value) {
 
 // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
 bool FileOptions::has_java_generate_equals_and_hash() const {
-  return (_has_bits_[0] & 0x00000100u) != 0;
+  return (_has_bits_[0] & 0x00000200u) != 0;
 }
 void FileOptions::set_has_java_generate_equals_and_hash() {
-  _has_bits_[0] |= 0x00000100u;
+  _has_bits_[0] |= 0x00000200u;
 }
 void FileOptions::clear_has_java_generate_equals_and_hash() {
-  _has_bits_[0] &= ~0x00000100u;
+  _has_bits_[0] &= ~0x00000200u;
 }
 void FileOptions::clear_java_generate_equals_and_hash() {
   java_generate_equals_and_hash_ = false;
@@ -9436,13 +9497,13 @@ void FileOptions::set_java_generate_equals_and_hash(bool value) {
 
 // optional bool java_string_check_utf8 = 27 [default = false];
 bool FileOptions::has_java_string_check_utf8() const {
-  return (_has_bits_[0] & 0x00000200u) != 0;
+  return (_has_bits_[0] & 0x00000400u) != 0;
 }
 void FileOptions::set_has_java_string_check_utf8() {
-  _has_bits_[0] |= 0x00000200u;
+  _has_bits_[0] |= 0x00000400u;
 }
 void FileOptions::clear_has_java_string_check_utf8() {
-  _has_bits_[0] &= ~0x00000200u;
+  _has_bits_[0] &= ~0x00000400u;
 }
 void FileOptions::clear_java_string_check_utf8() {
   java_string_check_utf8_ = false;
@@ -9460,13 +9521,13 @@ void FileOptions::set_java_string_check_utf8(bool value) {
 
 // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
 bool FileOptions::has_optimize_for() const {
-  return (_has_bits_[0] & 0x00008000u) != 0;
+  return (_has_bits_[0] & 0x00010000u) != 0;
 }
 void FileOptions::set_has_optimize_for() {
-  _has_bits_[0] |= 0x00008000u;
+  _has_bits_[0] |= 0x00010000u;
 }
 void FileOptions::clear_has_optimize_for() {
-  _has_bits_[0] &= ~0x00008000u;
+  _has_bits_[0] &= ~0x00010000u;
 }
 void FileOptions::clear_optimize_for() {
   optimize_for_ = 1;
@@ -9548,13 +9609,13 @@ void FileOptions::set_allocated_go_package(::std::string* go_package) {
 
 // optional bool cc_generic_services = 16 [default = false];
 bool FileOptions::has_cc_generic_services() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
+  return (_has_bits_[0] & 0x00000800u) != 0;
 }
 void FileOptions::set_has_cc_generic_services() {
-  _has_bits_[0] |= 0x00000400u;
+  _has_bits_[0] |= 0x00000800u;
 }
 void FileOptions::clear_has_cc_generic_services() {
-  _has_bits_[0] &= ~0x00000400u;
+  _has_bits_[0] &= ~0x00000800u;
 }
 void FileOptions::clear_cc_generic_services() {
   cc_generic_services_ = false;
@@ -9572,13 +9633,13 @@ void FileOptions::set_cc_generic_services(bool value) {
 
 // optional bool java_generic_services = 17 [default = false];
 bool FileOptions::has_java_generic_services() const {
-  return (_has_bits_[0] & 0x00000800u) != 0;
+  return (_has_bits_[0] & 0x00001000u) != 0;
 }
 void FileOptions::set_has_java_generic_services() {
-  _has_bits_[0] |= 0x00000800u;
+  _has_bits_[0] |= 0x00001000u;
 }
 void FileOptions::clear_has_java_generic_services() {
-  _has_bits_[0] &= ~0x00000800u;
+  _has_bits_[0] &= ~0x00001000u;
 }
 void FileOptions::clear_java_generic_services() {
   java_generic_services_ = false;
@@ -9596,13 +9657,13 @@ void FileOptions::set_java_generic_services(bool value) {
 
 // optional bool py_generic_services = 18 [default = false];
 bool FileOptions::has_py_generic_services() const {
-  return (_has_bits_[0] & 0x00001000u) != 0;
+  return (_has_bits_[0] & 0x00002000u) != 0;
 }
 void FileOptions::set_has_py_generic_services() {
-  _has_bits_[0] |= 0x00001000u;
+  _has_bits_[0] |= 0x00002000u;
 }
 void FileOptions::clear_has_py_generic_services() {
-  _has_bits_[0] &= ~0x00001000u;
+  _has_bits_[0] &= ~0x00002000u;
 }
 void FileOptions::clear_py_generic_services() {
   py_generic_services_ = false;
@@ -9620,13 +9681,13 @@ void FileOptions::set_py_generic_services(bool value) {
 
 // optional bool deprecated = 23 [default = false];
 bool FileOptions::has_deprecated() const {
-  return (_has_bits_[0] & 0x00002000u) != 0;
+  return (_has_bits_[0] & 0x00004000u) != 0;
 }
 void FileOptions::set_has_deprecated() {
-  _has_bits_[0] |= 0x00002000u;
+  _has_bits_[0] |= 0x00004000u;
 }
 void FileOptions::clear_has_deprecated() {
-  _has_bits_[0] &= ~0x00002000u;
+  _has_bits_[0] &= ~0x00004000u;
 }
 void FileOptions::clear_deprecated() {
   deprecated_ = false;
@@ -9644,13 +9705,13 @@ void FileOptions::set_deprecated(bool value) {
 
 // optional bool cc_enable_arenas = 31 [default = false];
 bool FileOptions::has_cc_enable_arenas() const {
-  return (_has_bits_[0] & 0x00004000u) != 0;
+  return (_has_bits_[0] & 0x00008000u) != 0;
 }
 void FileOptions::set_has_cc_enable_arenas() {
-  _has_bits_[0] |= 0x00004000u;
+  _has_bits_[0] |= 0x00008000u;
 }
 void FileOptions::clear_has_cc_enable_arenas() {
-  _has_bits_[0] &= ~0x00004000u;
+  _has_bits_[0] &= ~0x00008000u;
 }
 void FileOptions::clear_cc_enable_arenas() {
   cc_enable_arenas_ = false;
@@ -9918,6 +9979,69 @@ void FileOptions::set_allocated_php_class_prefix(::std::string* php_class_prefix
   // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix)
 }
 
+// optional string php_namespace = 41;
+bool FileOptions::has_php_namespace() const {
+  return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void FileOptions::set_has_php_namespace() {
+  _has_bits_[0] |= 0x00000080u;
+}
+void FileOptions::clear_has_php_namespace() {
+  _has_bits_[0] &= ~0x00000080u;
+}
+void FileOptions::clear_php_namespace() {
+  php_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_php_namespace();
+}
+const ::std::string& FileOptions::php_namespace() const {
+  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace)
+  return php_namespace_.GetNoArena();
+}
+void FileOptions::set_php_namespace(const ::std::string& value) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace)
+}
+#if LANG_CXX11
+void FileOptions::set_php_namespace(::std::string&& value) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace)
+}
+#endif
+void FileOptions::set_php_namespace(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace)
+}
+void FileOptions::set_php_namespace(const char* value, size_t size) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast(value), size));
+  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace)
+}
+::std::string* FileOptions::mutable_php_namespace() {
+  set_has_php_namespace();
+  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace)
+  return php_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* FileOptions::release_php_namespace() {
+  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace)
+  clear_has_php_namespace();
+  return php_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void FileOptions::set_allocated_php_namespace(::std::string* php_namespace) {
+  if (php_namespace != NULL) {
+    set_has_php_namespace();
+  } else {
+    clear_has_php_namespace();
+  }
+  php_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_namespace);
+  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace)
+}
+
 // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
 int FileOptions::uninterpreted_option_size() const {
   return uninterpreted_option_.size();
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h
index d1ed2b1f..f64a339c 100644
--- a/src/google/protobuf/descriptor.pb.h
+++ b/src/google/protobuf/descriptor.pb.h
@@ -2233,6 +2233,21 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
   ::std::string* release_php_class_prefix();
   void set_allocated_php_class_prefix(::std::string* php_class_prefix);
 
+  // optional string php_namespace = 41;
+  bool has_php_namespace() const;
+  void clear_php_namespace();
+  static const int kPhpNamespaceFieldNumber = 41;
+  const ::std::string& php_namespace() const;
+  void set_php_namespace(const ::std::string& value);
+  #if LANG_CXX11
+  void set_php_namespace(::std::string&& value);
+  #endif
+  void set_php_namespace(const char* value);
+  void set_php_namespace(const char* value, size_t size);
+  ::std::string* mutable_php_namespace();
+  ::std::string* release_php_namespace();
+  void set_allocated_php_namespace(::std::string* php_namespace);
+
   // optional bool java_multiple_files = 10 [default = false];
   bool has_java_multiple_files() const;
   void clear_java_multiple_files();
@@ -2331,6 +2346,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
   void clear_has_swift_prefix();
   void set_has_php_class_prefix();
   void clear_has_php_class_prefix();
+  void set_has_php_namespace();
+  void clear_has_php_namespace();
 
   ::google::protobuf::internal::ExtensionSet _extensions_;
 
@@ -2345,6 +2362,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p
   ::google::protobuf::internal::ArenaStringPtr csharp_namespace_;
   ::google::protobuf::internal::ArenaStringPtr swift_prefix_;
   ::google::protobuf::internal::ArenaStringPtr php_class_prefix_;
+  ::google::protobuf::internal::ArenaStringPtr php_namespace_;
   bool java_multiple_files_;
   bool java_generate_equals_and_hash_;
   bool java_string_check_utf8_;
@@ -6554,13 +6572,13 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_
 
 // optional bool java_multiple_files = 10 [default = false];
 inline bool FileOptions::has_java_multiple_files() const {
-  return (_has_bits_[0] & 0x00000080u) != 0;
+  return (_has_bits_[0] & 0x00000100u) != 0;
 }
 inline void FileOptions::set_has_java_multiple_files() {
-  _has_bits_[0] |= 0x00000080u;
+  _has_bits_[0] |= 0x00000100u;
 }
 inline void FileOptions::clear_has_java_multiple_files() {
-  _has_bits_[0] &= ~0x00000080u;
+  _has_bits_[0] &= ~0x00000100u;
 }
 inline void FileOptions::clear_java_multiple_files() {
   java_multiple_files_ = false;
@@ -6578,13 +6596,13 @@ inline void FileOptions::set_java_multiple_files(bool value) {
 
 // optional bool java_generate_equals_and_hash = 20 [deprecated = true];
 inline bool FileOptions::has_java_generate_equals_and_hash() const {
-  return (_has_bits_[0] & 0x00000100u) != 0;
+  return (_has_bits_[0] & 0x00000200u) != 0;
 }
 inline void FileOptions::set_has_java_generate_equals_and_hash() {
-  _has_bits_[0] |= 0x00000100u;
+  _has_bits_[0] |= 0x00000200u;
 }
 inline void FileOptions::clear_has_java_generate_equals_and_hash() {
-  _has_bits_[0] &= ~0x00000100u;
+  _has_bits_[0] &= ~0x00000200u;
 }
 inline void FileOptions::clear_java_generate_equals_and_hash() {
   java_generate_equals_and_hash_ = false;
@@ -6602,13 +6620,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) {
 
 // optional bool java_string_check_utf8 = 27 [default = false];
 inline bool FileOptions::has_java_string_check_utf8() const {
-  return (_has_bits_[0] & 0x00000200u) != 0;
+  return (_has_bits_[0] & 0x00000400u) != 0;
 }
 inline void FileOptions::set_has_java_string_check_utf8() {
-  _has_bits_[0] |= 0x00000200u;
+  _has_bits_[0] |= 0x00000400u;
 }
 inline void FileOptions::clear_has_java_string_check_utf8() {
-  _has_bits_[0] &= ~0x00000200u;
+  _has_bits_[0] &= ~0x00000400u;
 }
 inline void FileOptions::clear_java_string_check_utf8() {
   java_string_check_utf8_ = false;
@@ -6626,13 +6644,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) {
 
 // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
 inline bool FileOptions::has_optimize_for() const {
-  return (_has_bits_[0] & 0x00008000u) != 0;
+  return (_has_bits_[0] & 0x00010000u) != 0;
 }
 inline void FileOptions::set_has_optimize_for() {
-  _has_bits_[0] |= 0x00008000u;
+  _has_bits_[0] |= 0x00010000u;
 }
 inline void FileOptions::clear_has_optimize_for() {
-  _has_bits_[0] &= ~0x00008000u;
+  _has_bits_[0] &= ~0x00010000u;
 }
 inline void FileOptions::clear_optimize_for() {
   optimize_for_ = 1;
@@ -6714,13 +6732,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) {
 
 // optional bool cc_generic_services = 16 [default = false];
 inline bool FileOptions::has_cc_generic_services() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
+  return (_has_bits_[0] & 0x00000800u) != 0;
 }
 inline void FileOptions::set_has_cc_generic_services() {
-  _has_bits_[0] |= 0x00000400u;
+  _has_bits_[0] |= 0x00000800u;
 }
 inline void FileOptions::clear_has_cc_generic_services() {
-  _has_bits_[0] &= ~0x00000400u;
+  _has_bits_[0] &= ~0x00000800u;
 }
 inline void FileOptions::clear_cc_generic_services() {
   cc_generic_services_ = false;
@@ -6738,13 +6756,13 @@ inline void FileOptions::set_cc_generic_services(bool value) {
 
 // optional bool java_generic_services = 17 [default = false];
 inline bool FileOptions::has_java_generic_services() const {
-  return (_has_bits_[0] & 0x00000800u) != 0;
+  return (_has_bits_[0] & 0x00001000u) != 0;
 }
 inline void FileOptions::set_has_java_generic_services() {
-  _has_bits_[0] |= 0x00000800u;
+  _has_bits_[0] |= 0x00001000u;
 }
 inline void FileOptions::clear_has_java_generic_services() {
-  _has_bits_[0] &= ~0x00000800u;
+  _has_bits_[0] &= ~0x00001000u;
 }
 inline void FileOptions::clear_java_generic_services() {
   java_generic_services_ = false;
@@ -6762,13 +6780,13 @@ inline void FileOptions::set_java_generic_services(bool value) {
 
 // optional bool py_generic_services = 18 [default = false];
 inline bool FileOptions::has_py_generic_services() const {
-  return (_has_bits_[0] & 0x00001000u) != 0;
+  return (_has_bits_[0] & 0x00002000u) != 0;
 }
 inline void FileOptions::set_has_py_generic_services() {
-  _has_bits_[0] |= 0x00001000u;
+  _has_bits_[0] |= 0x00002000u;
 }
 inline void FileOptions::clear_has_py_generic_services() {
-  _has_bits_[0] &= ~0x00001000u;
+  _has_bits_[0] &= ~0x00002000u;
 }
 inline void FileOptions::clear_py_generic_services() {
   py_generic_services_ = false;
@@ -6786,13 +6804,13 @@ inline void FileOptions::set_py_generic_services(bool value) {
 
 // optional bool deprecated = 23 [default = false];
 inline bool FileOptions::has_deprecated() const {
-  return (_has_bits_[0] & 0x00002000u) != 0;
+  return (_has_bits_[0] & 0x00004000u) != 0;
 }
 inline void FileOptions::set_has_deprecated() {
-  _has_bits_[0] |= 0x00002000u;
+  _has_bits_[0] |= 0x00004000u;
 }
 inline void FileOptions::clear_has_deprecated() {
-  _has_bits_[0] &= ~0x00002000u;
+  _has_bits_[0] &= ~0x00004000u;
 }
 inline void FileOptions::clear_deprecated() {
   deprecated_ = false;
@@ -6810,13 +6828,13 @@ inline void FileOptions::set_deprecated(bool value) {
 
 // optional bool cc_enable_arenas = 31 [default = false];
 inline bool FileOptions::has_cc_enable_arenas() const {
-  return (_has_bits_[0] & 0x00004000u) != 0;
+  return (_has_bits_[0] & 0x00008000u) != 0;
 }
 inline void FileOptions::set_has_cc_enable_arenas() {
-  _has_bits_[0] |= 0x00004000u;
+  _has_bits_[0] |= 0x00008000u;
 }
 inline void FileOptions::clear_has_cc_enable_arenas() {
-  _has_bits_[0] &= ~0x00004000u;
+  _has_bits_[0] &= ~0x00008000u;
 }
 inline void FileOptions::clear_cc_enable_arenas() {
   cc_enable_arenas_ = false;
@@ -7084,6 +7102,69 @@ inline void FileOptions::set_allocated_php_class_prefix(::std::string* php_class
   // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_class_prefix)
 }
 
+// optional string php_namespace = 41;
+inline bool FileOptions::has_php_namespace() const {
+  return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void FileOptions::set_has_php_namespace() {
+  _has_bits_[0] |= 0x00000080u;
+}
+inline void FileOptions::clear_has_php_namespace() {
+  _has_bits_[0] &= ~0x00000080u;
+}
+inline void FileOptions::clear_php_namespace() {
+  php_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  clear_has_php_namespace();
+}
+inline const ::std::string& FileOptions::php_namespace() const {
+  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace)
+  return php_namespace_.GetNoArena();
+}
+inline void FileOptions::set_php_namespace(const ::std::string& value) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace)
+}
+#if LANG_CXX11
+inline void FileOptions::set_php_namespace(::std::string&& value) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:google.protobuf.FileOptions.php_namespace)
+}
+#endif
+inline void FileOptions::set_php_namespace(const char* value) {
+  GOOGLE_DCHECK(value != NULL);
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.php_namespace)
+}
+inline void FileOptions::set_php_namespace(const char* value, size_t size) {
+  set_has_php_namespace();
+  php_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast(value), size));
+  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace)
+}
+inline ::std::string* FileOptions::mutable_php_namespace() {
+  set_has_php_namespace();
+  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace)
+  return php_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* FileOptions::release_php_namespace() {
+  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.php_namespace)
+  clear_has_php_namespace();
+  return php_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void FileOptions::set_allocated_php_namespace(::std::string* php_namespace) {
+  if (php_namespace != NULL) {
+    set_has_php_namespace();
+  } else {
+    clear_has_php_namespace();
+  }
+  php_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), php_namespace);
+  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.php_namespace)
+}
+
 // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
 inline int FileOptions::uninterpreted_option_size() const {
   return uninterpreted_option_.size();
diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto
index f859c429..c7fbaaf6 100644
--- a/src/google/protobuf/descriptor.proto
+++ b/src/google/protobuf/descriptor.proto
@@ -380,6 +380,11 @@ message FileOptions {
   // from this .proto. Default is empty.
   optional string php_class_prefix = 40;
 
+  // Use this option to change the namespace of php generated classes. Default
+  // is empty. When this option is empty, the package name will be used for
+  // determining the namespace.
+  optional string php_namespace = 41;
+
   // The parser stores options it doesn't recognize here. See above.
   repeated UninterpretedOption uninterpreted_option = 999;
 
diff --git a/tests.sh b/tests.sh
index 710389bc..5d11c857 100755
--- a/tests.sh
+++ b/tests.sh
@@ -346,7 +346,7 @@ generate_php_test_proto() {
   # Generate test file
   rm -rf generated
   mkdir generated
-  ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto proto/test_prefix.proto
+  ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto proto/test_prefix.proto proto/test_php_namespace.proto proto/test_empty_php_namespace.proto
   pushd ../../src
   ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto
   ./protoc --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto
-- 
cgit v1.2.3


From b9b34e9b1167d89c4df8f0abffe31262aebe7a39 Mon Sep 17 00:00:00 2001
From: Brent Shaffer 
Date: Wed, 14 Jun 2017 15:57:11 -0700
Subject: Follows proper autoloading standards (#3123)

* Follows proper autoloading standards
 - Splits PHP classes in descriptor.php into separate files
 - Splits MapFieldIter and RepeatedFieldIter into separate files
 - Moves descriptor.php to Internal/functions.php
 - Moves all namespaced functions into Iternal/functions.php

* fixes Makefile.am for added php files

* [PHP] moves all functions to GPBUtil

* removes description.php from the makefile
---
 Makefile.am                                        |   9 +-
 composer.json                                      |   5 +-
 php/composer.json                                  |   5 +-
 php/src/Google/Protobuf/Internal/Descriptor.php    | 167 ++++++
 .../Google/Protobuf/Internal/EnumDescriptor.php    |  56 ++
 .../Protobuf/Internal/EnumValueDescriptor.php      |  37 ++
 .../Google/Protobuf/Internal/FieldDescriptor.php   | 236 ++++++++
 .../Google/Protobuf/Internal/FileDescriptor.php    |  90 ++++
 php/src/Google/Protobuf/Internal/GPBUtil.php       | 100 +++-
 php/src/Google/Protobuf/Internal/InputStream.php   |  25 +-
 php/src/Google/Protobuf/Internal/MapField.php      | 181 ++-----
 php/src/Google/Protobuf/Internal/MapFieldIter.php  | 113 ++++
 .../Google/Protobuf/Internal/OneofDescriptor.php   |  67 +++
 php/src/Google/Protobuf/Internal/RepeatedField.php |  80 ---
 .../Google/Protobuf/Internal/RepeatedFieldIter.php | 118 ++++
 php/src/Google/Protobuf/descriptor.php             | 600 ---------------------
 16 files changed, 1048 insertions(+), 841 deletions(-)
 create mode 100644 php/src/Google/Protobuf/Internal/Descriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/EnumDescriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/EnumValueDescriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/FieldDescriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/FileDescriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/MapFieldIter.php
 create mode 100644 php/src/Google/Protobuf/Internal/OneofDescriptor.php
 create mode 100644 php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
 delete mode 100644 php/src/Google/Protobuf/descriptor.php

(limited to 'php/src/Google/Protobuf')

diff --git a/Makefile.am b/Makefile.am
index 385531ed..47fe4bb9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -597,36 +597,44 @@ php_EXTRA_DIST=                                                       \
   php/ext/google/protobuf/upb.c                                       \
   php/ext/google/protobuf/protobuf.c                                  \
   php/src/phpdoc.dist.xml                                             \
+  php/src/Google/Protobuf/Internal/Descriptor.php                     \
   php/src/Google/Protobuf/Internal/DescriptorPool.php                 \
   php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php              \
   php/src/Google/Protobuf/Internal/OneofField.php                     \
   php/src/Google/Protobuf/Internal/MessageOptions.php                 \
+  php/src/Google/Protobuf/Internal/FileDescriptor.php                 \
   php/src/Google/Protobuf/Internal/FileDescriptorProto.php            \
   php/src/Google/Protobuf/Internal/MapEntry.php                       \
+  php/src/Google/Protobuf/Internal/FieldDescriptor.php                \
   php/src/Google/Protobuf/Internal/FieldDescriptorProto.php           \
   php/src/Google/Protobuf/Internal/InputStream.php                    \
   php/src/Google/Protobuf/Internal/UninterpretedOption.php            \
   php/src/Google/Protobuf/Internal/ServiceOptions.php                 \
   php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \
   php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php         \
+  php/src/Google/Protobuf/Internal/OneofDescriptor.php                \
   php/src/Google/Protobuf/Internal/OneofDescriptorProto.php           \
   php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php   \
   php/src/Google/Protobuf/Internal/OutputStream.php                   \
   php/src/Google/Protobuf/Internal/MessageBuilderContext.php          \
+  php/src/Google/Protobuf/Internal/EnumValueDescriptor.php            \
   php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php       \
   php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php       \
   php/src/Google/Protobuf/Internal/DescriptorProto.php                \
   php/src/Google/Protobuf/Internal/MapField.php                       \
+  php/src/Google/Protobuf/Internal/MapFieldIter.php                   \
   php/src/Google/Protobuf/Internal/MethodDescriptorProto.php          \
   php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \
   php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php  \
   php/src/Google/Protobuf/Internal/RepeatedField.php                  \
+  php/src/Google/Protobuf/Internal/RepeatedFieldIter.php              \
   php/src/Google/Protobuf/Internal/EnumValueOptions.php               \
   php/src/Google/Protobuf/Internal/MethodOptions.php                  \
   php/src/Google/Protobuf/Internal/OneofOptions.php                   \
   php/src/Google/Protobuf/Internal/Message.php                        \
   php/src/Google/Protobuf/Internal/FileOptions.php                    \
   php/src/Google/Protobuf/Internal/FileDescriptorSet.php              \
+  php/src/Google/Protobuf/Internal/EnumDescriptor.php                 \
   php/src/Google/Protobuf/Internal/EnumDescriptorProto.php            \
   php/src/Google/Protobuf/Internal/GPBWire.php                        \
   php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php     \
@@ -643,7 +651,6 @@ php_EXTRA_DIST=                                                       \
   php/src/Google/Protobuf/Internal/GPBUtil.php                        \
   php/src/Google/Protobuf/Internal/FieldOptions_CType.php             \
   php/src/Google/Protobuf/Internal/GPBDecodeException.php             \
-  php/src/Google/Protobuf/descriptor.php                              \
   php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php         \
   php/tests/array_test.php                                            \
   php/tests/autoload.php                                              \
diff --git a/composer.json b/composer.json
index 2b04e079..5b6c7ee2 100644
--- a/composer.json
+++ b/composer.json
@@ -15,9 +15,6 @@
     "psr-4": {
       "Google\\Protobuf\\Internal\\": "php/src/Google/Protobuf/Internal",
       "GPBMetadata\\Google\\Protobuf\\Internal\\": "php/src/GPBMetadata/Google/Protobuf/Internal"
-    },
-    "files": [
-      "php/src/Google/Protobuf/descriptor.php"
-    ]
+    }
   }
 }
diff --git a/php/composer.json b/php/composer.json
index 32b0f44c..724a45dd 100644
--- a/php/composer.json
+++ b/php/composer.json
@@ -20,9 +20,6 @@
       "GPBMetadata\\": "tests/generated/GPBMetadata",
       "GPBMetadata\\Google\\Protobuf\\Internal\\": "src/GPBMetadata/Google/Protobuf/Internal",
       "": "tests/generated"
-    },
-    "files": [
-      "src/Google/Protobuf/descriptor.php"
-    ]
+    }
   }
 }
diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php
new file mode 100644
index 00000000..d0d1e259
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/Descriptor.php
@@ -0,0 +1,167 @@
+oneof_decl[] = $oneof;
+    }
+
+    public function getOneofDecl()
+    {
+        return $this->oneof_decl;
+    }
+
+    public function setFullName($full_name)
+    {
+        $this->full_name = $full_name;
+    }
+
+    public function getFullName()
+    {
+        return $this->full_name;
+    }
+
+    public function addField($field)
+    {
+        $this->field[$field->getNumber()] = $field;
+    }
+
+    public function getField()
+    {
+        return $this->field;
+    }
+
+    public function addNestedType($desc)
+    {
+        $this->nested_type[] = $desc;
+    }
+
+    public function getNestedType()
+    {
+        return $this->nested_type;
+    }
+
+    public function addEnumType($desc)
+    {
+        $this->enum_type[] = $desc;
+    }
+
+    public function getEnumType()
+    {
+        return $this->enum_type;
+    }
+
+    public function getFieldByNumber($number)
+    {
+      if (!isset($this->field[$number])) {
+        return NULL;
+      } else {
+        return $this->field[$number];
+      }
+    }
+
+    public function setClass($klass)
+    {
+        $this->klass = $klass;
+    }
+
+    public function getClass()
+    {
+        return $this->klass;
+    }
+
+    public function setOptions($options)
+    {
+        $this->options = $options;
+    }
+
+    public function getOptions()
+    {
+        return $this->options;
+    }
+
+    public static function buildFromProto($proto, $file_proto, $containing)
+    {
+        $desc = new Descriptor();
+
+        $message_name_without_package  = "";
+        $classname = "";
+        $fullname = "";
+        getFullClassName(
+            $proto,
+            $containing,
+            $file_proto,
+            $message_name_without_package,
+            $classname,
+            $fullname);
+        $desc->setFullName($fullname);
+        $desc->setClass($classname);
+        $desc->setOptions($proto->getOptions());
+
+        foreach ($proto->getField() as $field_proto) {
+            $desc->addField(FieldDescriptor::buildFromProto($field_proto));
+        }
+
+        // Handle nested types.
+        foreach ($proto->getNestedType() as $nested_proto) {
+            $desc->addNestedType(Descriptor::buildFromProto(
+              $nested_proto, $file_proto, $message_name_without_package));
+        }
+
+        // Handle nested enum.
+        foreach ($proto->getEnumType() as $enum_proto) {
+            $desc->addEnumType(EnumDescriptor::buildFromProto(
+              $enum_proto, $file_proto, $message_name_without_package));
+        }
+
+        // Handle oneof fields.
+        foreach ($proto->getOneofDecl() as $oneof_proto) {
+            $desc->addOneofDecl(
+                OneofDescriptor::buildFromProto($oneof_proto, $desc));
+        }
+
+        return $desc;
+    }
+}
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
new file mode 100644
index 00000000..7360a477
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
@@ -0,0 +1,56 @@
+full_name = $full_name;
+    }
+
+    public function getFullName()
+    {
+        return $this->full_name;
+    }
+
+    public function addValue($number, $value)
+    {
+        $this->value[$number] = $value;
+    }
+
+    public function setClass($klass)
+    {
+        $this->klass = $klass;
+    }
+
+    public function getClass()
+    {
+        return $this->klass;
+    }
+
+    public static function buildFromProto($proto, $file_proto, $containing)
+    {
+        $desc = new EnumDescriptor();
+
+        $enum_name_without_package  = "";
+        $classname = "";
+        $fullname = "";
+        GPBUtil::getFullClassName(
+            $proto,
+            $containing,
+            $file_proto,
+            $enum_name_without_package,
+            $classname,
+            $fullname);
+        $desc->setFullName($fullname);
+        $desc->setClass($classname);
+
+        return $desc;
+    }
+}
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php
new file mode 100644
index 00000000..e65a4e8d
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php
@@ -0,0 +1,37 @@
+oneof_index = $index;
+    }
+
+    public function getOneofIndex()
+    {
+        return $this->oneof_index;
+    }
+
+    public function setName($name)
+    {
+        $this->name = $name;
+    }
+
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    public function setSetter($setter)
+    {
+        $this->setter = $setter;
+    }
+
+    public function getSetter()
+    {
+        return $this->setter;
+    }
+
+    public function setGetter($getter)
+    {
+        $this->getter = $getter;
+    }
+
+    public function getGetter()
+    {
+        return $this->getter;
+    }
+
+    public function setNumber($number)
+    {
+        $this->number = $number;
+    }
+
+    public function getNumber()
+    {
+        return $this->number;
+    }
+
+    public function setLabel($label)
+    {
+        $this->label = $label;
+    }
+
+    public function getLabel()
+    {
+        return $this->label;
+    }
+
+    public function isRepeated()
+    {
+        return $this->label === GPBLabel::REPEATED;
+    }
+
+    public function setType($type)
+    {
+        $this->type = $type;
+    }
+
+    public function getType()
+    {
+        return $this->type;
+    }
+
+    public function setMessageType($message_type)
+    {
+        $this->message_type = $message_type;
+    }
+
+    public function getMessageType()
+    {
+        return $this->message_type;
+    }
+
+    public function setEnumType($enum_type)
+    {
+        $this->enum_type = $enum_type;
+    }
+
+    public function getEnumType()
+    {
+        return $this->enum_type;
+    }
+
+    public function setPacked($packed)
+    {
+        $this->packed = $packed;
+    }
+
+    public function getPacked()
+    {
+        return $this->packed;
+    }
+
+    public function isPackable()
+    {
+        return $this->isRepeated() && self::isTypePackable($this->type);
+    }
+
+    public function isMap()
+    {
+        return $this->getType() == GPBType::MESSAGE &&
+               !is_null($this->getMessageType()->getOptions()) &&
+               $this->getMessageType()->getOptions()->getMapEntry();
+    }
+
+    private static function isTypePackable($field_type)
+    {
+        return ($field_type !== GPBType::STRING  &&
+            $field_type !== GPBType::GROUP   &&
+            $field_type !== GPBType::MESSAGE &&
+            $field_type !== GPBType::BYTES);
+    }
+
+    public static function getFieldDescriptor(
+        $name,
+        $label,
+        $type,
+        $number,
+        $oneof_index,
+        $packed,
+        $type_name = null)
+    {
+        $field = new FieldDescriptor();
+        $field->setName($name);
+        $camel_name = implode('', array_map('ucwords', explode('_', $name)));
+        $field->setGetter('get' . $camel_name);
+        $field->setSetter('set' . $camel_name);
+        $field->setType($type);
+        $field->setNumber($number);
+        $field->setLabel($label);
+        $field->setPacked($packed);
+        $field->setOneofIndex($oneof_index);
+
+        // At this time, the message/enum type may have not been added to pool.
+        // So we use the type name as place holder and will replace it with the
+        // actual descriptor in cross building.
+        switch ($type) {
+            case GPBType::MESSAGE:
+                $field->setMessageType($type_name);
+                break;
+            case GPBType::ENUM:
+                $field->setEnumType($type_name);
+                break;
+            default:
+                break;
+        }
+
+        return $field;
+    }
+
+    public static function buildFromProto($proto)
+    {
+        $type_name = null;
+        switch ($proto->getType()) {
+            case GPBType::MESSAGE:
+            case GPBType::GROUP:
+            case GPBType::ENUM:
+                $type_name = $proto->getTypeName();
+                break;
+            default:
+                break;
+        }
+
+        $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1;
+        $packed = false;
+        $options = $proto->getOptions();
+        if ($options !== null) {
+            $packed = $options->getPacked();
+        }
+
+        return FieldDescriptor::getFieldDescriptor(
+            $proto->getName(), $proto->getLabel(), $proto->getType(),
+            $proto->getNumber(), $oneof_index, $packed, $type_name);
+    }
+}
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptor.php b/php/src/Google/Protobuf/Internal/FileDescriptor.php
new file mode 100644
index 00000000..14716390
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/FileDescriptor.php
@@ -0,0 +1,90 @@
+package = $package;
+    }
+
+    public function getPackage()
+    {
+        return $this->package;
+    }
+
+    public function getMessageType()
+    {
+        return $this->message_type;
+    }
+
+    public function addMessageType($desc)
+    {
+        $this->message_type[] = $desc;
+    }
+
+    public function getEnumType()
+    {
+        return $this->enum_type;
+    }
+
+    public function addEnumType($desc)
+    {
+        $this->enum_type[]= $desc;
+    }
+
+    public static function buildFromProto($proto)
+    {
+        $file = new FileDescriptor();
+        $file->setPackage($proto->getPackage());
+        foreach ($proto->getMessageType() as $message_proto) {
+            $file->addMessageType(Descriptor::buildFromProto(
+                $message_proto, $proto, ""));
+        }
+        foreach ($proto->getEnumType() as $enum_proto) {
+            $file->getEnumType()[] =
+                $file->addEnumType(
+                    EnumDescriptor::buildFromProto(
+                        $enum_proto,
+                        $proto,
+                        ""));
+        }
+        return $file;
+    }
+}
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 0e66ae6f..1b71f7b7 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -67,7 +67,6 @@ class GPBUtil
         }
     }
 
-
     public static function checkString(&$var, $check_utf8)
     {
         if (is_array($var) || is_object($var)) {
@@ -242,4 +241,103 @@ class GPBUtil
     {
         return new Uint64($value);
     }
+
+    public static function getClassNamePrefix(
+        $classname,
+        $file_proto)
+    {
+        $option = $file_proto->getOptions();
+        $prefix = is_null($option) ? "" : $option->getPhpClassPrefix();
+        if ($prefix !== "") {
+            return $prefix;
+        }
+
+        $reserved_words = array("Empty");
+        foreach ($reserved_words as $reserved_word) {
+            if ($classname === $reserved_word) {
+                if ($file_proto->getPackage() === "google.protobuf") {
+                    return "GPB";
+                } else {
+                    return "PB";
+                }
+            }
+        }
+
+        return "";
+    }
+
+    public static function getClassNameWithoutPackage(
+        $name,
+        $file_proto)
+    {
+        $classname = implode('_', array_map('ucwords', explode('.', $name)));
+        return static::getClassNamePrefix($classname, $file_proto) . $classname;
+    }
+
+    public static function getFullClassName(
+        $proto,
+        $containing,
+        $file_proto,
+        &$message_name_without_package,
+        &$classname,
+        &$fullname)
+    {
+        // Full name needs to start with '.'.
+        $message_name_without_package = $proto->getName();
+        if ($containing !== "") {
+            $message_name_without_package =
+                $containing . "." . $message_name_without_package;
+        }
+
+        $package = $file_proto->getPackage();
+        if ($package === "") {
+            $fullname = "." . $message_name_without_package;
+        } else {
+            $fullname = "." . $package . "." . $message_name_without_package;
+        }
+
+        $class_name_without_package =
+            static::getClassNameWithoutPackage($message_name_without_package, $file_proto);
+
+        $option = $file_proto->getOptions();
+        if (!is_null($option) && $option->hasPhpNamespace()) {
+            $namespace = $option->getPhpNamespace();
+            if ($namespace !== "") {
+                $classname = $namespace . "\\" . $class_name_without_package;
+                return;
+            } else {
+                $classname = $class_name_without_package;
+                return;
+            }
+        }
+
+        if ($package === "") {
+            $classname = $class_name_without_package;
+        } else {
+            $classname =
+                implode('\\', array_map('ucwords', explode('.', $package))).
+                "\\".$class_name_without_package;
+        }
+    }
+
+    public static function combineInt32ToInt64($high, $low)
+    {
+        $isNeg = $high < 0;
+        if ($isNeg) {
+            $high = ~$high;
+            $low = ~$low;
+            $low++;
+            if (!$low) {
+                $high++;
+            }
+        }
+        $result = bcadd(bcmul($high, 4294967296), $low);
+        if ($low < 0) {
+            $result = bcadd($result, 4294967296);
+        }
+        if ($isNeg) {
+          $result = bcsub(0, $result);
+        }
+        return $result;
+    }
 }
diff --git a/php/src/Google/Protobuf/Internal/InputStream.php b/php/src/Google/Protobuf/Internal/InputStream.php
index 8012a225..f84e1aee 100644
--- a/php/src/Google/Protobuf/Internal/InputStream.php
+++ b/php/src/Google/Protobuf/Internal/InputStream.php
@@ -34,27 +34,6 @@ namespace Google\Protobuf\Internal;
 
 use Google\Protobuf\Internal\Uint64;
 
-function combineInt32ToInt64($high, $low)
-{
-    $isNeg = $high < 0;
-    if ($isNeg) {
-        $high = ~$high;
-        $low = ~$low;
-        $low++;
-        if (!$low) {
-            $high++;
-        }
-    }
-    $result = bcadd(bcmul($high, 4294967296), $low);
-    if ($low < 0) {
-        $result = bcadd($result, 4294967296);
-    }
-    if ($isNeg) {
-      $result = bcsub(0, $result);
-    }
-    return $result;
-}
-
 class InputStream
 {
 
@@ -192,7 +171,7 @@ class InputStream
                 $count += 1;
             } while ($b & 0x80);
 
-            $var = combineInt32ToInt64($high, $low);
+            $var = GPBUtil::combineInt32ToInt64($high, $low);
         } else {
             $result = 0;
             $shift = 0;
@@ -265,7 +244,7 @@ class InputStream
         }
         $high = unpack('V', $data)[1];
         if (PHP_INT_SIZE == 4) {
-            $var = combineInt32ToInt64($high, $low);
+            $var = GPBUtil::combineInt32ToInt64($high, $low);
         } else {
             $var = ($high << 32) | $low;
         }
diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php
index 55cc12ce..12f09d61 100644
--- a/php/src/Google/Protobuf/Internal/MapField.php
+++ b/php/src/Google/Protobuf/Internal/MapField.php
@@ -37,131 +37,6 @@
 
 namespace Google\Protobuf\Internal;
 
-/**
- * MapFieldIter is used to iterate MapField. It is also need for the foreach
- * syntax.
- */
-class MapFieldIter implements \Iterator
-{
-
-    /**
-     * @ignore
-     */
-    private $container;
-
-    /**
-     * Create iterator instance for MapField.
-     *
-     * @param MapField The MapField instance for which this iterator is
-     * created.
-     * @ignore
-     */
-    public function __construct($container)
-    {
-        $this->container = $container;
-    }
-
-    /**
-     * Reset the status of the iterator
-     *
-     * @return void
-     */
-    public function rewind()
-    {
-        return reset($this->container);
-    }
-
-    /**
-     * Return the element at the current position.
-     *
-     * @return object The element at the current position.
-     */
-    public function current()
-    {
-        return current($this->container);
-    }
-
-    /**
-     * Return the current key.
-     *
-     * @return object The current key.
-     */
-    public function key()
-    {
-        return key($this->container);
-    }
-
-    /**
-     * Move to the next position.
-     *
-     * @return void
-     */
-    public function next()
-    {
-        return next($this->container);
-    }
-
-    /**
-     * Check whether there are more elements to iterate.
-     *
-     * @return bool True if there are more elements to iterate.
-     */
-    public function valid()
-    {
-        return key($this->container) !== null;
-    }
-}
-
-/**
- * @ignore
- */
-function checkKey($key_type, &$key)
-{
-    switch ($key_type) {
-        case GPBType::INT32:
-            GPBUtil::checkInt32($key);
-            break;
-        case GPBType::UINT32:
-            GPBUtil::checkUint32($key);
-            break;
-        case GPBType::INT64:
-            GPBUtil::checkInt64($key);
-            break;
-        case GPBType::UINT64:
-            GPBUtil::checkUint64($key);
-            break;
-        case GPBType::FIXED64:
-            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;
-        case GPBType::STRING:
-            GPBUtil::checkString($key, true);
-            break;
-        default:
-            trigger_error(
-                "Given type cannot be map key.",
-                E_USER_ERROR);
-            break;
-    }
-}
-
 /**
  * MapField is used by generated protocol message classes to manipulate map
  * fields. It can be used like native PHP array.
@@ -255,7 +130,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function offsetSet($key, $value)
     {
-        checkKey($this->key_type, $key);
+        $this->checkKey($this->key_type, $key);
 
         switch ($this->value_type) {
             case GPBType::INT32:
@@ -306,7 +181,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function offsetUnset($key)
     {
-        checkKey($this->key_type, $key);
+        $this->checkKey($this->key_type, $key);
         unset($this->container[$key]);
     }
 
@@ -321,7 +196,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
      */
     public function offsetExists($key)
     {
-        checkKey($this->key_type, $key);
+        $this->checkKey($this->key_type, $key);
         return isset($this->container[$key]);
     }
 
@@ -344,4 +219,54 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
     {
         return count($this->container);
     }
+
+    /**
+     * @ignore
+     */
+    private function checkKey($key_type, &$key)
+    {
+        switch ($key_type) {
+            case GPBType::INT32:
+                GPBUtil::checkInt32($key);
+                break;
+            case GPBType::UINT32:
+                GPBUtil::checkUint32($key);
+                break;
+            case GPBType::INT64:
+                GPBUtil::checkInt64($key);
+                break;
+            case GPBType::UINT64:
+                GPBUtil::checkUint64($key);
+                break;
+            case GPBType::FIXED64:
+                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;
+            case GPBType::STRING:
+                GPBUtil::checkString($key, true);
+                break;
+            default:
+                trigger_error(
+                    "Given type cannot be map key.",
+                    E_USER_ERROR);
+                break;
+        }
+    }
 }
diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php
new file mode 100644
index 00000000..a0388d92
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php
@@ -0,0 +1,113 @@
+container = $container;
+    }
+
+    /**
+     * Reset the status of the iterator
+     *
+     * @return void
+     */
+    public function rewind()
+    {
+        return reset($this->container);
+    }
+
+    /**
+     * Return the element at the current position.
+     *
+     * @return object The element at the current position.
+     */
+    public function current()
+    {
+        return current($this->container);
+    }
+
+    /**
+     * Return the current key.
+     *
+     * @return object The current key.
+     */
+    public function key()
+    {
+        return key($this->container);
+    }
+
+    /**
+     * Move to the next position.
+     *
+     * @return void
+     */
+    public function next()
+    {
+        return next($this->container);
+    }
+
+    /**
+     * Check whether there are more elements to iterate.
+     *
+     * @return bool True if there are more elements to iterate.
+     */
+    public function valid()
+    {
+        return key($this->container) !== null;
+    }
+}
\ No newline at end of file
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptor.php b/php/src/Google/Protobuf/Internal/OneofDescriptor.php
new file mode 100644
index 00000000..04988737
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptor.php
@@ -0,0 +1,67 @@
+name = $name;
+    }
+
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    public function addField(&$field)
+    {
+        $this->fields[] = $field;
+    }
+
+    public function getFields()
+    {
+        return $this->fields;
+    }
+
+    public static function buildFromProto($oneof_proto)
+    {
+        $oneof = new OneofDescriptor();
+        $oneof->setName($oneof_proto->getName());
+        return $oneof;
+    }
+}
diff --git a/php/src/Google/Protobuf/Internal/RepeatedField.php b/php/src/Google/Protobuf/Internal/RepeatedField.php
index 2ad4709a..797b3b3a 100644
--- a/php/src/Google/Protobuf/Internal/RepeatedField.php
+++ b/php/src/Google/Protobuf/Internal/RepeatedField.php
@@ -40,86 +40,6 @@ namespace Google\Protobuf\Internal;
 use Google\Protobuf\Internal\GPBType;
 use Google\Protobuf\Internal\GPBUtil;
 
-/**
- * RepeatedFieldIter is used to iterate RepeatedField. It is also need for the
- * foreach syntax.
- */
-class RepeatedFieldIter implements \Iterator
-{
-
-    /**
-     * @ignore
-     */
-    private $position;
-    /**
-     * @ignore
-     */
-    private $container;
-
-    /**
-     * Create iterator instance for RepeatedField.
-     *
-     * @param RepeatedField The RepeatedField instance for which this iterator
-     * is created.
-     * @ignore
-     */
-    public function __construct($container)
-    {
-        $this->position = 0;
-        $this->container = $container;
-    }
-
-    /**
-     * Reset the status of the iterator
-     *
-     * @return void
-     */
-    public function rewind()
-    {
-        $this->position = 0;
-    }
-
-    /**
-     * Return the element at the current position.
-     *
-     * @return object The element at the current position.
-     */
-    public function current()
-    {
-        return $this->container[$this->position];
-    }
-
-    /**
-     * Return the current position.
-     *
-     * @return integer The current position.
-     */
-    public function key()
-    {
-        return $this->position;
-    }
-
-    /**
-     * Move to the next position.
-     *
-     * @return void
-     */
-    public function next()
-    {
-        ++$this->position;
-    }
-
-    /**
-     * Check whether there are more elements to iterate.
-     *
-     * @return bool True if there are more elements to iterate.
-     */
-    public function valid()
-    {
-        return isset($this->container[$this->position]);
-    }
-}
-
 /**
  * RepeatedField is used by generated protocol message classes to manipulate
  * repeated fields. It can be used like native PHP array.
diff --git a/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php b/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
new file mode 100644
index 00000000..2b6f8230
--- /dev/null
+++ b/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
@@ -0,0 +1,118 @@
+position = 0;
+        $this->container = $container;
+    }
+
+    /**
+     * Reset the status of the iterator
+     *
+     * @return void
+     */
+    public function rewind()
+    {
+        $this->position = 0;
+    }
+
+    /**
+     * Return the element at the current position.
+     *
+     * @return object The element at the current position.
+     */
+    public function current()
+    {
+        return $this->container[$this->position];
+    }
+
+    /**
+     * Return the current position.
+     *
+     * @return integer The current position.
+     */
+    public function key()
+    {
+        return $this->position;
+    }
+
+    /**
+     * Move to the next position.
+     *
+     * @return void
+     */
+    public function next()
+    {
+        ++$this->position;
+    }
+
+    /**
+     * Check whether there are more elements to iterate.
+     *
+     * @return bool True if there are more elements to iterate.
+     */
+    public function valid()
+    {
+        return isset($this->container[$this->position]);
+    }
+}
diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php
deleted file mode 100644
index b7a3a550..00000000
--- a/php/src/Google/Protobuf/descriptor.php
+++ /dev/null
@@ -1,600 +0,0 @@
-package = $package;
-    }
-
-    public function getPackage()
-    {
-        return $this->package;
-    }
-
-    public function getMessageType()
-    {
-        return $this->message_type;
-    }
-
-    public function addMessageType($desc)
-    {
-        $this->message_type[] = $desc;
-    }
-
-    public function getEnumType()
-    {
-        return $this->enum_type;
-    }
-
-    public function addEnumType($desc)
-    {
-        $this->enum_type[]= $desc;
-    }
-
-    public static function buildFromProto($proto)
-    {
-        $file = new FileDescriptor();
-        $file->setPackage($proto->getPackage());
-        foreach ($proto->getMessageType() as $message_proto) {
-            $file->addMessageType(Descriptor::buildFromProto(
-                $message_proto, $proto, ""));
-        }
-        foreach ($proto->getEnumType() as $enum_proto) {
-            $file->getEnumType()[] =
-                $file->addEnumType(
-                    EnumDescriptor::buildFromProto(
-                        $enum_proto,
-                        $proto,
-                        ""));
-        }
-        return $file;
-    }
-}
-
-class Descriptor
-{
-
-    private $full_name;
-    private $field = [];
-    private $nested_type = [];
-    private $enum_type = [];
-    private $klass;
-    private $options;
-    private $oneof_decl = [];
-
-    public function addOneofDecl($oneof)
-    {
-        $this->oneof_decl[] = $oneof;
-    }
-
-    public function getOneofDecl()
-    {
-        return $this->oneof_decl;
-    }
-
-    public function setFullName($full_name)
-    {
-        $this->full_name = $full_name;
-    }
-
-    public function getFullName()
-    {
-        return $this->full_name;
-    }
-
-    public function addField($field)
-    {
-        $this->field[$field->getNumber()] = $field;
-    }
-
-    public function getField()
-    {
-        return $this->field;
-    }
-
-    public function addNestedType($desc)
-    {
-        $this->nested_type[] = $desc;
-    }
-
-    public function getNestedType()
-    {
-        return $this->nested_type;
-    }
-
-    public function addEnumType($desc)
-    {
-        $this->enum_type[] = $desc;
-    }
-
-    public function getEnumType()
-    {
-        return $this->enum_type;
-    }
-
-    public function getFieldByNumber($number)
-    {
-      if (!isset($this->field[$number])) {
-        return NULL;
-      } else {
-        return $this->field[$number];
-      }
-    }
-
-    public function setClass($klass)
-    {
-        $this->klass = $klass;
-    }
-
-    public function getClass()
-    {
-        return $this->klass;
-    }
-
-    public function setOptions($options)
-    {
-        $this->options = $options;
-    }
-
-    public function getOptions()
-    {
-        return $this->options;
-    }
-
-    public static function buildFromProto($proto, $file_proto, $containing)
-    {
-        $desc = new Descriptor();
-
-        $message_name_without_package  = "";
-        $classname = "";
-        $fullname = "";
-        getFullClassName(
-            $proto,
-            $containing,
-            $file_proto,
-            $message_name_without_package,
-            $classname,
-            $fullname);
-        $desc->setFullName($fullname);
-        $desc->setClass($classname);
-        $desc->setOptions($proto->getOptions());
-
-        foreach ($proto->getField() as $field_proto) {
-            $desc->addField(FieldDescriptor::buildFromProto($field_proto));
-        }
-
-        // Handle nested types.
-        foreach ($proto->getNestedType() as $nested_proto) {
-            $desc->addNestedType(Descriptor::buildFromProto(
-              $nested_proto, $file_proto, $message_name_without_package));
-        }
-
-        // Handle nested enum.
-        foreach ($proto->getEnumType() as $enum_proto) {
-            $desc->addEnumType(EnumDescriptor::buildFromProto(
-              $enum_proto, $file_proto, $message_name_without_package));
-        }
-
-        // Handle oneof fields.
-        foreach ($proto->getOneofDecl() as $oneof_proto) {
-            $desc->addOneofDecl(
-                OneofDescriptor::buildFromProto($oneof_proto, $desc));
-        }
-
-        return $desc;
-    }
-}
-
-function getClassNamePrefix(
-    $classname,
-    $file_proto)
-{
-    $option = $file_proto->getOptions();
-    $prefix = is_null($option) ? "" : $option->getPhpClassPrefix();
-    if ($prefix !== "") {
-        return $prefix;
-    }
-
-    $reserved_words = array("Empty", "ECHO", "ARRAY");
-    foreach ($reserved_words as $reserved_word) {
-        if ($classname === $reserved_word) {
-            if ($file_proto->getPackage() === "google.protobuf") {
-                return "GPB";
-            } else {
-                return "PB";
-            }
-        }
-    }
-
-    return "";
-}
-
-function getClassNameWithoutPackage(
-    $name,
-    $file_proto)
-{
-    $classname = implode('_', array_map('ucwords', explode('.', $name)));
-    return getClassNamePrefix($classname, $file_proto) . $classname;
-}
-
-function getFullClassName(
-    $proto,
-    $containing,
-    $file_proto,
-    &$message_name_without_package,
-    &$classname,
-    &$fullname)
-{
-    // Full name needs to start with '.'.
-    $message_name_without_package = $proto->getName();
-    if ($containing !== "") {
-        $message_name_without_package =
-            $containing . "." . $message_name_without_package;
-    }
-
-    $package = $file_proto->getPackage();
-    if ($package === "") {
-        $fullname = "." . $message_name_without_package;
-    } else {
-        $fullname = "." . $package . "." . $message_name_without_package;
-    }
-
-    $class_name_without_package =
-        getClassNameWithoutPackage($message_name_without_package, $file_proto);
-
-    $option = $file_proto->getOptions();
-    if (!is_null($option) && $option->hasPhpNamespace()) {
-        $namespace = $option->getPhpNamespace();
-        if ($namespace !== "") {
-            $classname = $namespace . "\\" . $class_name_without_package;
-            return;
-        } else {
-            $classname = $class_name_without_package;
-            return;
-        }
-    }
-
-    if ($package === "") {
-        $classname = $class_name_without_package;
-    } else {
-        $classname =
-            implode('\\', array_map('ucwords', explode('.', $package))).
-            "\\".$class_name_without_package;
-    }
-}
-
-class OneofDescriptor
-{
-
-    private $name;
-    private $fields;
-
-    public function setName($name)
-    {
-        $this->name = $name;
-    }
-
-    public function getName()
-    {
-        return $this->name;
-    }
-
-    public function addField(&$field)
-    {
-        $this->fields[] = $field;
-    }
-
-    public function getFields()
-    {
-        return $this->fields;
-    }
-
-    public static function buildFromProto($oneof_proto)
-    {
-        $oneof = new OneofDescriptor();
-        $oneof->setName($oneof_proto->getName());
-        return $oneof;
-    }
-}
-
-
-class EnumDescriptor
-{
-
-    private $klass;
-    private $full_name;
-    private $value;
-
-    public function setFullName($full_name)
-    {
-        $this->full_name = $full_name;
-    }
-
-    public function getFullName()
-    {
-        return $this->full_name;
-    }
-
-    public function addValue($number, $value)
-    {
-        $this->value[$number] = $value;
-    }
-
-    public function setClass($klass)
-    {
-        $this->klass = $klass;
-    }
-
-    public function getClass()
-    {
-        return $this->klass;
-    }
-
-    public static function buildFromProto($proto, $file_proto, $containing)
-    {
-        $desc = new EnumDescriptor();
-
-        $enum_name_without_package  = "";
-        $classname = "";
-        $fullname = "";
-        getFullClassName(
-            $proto,
-            $containing,
-            $file_proto,
-            $enum_name_without_package,
-            $classname,
-            $fullname);
-        $desc->setFullName($fullname);
-        $desc->setClass($classname);
-
-        return $desc;
-    }
-}
-
-class EnumValueDescriptor
-{
-}
-
-class FieldDescriptor
-{
-
-    private $name;
-    private $setter;
-    private $getter;
-    private $number;
-    private $label;
-    private $type;
-    private $message_type;
-    private $enum_type;
-    private $packed;
-    private $is_map;
-    private $oneof_index = -1;
-
-    public function setOneofIndex($index)
-    {
-        $this->oneof_index = $index;
-    }
-
-    public function getOneofIndex()
-    {
-        return $this->oneof_index;
-    }
-
-    public function setName($name)
-    {
-        $this->name = $name;
-    }
-
-    public function getName()
-    {
-        return $this->name;
-    }
-
-    public function setSetter($setter)
-    {
-        $this->setter = $setter;
-    }
-
-    public function getSetter()
-    {
-        return $this->setter;
-    }
-
-    public function setGetter($getter)
-    {
-        $this->getter = $getter;
-    }
-
-    public function getGetter()
-    {
-        return $this->getter;
-    }
-
-    public function setNumber($number)
-    {
-        $this->number = $number;
-    }
-
-    public function getNumber()
-    {
-        return $this->number;
-    }
-
-    public function setLabel($label)
-    {
-        $this->label = $label;
-    }
-
-    public function getLabel()
-    {
-        return $this->label;
-    }
-
-    public function isRepeated()
-    {
-        return $this->label === GPBLabel::REPEATED;
-    }
-
-    public function setType($type)
-    {
-        $this->type = $type;
-    }
-
-    public function getType()
-    {
-        return $this->type;
-    }
-
-    public function setMessageType($message_type)
-    {
-        $this->message_type = $message_type;
-    }
-
-    public function getMessageType()
-    {
-        return $this->message_type;
-    }
-
-    public function setEnumType($enum_type)
-    {
-        $this->enum_type = $enum_type;
-    }
-
-    public function getEnumType()
-    {
-        return $this->enum_type;
-    }
-
-    public function setPacked($packed)
-    {
-        $this->packed = $packed;
-    }
-
-    public function getPacked()
-    {
-        return $this->packed;
-    }
-
-    public function isPackable()
-    {
-        return $this->isRepeated() && self::isTypePackable($this->type);
-    }
-
-    public function isMap()
-    {
-        return $this->getType() == GPBType::MESSAGE &&
-               !is_null($this->getMessageType()->getOptions()) &&
-               $this->getMessageType()->getOptions()->getMapEntry();
-    }
-
-    private static function isTypePackable($field_type)
-    {
-        return ($field_type !== GPBType::STRING  &&
-            $field_type !== GPBType::GROUP   &&
-            $field_type !== GPBType::MESSAGE &&
-            $field_type !== GPBType::BYTES);
-    }
-
-    public static function getFieldDescriptor(
-        $name,
-        $label,
-        $type,
-        $number,
-        $oneof_index,
-        $packed,
-        $type_name = null)
-    {
-        $field = new FieldDescriptor();
-        $field->setName($name);
-        $camel_name = implode('', array_map('ucwords', explode('_', $name)));
-        $field->setGetter('get' . $camel_name);
-        $field->setSetter('set' . $camel_name);
-        $field->setType($type);
-        $field->setNumber($number);
-        $field->setLabel($label);
-        $field->setPacked($packed);
-        $field->setOneofIndex($oneof_index);
-
-        // At this time, the message/enum type may have not been added to pool.
-        // So we use the type name as place holder and will replace it with the
-        // actual descriptor in cross building.
-        switch ($type) {
-            case GPBType::MESSAGE:
-                $field->setMessageType($type_name);
-                break;
-            case GPBType::ENUM:
-                $field->setEnumType($type_name);
-                break;
-            default:
-                break;
-        }
-
-        return $field;
-    }
-
-    public static function buildFromProto($proto)
-    {
-        $type_name = null;
-        switch ($proto->getType()) {
-            case GPBType::MESSAGE:
-            case GPBType::GROUP:
-            case GPBType::ENUM:
-                $type_name = $proto->getTypeName();
-                break;
-            default:
-                break;
-        }
-
-        $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1;
-        $packed = false;
-        $options = $proto->getOptions();
-        if ($options !== null) {
-            $packed = $options->getPacked();
-        }
-
-        return FieldDescriptor::getFieldDescriptor(
-            $proto->getName(), $proto->getLabel(), $proto->getType(),
-            $proto->getNumber(), $oneof_index, $packed, $type_name);
-    }
-}
-- 
cgit v1.2.3


From 8d97b3d8b5a33650e822460b3b561802c969e86e Mon Sep 17 00:00:00 2001
From: michaelbausor 
Date: Thu, 15 Jun 2017 10:49:24 -0700
Subject: Fix incorrect function call (#3232)

---
 php/src/Google/Protobuf/Internal/Descriptor.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'php/src/Google/Protobuf')

diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php
index d0d1e259..f8d24e45 100644
--- a/php/src/Google/Protobuf/Internal/Descriptor.php
+++ b/php/src/Google/Protobuf/Internal/Descriptor.php
@@ -129,7 +129,7 @@ class Descriptor
         $message_name_without_package  = "";
         $classname = "";
         $fullname = "";
-        getFullClassName(
+        GPBUtil::getFullClassName(
             $proto,
             $containing,
             $file_proto,
-- 
cgit v1.2.3


From 91bf623aa145cd1576451ed3764a64a089384ac4 Mon Sep 17 00:00:00 2001
From: Paul Yang 
Date: Thu, 15 Jun 2017 13:04:08 -0700
Subject: Fix php jenkins test (#3233)

Update commit id to upload latest composer.
Compile php with bc-math for future json support.
---
 jenkins/docker/Dockerfile                    | 8 ++++----
 jenkins/docker32/Dockerfile                  | 2 +-
 php/src/Google/Protobuf/Internal/GPBUtil.php | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

(limited to 'php/src/Google/Protobuf')

diff --git a/jenkins/docker/Dockerfile b/jenkins/docker/Dockerfile
index 6a9e7e47..fcebe167 100644
--- a/jenkins/docker/Dockerfile
+++ b/jenkins/docker/Dockerfile
@@ -145,7 +145,7 @@ RUN mv mirror php-5.5.38.tar.bz2
 RUN tar -xvf php-5.5.38.tar.bz2
 RUN cd php-5.5.38 && ./configure --enable-maintainer-zts --prefix=/usr/local/php-5.5-zts && \
     make && make install && cd ..
-RUN cd php-5.5.38 && make clean && ./configure --prefix=/usr/local/php-5.5 && \
+RUN cd php-5.5.38 && make clean && ./configure --enable-bcmath --prefix=/usr/local/php-5.5 && \
     make && make install && cd ..
 
 RUN wget http://am1.php.net/get/php-5.6.30.tar.bz2/from/this/mirror
@@ -153,7 +153,7 @@ RUN mv mirror php-5.6.30.tar.bz2
 RUN tar -xvf php-5.6.30.tar.bz2
 RUN cd php-5.6.30 && ./configure --enable-maintainer-zts --prefix=/usr/local/php-5.6-zts && \
     make && make install && cd ..
-RUN cd php-5.6.30 && make clean && ./configure --prefix=/usr/local/php-5.6 && \
+RUN cd php-5.6.30 && make clean && ./configure --enable-bcmath --prefix=/usr/local/php-5.6 && \
     make && make install && cd ..
 
 RUN wget http://am1.php.net/get/php-7.0.18.tar.bz2/from/this/mirror
@@ -161,7 +161,7 @@ RUN mv mirror php-7.0.18.tar.bz2
 RUN tar -xvf php-7.0.18.tar.bz2
 RUN cd php-7.0.18 && ./configure --enable-maintainer-zts --prefix=/usr/local/php-7.0-zts && \
     make && make install && cd ..
-RUN cd php-7.0.18 && make clean && ./configure --prefix=/usr/local/php-7.0 && \
+RUN cd php-7.0.18 && make clean && ./configure --enable-bcmath --prefix=/usr/local/php-7.0 && \
     make && make install && cd ..
 
 RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
@@ -174,7 +174,7 @@ RUN cd /tmp && \
   rm -rf protobuf && \
   git clone https://github.com/google/protobuf.git && \
   cd protobuf && \
-  git reset --hard 6b27c1f981a9a93918e4039f236ead27165a8e91 && \
+  git reset --hard 8d97b3d8b5a33650e822460b3b561802c969e86e && \
   cd php && \
   ln -sfn /usr/local/php-5.5/bin/php /usr/bin/php && \
   ln -sfn /usr/local/php-5.5/bin/php-config /usr/bin/php-config && \
diff --git a/jenkins/docker32/Dockerfile b/jenkins/docker32/Dockerfile
index ab3fd957..d9925d8d 100644
--- a/jenkins/docker32/Dockerfile
+++ b/jenkins/docker32/Dockerfile
@@ -64,7 +64,7 @@ RUN php -r "unlink('composer-setup.php');"
 RUN cd /tmp && \
   git clone https://github.com/google/protobuf.git && \
   cd protobuf/php && \
-  git reset --hard 6b27c1f981a9a93918e4039f236ead27165a8e91 && \
+  git reset --hard 8d97b3d8b5a33650e822460b3b561802c969e86e && \
   ln -sfn /usr/bin/php5.5 /usr/bin/php && \
   ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \
   ln -sfn /usr/bin/phpize5.5 /usr/bin/phpize && \
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 1b71f7b7..8c97e9fa 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -252,7 +252,7 @@ class GPBUtil
             return $prefix;
         }
 
-        $reserved_words = array("Empty");
+        $reserved_words = array("Empty", "ECHO", "ARRAY");
         foreach ($reserved_words as $reserved_word) {
             if ($classname === $reserved_word) {
                 if ($file_proto->getPackage() === "google.protobuf") {
-- 
cgit v1.2.3


From 703cd8e11c8d34283d4c8bf869c61866e8211c9d Mon Sep 17 00:00:00 2001
From: Ryan Gordon 
Date: Mon, 19 Jun 2017 18:15:49 -0700
Subject: Switch to addEnumType to fix fatal error (#3225)

* Switch to addEnumType to fix fatal error

* Fixing more cases of HHVM incompatibility

* Updating tests to be hhvm compatible

* Fixing tests

* Fixing merge

* Don't use call_user_func, should hopefully fix tests

* Fixing spelling

* Fixing another misspelling in a test

* Fixing placement of append and kvUpdate functions

* Actually fix function helpers

* Remove double addEnumType. How did this ever work?

* Fixing a couple more tests

* Only use the setter if the return value isn't an object
---
 .../Google/Protobuf/Internal/FileDescriptor.php    |  11 +-
 php/src/Google/Protobuf/Internal/Message.php       |  43 +++-
 php/tests/generated_class_test.php                 |  61 +++--
 php/tests/test_util.php                            | 280 +++++++++++----------
 4 files changed, 235 insertions(+), 160 deletions(-)

(limited to 'php/src/Google/Protobuf')

diff --git a/php/src/Google/Protobuf/Internal/FileDescriptor.php b/php/src/Google/Protobuf/Internal/FileDescriptor.php
index 14716390..038da38c 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptor.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptor.php
@@ -78,12 +78,11 @@ class FileDescriptor
                 $message_proto, $proto, ""));
         }
         foreach ($proto->getEnumType() as $enum_proto) {
-            $file->getEnumType()[] =
-                $file->addEnumType(
-                    EnumDescriptor::buildFromProto(
-                        $enum_proto,
-                        $proto,
-                        ""));
+            $file->addEnumType(
+                EnumDescriptor::buildFromProto(
+                    $enum_proto,
+                    $proto,
+                    ""));
         }
         return $file;
     }
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index 10c639ac..9ba249a0 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -373,7 +373,7 @@ class Message
             $getter = $field->getGetter();
             while ($input->bytesUntilLimit() > 0) {
                 self::parseFieldFromStreamNoTag($input, $field, $value);
-                $this->$getter()[] = $value;
+                $this->appendHelper($field, $value);
             }
             $input->popLimit($limit);
             return;
@@ -382,11 +382,9 @@ class Message
         }
 
         if ($field->isMap()) {
-            $getter = $field->getGetter();
-            $this->$getter()[$value->getKey()] = $value->getValue();
+            $this->kvUpdateHelper($field, $value->getKey(), $value->getValue());
         } else if ($field->isRepeated()) {
-            $getter = $field->getGetter();
-            $this->$getter()[] = $value;
+            $this->appendHelper($field, $value);
         } else {
             $setter = $field->getSetter();
             $this->$setter($value);
@@ -533,9 +531,10 @@ class Message
                           $klass = $value_field->getMessageType()->getClass();
                           $copy = new $klass;
                           $copy->mergeFrom($value);
-                          $this->$getter()[$key] = $copy;
+
+                          $this->kvUpdateHelper($field, $key, $copy);
                       } else {
-                          $this->$getter()[$key] = $value;
+                          $this->kvUpdateHelper($field, $key, $value);
                       }
                   }
               }
@@ -546,9 +545,9 @@ class Message
                           $klass = $field->getMessageType()->getClass();
                           $copy = new $klass;
                           $copy->mergeFrom($tmp);
-                          $this->$getter()[] = $copy;
+                          $this->appendHelper($field, $copy);
                       } else {
-                          $this->$getter()[] = $tmp;
+                          $this->appendHelper($field, $tmp);
                       }
                   }
               }
@@ -896,4 +895,30 @@ class Message
         }
         return $size;
     }
+
+    private function appendHelper($field, $append_value)
+    {
+        $getter = $field->getGetter();
+        $setter = $field->getSetter();
+
+        $field_arr_value = $this->$getter();
+        $field_arr_value[] = $append_value;
+
+        if (!is_object($field_arr_value)) {
+            $this->$setter($field_arr_value);
+        }
+    }
+
+    private function kvUpdateHelper($field, $update_key, $update_value)
+    {
+        $getter = $field->getGetter();
+        $setter = $field->getSetter();
+
+        $field_arr_value = $this->$getter();
+        $field_arr_value[$update_key] = $update_value;
+
+        if (!is_object($field_arr_value)) {
+            $this->$setter($field_arr_value);
+        }
+    }
 }
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index f7e645b3..33f38e1c 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -743,24 +743,44 @@ class GeneratedClassTest extends TestBase
         $n->setOptionalInt32(100);
         $sub1 = new TestMessage_Sub();
         $sub1->setA(101);
-        $sub1->getB()[] = 102;
+
+        $b = $sub1->getB();
+        $b[] = 102;
+        $sub1->setB($b);
+
         $n->setOptionalMessage($sub1);
 
         // Repeated
-        $n->getRepeatedInt32()[] = 200;
-        $n->getRepeatedString()[] = 'abc';
+        $repeatedInt32 = $n->getRepeatedInt32();
+        $repeatedInt32[] = 200;
+        $n->setRepeatedInt32($repeatedInt32);
+
+        $repeatedString = $n->getRepeatedString();
+        $repeatedString[] = 'abc';
+        $n->setRepeatedString($repeatedString);
+
         $sub2 = new TestMessage_Sub();
         $sub2->setA(201);
-        $n->getRepeatedMessage()[] = $sub2;
+        $repeatedMessage = $n->getRepeatedMessage();
+        $repeatedMessage[] = $sub2;
+        $n->setRepeatedMessage($repeatedMessage);
 
         // Map
-        $n->getMapInt32Int32()[1] = 300;
-        $n->getMapInt32Int32()[-62] = 301;
-        $n->getMapStringString()['def'] = 'def';
-        $n->getMapInt32Message()[1] = new TestMessage_Sub();
-        $n->getMapInt32Message()[1]->setA(302);
-        $n->getMapInt32Message()[2] = new TestMessage_Sub();
-        $n->getMapInt32Message()[2]->setA(303);
+        $mapInt32Int32 = $n->getMapInt32Int32();
+        $mapInt32Int32[1] = 300;
+        $mapInt32Int32[-62] = 301;
+        $n->setMapInt32Int32($mapInt32Int32);
+
+        $mapStringString = $n->getMapStringString();
+        $mapStringString['def'] = 'def';
+        $n->setMapStringString($mapStringString);
+
+        $mapInt32Message = $n->getMapInt32Message();
+        $mapInt32Message[1] = new TestMessage_Sub();
+        $mapInt32Message[1]->setA(302);
+        $mapInt32Message[2] = new TestMessage_Sub();
+        $mapInt32Message[2]->setA(303);
+        $n->setMapInt32Message($mapInt32Message);
 
         $m->mergeFrom($n);
 
@@ -795,9 +815,16 @@ class GeneratedClassTest extends TestBase
         // Check sub-messages are copied by value.
         $n->getOptionalMessage()->setA(-101);
         $this->assertSame(101, $m->getOptionalMessage()->getA());
-        $n->getRepeatedMessage()[0]->setA(-201);
+
+        $repeatedMessage = $n->getRepeatedMessage();
+        $repeatedMessage[0]->setA(-201);
+        $n->setRepeatedMessage($repeatedMessage);
         $this->assertSame(201, $m->getRepeatedMessage()[2]->getA());
-        $n->getMapInt32Message()[1]->setA(-302);
+
+        $mapInt32Message = $n->getMapInt32Message();
+        $mapInt32Message[1]->setA(-302);
+        $n->setMapInt32Message($mapInt32Message);
+
         $this->assertSame(302, $m->getMapInt32Message()[1]->getA());
 
         // Test merge oneof.
@@ -843,7 +870,9 @@ class GeneratedClassTest extends TestBase
         $m = new TestMessage();
         $sub = new NoNameSpaceMessage();
         $m->setOptionalNoNamespaceMessage($sub);
-        $m->getRepeatedNoNamespaceMessage()[] = new NoNameSpaceMessage();
+        $repeatedNoNamespaceMessage = $m->getRepeatedNoNamespaceMessage();
+        $repeatedNoNamespaceMessage[] = new NoNameSpaceMessage();
+        $m->setRepeatedNoNamespaceMessage($repeatedNoNamespaceMessage);
 
         $n = new NoNamespaceMessage();
         $n->setB(NoNamespaceMessage_NestedEnum::ZERO);
@@ -853,7 +882,9 @@ class GeneratedClassTest extends TestBase
     {
         $m = new TestMessage();
         $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A);
-        $m->getRepeatedNoNamespaceEnum()[] = NoNameSpaceEnum::VALUE_A;
+        $repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum();
+        $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A;
+        $m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum);
     }
 
     #########################################################
diff --git a/php/tests/test_util.php b/php/tests/test_util.php
index 9dbcbb62..c8afdd3e 100644
--- a/php/tests/test_util.php
+++ b/php/tests/test_util.php
@@ -71,61 +71,61 @@ class TestUtil
         $m->setOptionalMessage($sub);
         $m->getOptionalMessage()->SetA(33);
 
-        $m->getRepeatedInt32()    []= -42;
-        $m->getRepeatedInt64()    []= -43;
-        $m->getRepeatedUint32()   []=  42;
-        $m->getRepeatedUint64()   []=  43;
-        $m->getRepeatedSint32()   []= -44;
-        $m->getRepeatedSint64()   []= -45;
-        $m->getRepeatedFixed32()  []=  46;
-        $m->getRepeatedFixed64()  []=  47;
-        $m->getRepeatedSfixed32() []= -46;
-        $m->getRepeatedSfixed64() []= -47;
-        $m->getRepeatedFloat()    []= 1.5;
-        $m->getRepeatedDouble()   []= 1.6;
-        $m->getRepeatedBool()     []= true;
-        $m->getRepeatedString()   []= 'a';
-        $m->getRepeatedBytes()    []= 'b';
-        $m->getRepeatedEnum()     []= TestEnum::ZERO;
-        $m->getRepeatedMessage()  []= new TestMessage_Sub();
+        self::appendHelper($m, 'RepeatedInt32',    -42);
+        self::appendHelper($m, 'RepeatedInt64',    -43);
+        self::appendHelper($m, 'RepeatedUint32',    42);
+        self::appendHelper($m, 'RepeatedUint64',    43);
+        self::appendHelper($m, 'RepeatedSint32',   -44);
+        self::appendHelper($m, 'RepeatedSint64',   -45);
+        self::appendHelper($m, 'RepeatedFixed32',   46);
+        self::appendHelper($m, 'RepeatedFixed64',   47);
+        self::appendHelper($m, 'RepeatedSfixed32', -46);
+        self::appendHelper($m, 'RepeatedSfixed64', -47);
+        self::appendHelper($m, 'RepeatedFloat',    1.5);
+        self::appendHelper($m, 'RepeatedDouble',   1.6);
+        self::appendHelper($m, 'RepeatedBool',     true);
+        self::appendHelper($m, 'RepeatedString',   'a');
+        self::appendHelper($m, 'RepeatedBytes',    'b');
+        self::appendHelper($m, 'RepeatedEnum',     TestEnum::ZERO);
+        self::appendHelper($m, 'RepeatedMessage',  new TestMessage_Sub());
         $m->getRepeatedMessage()[0]->setA(34);
 
-        $m->getRepeatedInt32()    []= -52;
-        $m->getRepeatedInt64()    []= -53;
-        $m->getRepeatedUint32()   []=  52;
-        $m->getRepeatedUint64()   []=  53;
-        $m->getRepeatedSint32()   []= -54;
-        $m->getRepeatedSint64()   []= -55;
-        $m->getRepeatedFixed32()  []=  56;
-        $m->getRepeatedFixed64()  []=  57;
-        $m->getRepeatedSfixed32() []= -56;
-        $m->getRepeatedSfixed64() []= -57;
-        $m->getRepeatedFloat()    []= 2.5;
-        $m->getRepeatedDouble()   []= 2.6;
-        $m->getRepeatedBool()     []= false;
-        $m->getRepeatedString()   []= 'c';
-        $m->getRepeatedBytes()    []= 'd';
-        $m->getRepeatedEnum()     []= TestEnum::ONE;
-        $m->getRepeatedMessage()  []= new TestMessage_Sub();
+        self::appendHelper($m, 'RepeatedInt32',    -52);
+        self::appendHelper($m, 'RepeatedInt64',    -53);
+        self::appendHelper($m, 'RepeatedUint32',    52);
+        self::appendHelper($m, 'RepeatedUint64',    53);
+        self::appendHelper($m, 'RepeatedSint32',   -54);
+        self::appendHelper($m, 'RepeatedSint64',   -55);
+        self::appendHelper($m, 'RepeatedFixed32',   56);
+        self::appendHelper($m, 'RepeatedFixed64',   57);
+        self::appendHelper($m, 'RepeatedSfixed32', -56);
+        self::appendHelper($m, 'RepeatedSfixed64', -57);
+        self::appendHelper($m, 'RepeatedFloat',    2.5);
+        self::appendHelper($m, 'RepeatedDouble',   2.6);
+        self::appendHelper($m, 'RepeatedBool',     false);
+        self::appendHelper($m, 'RepeatedString',   'c');
+        self::appendHelper($m, 'RepeatedBytes',    'd');
+        self::appendHelper($m, 'RepeatedEnum',     TestEnum::ONE);
+        self::appendHelper($m, 'RepeatedMessage',  new TestMessage_Sub());
         $m->getRepeatedMessage()[1]->SetA(35);
 
-        $m->getMapInt32Int32()[-62] = -62;
-        $m->getMapInt64Int64()[-63] = -63;
-        $m->getMapUint32Uint32()[62] = 62;
-        $m->getMapUint64Uint64()[63] = 63;
-        $m->getMapSint32Sint32()[-64] = -64;
-        $m->getMapSint64Sint64()[-65] = -65;
-        $m->getMapFixed32Fixed32()[66] = 66;
-        $m->getMapFixed64Fixed64()[67] = 67;
-        $m->getMapSfixed32Sfixed32()[-68] = -68;
-        $m->getMapSfixed64Sfixed64()[-69] = -69;
-        $m->getMapInt32Float()[1] = 3.5;
-        $m->getMapInt32Double()[1] = 3.6;
-        $m->getMapBoolBool()[true] = true;
-        $m->getMapStringString()['e'] = 'e';
-        $m->getMapInt32Bytes()[1] = 'f';
-        $m->getMapInt32Enum()[1] = TestEnum::ONE;
-        $m->getMapInt32Message()[1] = new TestMessage_Sub();
+        self::kvUpdateHelper($m, 'MapInt32Int32', -62, -62);
+        self::kvUpdateHelper($m, 'MapInt64Int64', -63, -63);
+        self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 62);
+        self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 63);
+        self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -64);
+        self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -65);
+        self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 66);
+        self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 67);
+        self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -68);
+        self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -69);
+        self::kvUpdateHelper($m, 'MapInt32Float', 1, 3.5);
+        self::kvUpdateHelper($m, 'MapInt32Double', 1, 3.6);
+        self::kvUpdateHelper($m, 'MapBoolBool', true, true);
+        self::kvUpdateHelper($m, 'MapStringString', 'e', 'e');
+        self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'f');
+        self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::ONE);
+        self::kvUpdateHelper($m, 'MapInt32Message', 1, new TestMessage_Sub());
         $m->getMapInt32Message()[1]->SetA(36);
     }
 
@@ -152,61 +152,61 @@ class TestUtil
         $m->setOptionalMessage($sub);
         $m->getOptionalMessage()->SetA(133);
 
-        $m->getRepeatedInt32()    []= -142;
-        $m->getRepeatedInt64()    []= -143;
-        $m->getRepeatedUint32()   []=  142;
-        $m->getRepeatedUint64()   []=  143;
-        $m->getRepeatedSint32()   []= -144;
-        $m->getRepeatedSint64()   []= -145;
-        $m->getRepeatedFixed32()  []=  146;
-        $m->getRepeatedFixed64()  []=  147;
-        $m->getRepeatedSfixed32() []= -146;
-        $m->getRepeatedSfixed64() []= -147;
-        $m->getRepeatedFloat()    []= 11.5;
-        $m->getRepeatedDouble()   []= 11.6;
-        $m->getRepeatedBool()     []= false;
-        $m->getRepeatedString()   []= 'aa';
-        $m->getRepeatedBytes()    []= 'bb';
-        $m->getRepeatedEnum()     []= TestEnum::TWO;
-        $m->getRepeatedMessage()  []= new TestMessage_Sub();
+        self::appendHelper($m, 'RepeatedInt32',    -142);
+        self::appendHelper($m, 'RepeatedInt64',    -143);
+        self::appendHelper($m, 'RepeatedUint32',    142);
+        self::appendHelper($m, 'RepeatedUint64',    143);
+        self::appendHelper($m, 'RepeatedSint32',   -144);
+        self::appendHelper($m, 'RepeatedSint64',   -145);
+        self::appendHelper($m, 'RepeatedFixed32',   146);
+        self::appendHelper($m, 'RepeatedFixed64',   147);
+        self::appendHelper($m, 'RepeatedSfixed32', -146);
+        self::appendHelper($m, 'RepeatedSfixed64', -147);
+        self::appendHelper($m, 'RepeatedFloat',    11.5);
+        self::appendHelper($m, 'RepeatedDouble',   11.6);
+        self::appendHelper($m, 'RepeatedBool',     false);
+        self::appendHelper($m, 'RepeatedString',   'aa');
+        self::appendHelper($m, 'RepeatedBytes',    'bb');
+        self::appendHelper($m, 'RepeatedEnum',     TestEnum::TWO);
+        self::appendHelper($m, 'RepeatedMessage',  new TestMessage_Sub());
         $m->getRepeatedMessage()[0]->setA(134);
 
-        $m->getMapInt32Int32()[-62] = -162;
-        $m->getMapInt64Int64()[-63] = -163;
-        $m->getMapUint32Uint32()[62] = 162;
-        $m->getMapUint64Uint64()[63] = 163;
-        $m->getMapSint32Sint32()[-64] = -164;
-        $m->getMapSint64Sint64()[-65] = -165;
-        $m->getMapFixed32Fixed32()[66] = 166;
-        $m->getMapFixed64Fixed64()[67] = 167;
-        $m->getMapSfixed32Sfixed32()[-68] = -168;
-        $m->getMapSfixed64Sfixed64()[-69] = -169;
-        $m->getMapInt32Float()[1] = 13.5;
-        $m->getMapInt32Double()[1] = 13.6;
-        $m->getMapBoolBool()[true] = false;
-        $m->getMapStringString()['e'] = 'ee';
-        $m->getMapInt32Bytes()[1] = 'ff';
-        $m->getMapInt32Enum()[1] = TestEnum::TWO;
-        $m->getMapInt32Message()[1] = new TestMessage_Sub();
+        self::kvUpdateHelper($m, 'MapInt32Int32', -62, -162);
+        self::kvUpdateHelper($m, 'MapInt64Int64', -63, -163);
+        self::kvUpdateHelper($m, 'MapUint32Uint32', 62, 162);
+        self::kvUpdateHelper($m, 'MapUint64Uint64', 63, 163);
+        self::kvUpdateHelper($m, 'MapSint32Sint32', -64, -164);
+        self::kvUpdateHelper($m, 'MapSint64Sint64', -65, -165);
+        self::kvUpdateHelper($m, 'MapFixed32Fixed32', 66, 166);
+        self::kvUpdateHelper($m, 'MapFixed64Fixed64', 67, 167);
+        self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -68, -168);
+        self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -69, -169);
+        self::kvUpdateHelper($m, 'MapInt32Float', 1, 13.5);
+        self::kvUpdateHelper($m, 'MapInt32Double', 1, 13.6);
+        self::kvUpdateHelper($m, 'MapBoolBool', true, false);
+        self::kvUpdateHelper($m, 'MapStringString', 'e', 'ee');
+        self::kvUpdateHelper($m, 'MapInt32Bytes', 1, 'ff');
+        self::kvUpdateHelper($m, 'MapInt32Enum', 1, TestEnum::TWO);
+        self::kvUpdateHelper($m, 'MapInt32Message', 1, new TestMessage_Sub());
         $m->getMapInt32Message()[1]->SetA(136);
 
-        $m->getMapInt32Int32()[-162] = -162;
-        $m->getMapInt64Int64()[-163] = -163;
-        $m->getMapUint32Uint32()[162] = 162;
-        $m->getMapUint64Uint64()[163] = 163;
-        $m->getMapSint32Sint32()[-164] = -164;
-        $m->getMapSint64Sint64()[-165] = -165;
-        $m->getMapFixed32Fixed32()[166] = 166;
-        $m->getMapFixed64Fixed64()[167] = 167;
-        $m->getMapSfixed32Sfixed32()[-168] = -168;
-        $m->getMapSfixed64Sfixed64()[-169] = -169;
-        $m->getMapInt32Float()[2] = 13.5;
-        $m->getMapInt32Double()[2] = 13.6;
-        $m->getMapBoolBool()[false] = false;
-        $m->getMapStringString()['ee'] = 'ee';
-        $m->getMapInt32Bytes()[2] = 'ff';
-        $m->getMapInt32Enum()[2] = TestEnum::TWO;
-        $m->getMapInt32Message()[2] = new TestMessage_Sub();
+        self::kvUpdateHelper($m, 'MapInt32Int32', -162, -162);
+        self::kvUpdateHelper($m, 'MapInt64Int64', -163, -163);
+        self::kvUpdateHelper($m, 'MapUint32Uint32', 162, 162);
+        self::kvUpdateHelper($m, 'MapUint64Uint64', 163, 163);
+        self::kvUpdateHelper($m, 'MapSint32Sint32', -164, -164);
+        self::kvUpdateHelper($m, 'MapSint64Sint64', -165, -165);
+        self::kvUpdateHelper($m, 'MapFixed32Fixed32', 166, 166);
+        self::kvUpdateHelper($m, 'MapFixed64Fixed64', 167, 167);
+        self::kvUpdateHelper($m, 'MapSfixed32Sfixed32', -168, -168);
+        self::kvUpdateHelper($m, 'MapSfixed64Sfixed64', -169, -169);
+        self::kvUpdateHelper($m, 'MapInt32Float', 2, 13.5);
+        self::kvUpdateHelper($m, 'MapInt32Double', 2, 13.6);
+        self::kvUpdateHelper($m, 'MapBoolBool', false, false);
+        self::kvUpdateHelper($m, 'MapStringString', 'ee', 'ee');
+        self::kvUpdateHelper($m, 'MapInt32Bytes', 2, 'ff');
+        self::kvUpdateHelper($m, 'MapInt32Enum', 2, TestEnum::TWO);
+        self::kvUpdateHelper($m, 'MapInt32Message', 2, new TestMessage_Sub());
         $m->getMapInt32Message()[2]->SetA(136);
     }
 
@@ -395,34 +395,34 @@ class TestUtil
 
     public static function setTestPackedMessage($m)
     {
-        $m->getRepeatedInt32()[] = -42;
-        $m->getRepeatedInt32()[] = -52;
-        $m->getRepeatedInt64()[] = -43;
-        $m->getRepeatedInt64()[] = -53;
-        $m->getRepeatedUint32()[] = 42;
-        $m->getRepeatedUint32()[] = 52;
-        $m->getRepeatedUint64()[] = 43;
-        $m->getRepeatedUint64()[] = 53;
-        $m->getRepeatedSint32()[] = -44;
-        $m->getRepeatedSint32()[] = -54;
-        $m->getRepeatedSint64()[] = -45;
-        $m->getRepeatedSint64()[] = -55;
-        $m->getRepeatedFixed32()[] = 46;
-        $m->getRepeatedFixed32()[] = 56;
-        $m->getRepeatedFixed64()[] = 47;
-        $m->getRepeatedFixed64()[] = 57;
-        $m->getRepeatedSfixed32()[] = -46;
-        $m->getRepeatedSfixed32()[] = -56;
-        $m->getRepeatedSfixed64()[] = -47;
-        $m->getRepeatedSfixed64()[] = -57;
-        $m->getRepeatedFloat()[] = 1.5;
-        $m->getRepeatedFloat()[] = 2.5;
-        $m->getRepeatedDouble()[] = 1.6;
-        $m->getRepeatedDouble()[] = 2.6;
-        $m->getRepeatedBool()[] = true;
-        $m->getRepeatedBool()[] = false;
-        $m->getRepeatedEnum()[] = TestEnum::ONE;
-        $m->getRepeatedEnum()[] = TestEnum::ZERO;
+        self::appendHelper($m, 'RepeatedInt32', -42);
+        self::appendHelper($m, 'RepeatedInt32', -52);
+        self::appendHelper($m, 'RepeatedInt64', -43);
+        self::appendHelper($m, 'RepeatedInt64', -53);
+        self::appendHelper($m, 'RepeatedUint32', 42);
+        self::appendHelper($m, 'RepeatedUint32', 52);
+        self::appendHelper($m, 'RepeatedUint64', 43);
+        self::appendHelper($m, 'RepeatedUint64', 53);
+        self::appendHelper($m, 'RepeatedSint32', -44);
+        self::appendHelper($m, 'RepeatedSint32', -54);
+        self::appendHelper($m, 'RepeatedSint64', -45);
+        self::appendHelper($m, 'RepeatedSint64', -55);
+        self::appendHelper($m, 'RepeatedFixed32', 46);
+        self::appendHelper($m, 'RepeatedFixed32', 56);
+        self::appendHelper($m, 'RepeatedFixed64', 47);
+        self::appendHelper($m, 'RepeatedFixed64', 57);
+        self::appendHelper($m, 'RepeatedSfixed32', -46);
+        self::appendHelper($m, 'RepeatedSfixed32', -56);
+        self::appendHelper($m, 'RepeatedSfixed64', -47);
+        self::appendHelper($m, 'RepeatedSfixed64', -57);
+        self::appendHelper($m, 'RepeatedFloat', 1.5);
+        self::appendHelper($m, 'RepeatedFloat', 2.5);
+        self::appendHelper($m, 'RepeatedDouble', 1.6);
+        self::appendHelper($m, 'RepeatedDouble', 2.6);
+        self::appendHelper($m, 'RepeatedBool', true);
+        self::appendHelper($m, 'RepeatedBool', false);
+        self::appendHelper($m, 'RepeatedEnum', TestEnum::ONE);
+        self::appendHelper($m, 'RepeatedEnum', TestEnum::ZERO);
     }
 
     public static function assertTestPackedMessage($m)
@@ -524,4 +524,24 @@ class TestUtil
             "B80601B80600"
         );
     }
+
+    private static function appendHelper($obj, $func_suffix, $value)
+    {
+        $getter_function = 'get'.$func_suffix;
+        $setter_function = 'set'.$func_suffix;
+
+        $arr = $obj->$getter_function();
+        $arr[] = $value;
+        $obj->$setter_function($arr);
+    }
+
+    private static function kvUpdateHelper($obj, $func_suffix, $key, $value)
+    {
+        $getter_function = 'get'.$func_suffix;
+        $setter_function = 'set'.$func_suffix;
+
+        $arr = $obj->$getter_function();
+        $arr[$key] = $value;
+        $obj->$setter_function($arr);
+    }
 }
-- 
cgit v1.2.3


From 12acbc2678073c3439b427be0b713b97e2074bfb Mon Sep 17 00:00:00 2001
From: Brent Shaffer 
Date: Tue, 27 Jun 2017 16:28:28 -0700
Subject: adds PHPDoc @return and @param for getters and setters respectively
 (#3131)

* adds PHPDoc @return and @param for getters and setters respectively

* addresses changes in PR review

* adds documentation tests

* Update php_generator:

- Prepend \ to names where required
- Remove 
 tags
- Update protobuf field comments

* Updates class files with the protobuf changes

* Addresses review comments

* removes Protobuf Type line from PHP generated classes

* fixes phpdoc test

* adds array types to phpdoc
---
 Makefile.am                                        |   1 +
 php/phpunit.xml                                    |   1 +
 .../Google/Protobuf/Internal/DescriptorProto.php   | 100 +++---
 .../Internal/DescriptorProto_ExtensionRange.php    |  20 +-
 .../Internal/DescriptorProto_ReservedRange.php     |  34 +--
 .../Protobuf/Internal/EnumDescriptorProto.php      |  31 +-
 php/src/Google/Protobuf/Internal/EnumOptions.php   |  47 ++-
 .../Protobuf/Internal/EnumValueDescriptorProto.php |  31 +-
 .../Google/Protobuf/Internal/EnumValueOptions.php  |  32 +-
 .../Protobuf/Internal/FieldDescriptorProto.php     | 136 ++++-----
 .../Internal/FieldDescriptorProto_Label.php        |  10 +-
 .../Internal/FieldDescriptorProto_Type.php         |  54 ++--
 php/src/Google/Protobuf/Internal/FieldOptions.php  | 107 +++----
 .../Protobuf/Internal/FieldOptions_CType.php       |  10 +-
 .../Protobuf/Internal/FieldOptions_JSType.php      |  14 +-
 .../Protobuf/Internal/FileDescriptorProto.php      | 160 +++++-----
 .../Google/Protobuf/Internal/FileDescriptorSet.php |  13 +-
 php/src/Google/Protobuf/Internal/FileOptions.php   | 254 +++++++---------
 .../Protobuf/Internal/FileOptions_OptimizeMode.php |  16 +-
 .../Google/Protobuf/Internal/GeneratedCodeInfo.php |  19 +-
 .../Internal/GeneratedCodeInfo_Annotation.php      |  62 ++--
 .../Google/Protobuf/Internal/MessageOptions.php    |  83 +++--
 .../Protobuf/Internal/MethodDescriptorProto.php    |  76 +++--
 php/src/Google/Protobuf/Internal/MethodOptions.php |  41 ++-
 .../Internal/MethodOptions_IdempotencyLevel.php    |  14 +-
 .../Protobuf/Internal/OneofDescriptorProto.php     |  22 +-
 php/src/Google/Protobuf/Internal/OneofOptions.php  |  17 +-
 .../Protobuf/Internal/ServiceDescriptorProto.php   |  31 +-
 .../Google/Protobuf/Internal/ServiceOptions.php    |  32 +-
 .../Google/Protobuf/Internal/SourceCodeInfo.php    |  19 +-
 .../Protobuf/Internal/SourceCodeInfo_Location.php  |  65 ++--
 .../Protobuf/Internal/UninterpretedOption.php      |  73 +++--
 .../Internal/UninterpretedOption_NamePart.php      |  22 +-
 php/tests/generated_phpdoc_test.php                | 337 +++++++++++++++++++++
 php/tests/test.sh                                  |   2 +-
 src/google/protobuf/compiler/php/php_generator.cc  | 159 +++++++---
 36 files changed, 1220 insertions(+), 925 deletions(-)
 create mode 100644 php/tests/generated_phpdoc_test.php

(limited to 'php/src/Google/Protobuf')

diff --git a/Makefile.am b/Makefile.am
index 47fe4bb9..0142bed1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -658,6 +658,7 @@ php_EXTRA_DIST=                                                       \
   php/tests/encode_decode_test.php                                    \
   php/tests/gdb_test.sh                                               \
   php/tests/generated_class_test.php                                  \
+  php/tests/generated_phpdoc_test.php                                 \
   php/tests/map_field_test.php                                        \
   php/tests/memory_leak_test.php                                      \
   php/tests/php_implementation_test.php                               \
diff --git a/php/phpunit.xml b/php/phpunit.xml
index 0191a601..7cb1e2a3 100644
--- a/php/phpunit.xml
+++ b/php/phpunit.xml
@@ -7,6 +7,7 @@
       tests/array_test.php
       tests/encode_decode_test.php
       tests/generated_class_test.php
+      tests/generated_phpdoc_test.php
       tests/map_field_test.php
       tests/well_known_test.php
     
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index c72c0962..0fdaecfc 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -12,66 +12,62 @@ use Google\Protobuf\Internal\InputStream;
 use Google\Protobuf\Internal\GPBUtil;
 
 /**
- * 
  * Describes a message type.
- * 
* - * Protobuf type google.protobuf.DescriptorProto + * Generated from protobuf message google.protobuf.DescriptorProto */ class DescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * repeated .google.protobuf.FieldDescriptorProto field = 2; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; */ private $field; private $has_field = false; /** - * repeated .google.protobuf.FieldDescriptorProto extension = 6; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 6; */ private $extension; private $has_extension = false; /** - * repeated .google.protobuf.DescriptorProto nested_type = 3; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto nested_type = 3; */ private $nested_type; private $has_nested_type = false; /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 4; */ private $enum_type; private $has_enum_type = false; /** - * repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; */ private $extension_range; private $has_extension_range = false; /** - * repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + * Generated from protobuf field repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; */ private $oneof_decl; private $has_oneof_decl = false; /** - * optional .google.protobuf.MessageOptions options = 7; + * Generated from protobuf field optional .google.protobuf.MessageOptions options = 7; */ private $options = null; private $has_options = false; /** - * repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; */ private $reserved_range; private $has_reserved_range = false; /** - *
      * Reserved field names, which may not be used by fields in the same message.
      * A given name may only be reserved once.
-     * 
* - * repeated string reserved_name = 10; + * Generated from protobuf field repeated string reserved_name = 10; */ private $reserved_name; private $has_reserved_name = false; @@ -82,7 +78,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -90,7 +87,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -107,7 +106,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto field = 2; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getField() { @@ -115,7 +115,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto field = 2; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; + * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setField(&$var) { @@ -132,7 +134,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto extension = 6; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 6; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getExtension() { @@ -140,7 +143,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto extension = 6; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 6; + * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setExtension(&$var) { @@ -157,7 +162,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto nested_type = 3; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto nested_type = 3; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getNestedType() { @@ -165,7 +171,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto nested_type = 3; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto nested_type = 3; + * @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setNestedType(&$var) { @@ -182,7 +190,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getEnumType() { @@ -190,7 +199,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + * @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setEnumType(&$var) { @@ -207,7 +218,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getExtensionRange() { @@ -215,7 +227,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + * @param \Google\Protobuf\Internal\DescriptorProto_ExtensionRange[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setExtensionRange(&$var) { @@ -232,7 +246,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + * Generated from protobuf field repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getOneofDecl() { @@ -240,7 +255,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + * Generated from protobuf field repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + * @param \Google\Protobuf\Internal\OneofDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setOneofDecl(&$var) { @@ -257,7 +274,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MessageOptions options = 7; + * Generated from protobuf field optional .google.protobuf.MessageOptions options = 7; + * @return \Google\Protobuf\Internal\MessageOptions */ public function getOptions() { @@ -265,7 +283,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MessageOptions options = 7; + * Generated from protobuf field optional .google.protobuf.MessageOptions options = 7; + * @param \Google\Protobuf\Internal\MessageOptions $var + * @return $this */ public function setOptions(&$var) { @@ -282,7 +302,8 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getReservedRange() { @@ -290,7 +311,9 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + * @param \Google\Protobuf\Internal\DescriptorProto_ReservedRange[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setReservedRange(&$var) { @@ -307,12 +330,11 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Reserved field names, which may not be used by fields in the same message.
      * A given name may only be reserved once.
-     * 
* - * repeated string reserved_name = 10; + * Generated from protobuf field repeated string reserved_name = 10; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getReservedName() { @@ -320,12 +342,12 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Reserved field names, which may not be used by fields in the same message.
      * A given name may only be reserved once.
-     * 
* - * repeated string reserved_name = 10; + * Generated from protobuf field repeated string reserved_name = 10; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setReservedName(&$var) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php index b5e5453e..bbd34824 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php @@ -12,17 +12,17 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.DescriptorProto.ExtensionRange + * Generated from protobuf message google.protobuf.DescriptorProto.ExtensionRange */ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message { /** - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; */ private $start = 0; private $has_start = false; /** - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; */ private $end = 0; private $has_end = false; @@ -33,7 +33,8 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message } /** - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; + * @return int */ public function getStart() { @@ -41,7 +42,9 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message } /** - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; + * @param int $var + * @return $this */ public function setStart($var) { @@ -58,7 +61,8 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message } /** - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; + * @return int */ public function getEnd() { @@ -66,7 +70,9 @@ class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message } /** - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; + * @param int $var + * @return $this */ public function setEnd($var) { diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php index e5b7b05a..3d613133 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php @@ -12,31 +12,25 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Range of reserved tag numbers. Reserved tag numbers may not be used by
  * fields or extension ranges in the same message. Reserved ranges may
  * not overlap.
- * 
* - * Protobuf type google.protobuf.DescriptorProto.ReservedRange + * Generated from protobuf message google.protobuf.DescriptorProto.ReservedRange */ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message { /** - *
      * Inclusive.
-     * 
* - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; */ private $start = 0; private $has_start = false; /** - *
      * Exclusive.
-     * 
* - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; */ private $end = 0; private $has_end = false; @@ -47,11 +41,10 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message } /** - *
      * Inclusive.
-     * 
* - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; + * @return int */ public function getStart() { @@ -59,11 +52,11 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message } /** - *
      * Inclusive.
-     * 
* - * optional int32 start = 1; + * Generated from protobuf field optional int32 start = 1; + * @param int $var + * @return $this */ public function setStart($var) { @@ -80,11 +73,10 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message } /** - *
      * Exclusive.
-     * 
* - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; + * @return int */ public function getEnd() { @@ -92,11 +84,11 @@ class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message } /** - *
      * Exclusive.
-     * 
* - * optional int32 end = 2; + * Generated from protobuf field optional int32 end = 2; + * @param int $var + * @return $this */ public function setEnd($var) { diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index bf597436..6cdaf2df 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -12,26 +12,24 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes an enum type.
- * 
* - * Protobuf type google.protobuf.EnumDescriptorProto + * Generated from protobuf message google.protobuf.EnumDescriptorProto */ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * repeated .google.protobuf.EnumValueDescriptorProto value = 2; + * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; */ private $value; private $has_value = false; /** - * optional .google.protobuf.EnumOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumOptions options = 3; */ private $options = null; private $has_options = false; @@ -42,7 +40,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -50,7 +49,9 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -67,7 +68,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumValueDescriptorProto value = 2; + * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getValue() { @@ -75,7 +77,9 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumValueDescriptorProto value = 2; + * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; + * @param \Google\Protobuf\Internal\EnumValueDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setValue(&$var) { @@ -92,7 +96,8 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.EnumOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumOptions options = 3; + * @return \Google\Protobuf\Internal\EnumOptions */ public function getOptions() { @@ -100,7 +105,9 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.EnumOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumOptions options = 3; + * @param \Google\Protobuf\Internal\EnumOptions $var + * @return $this */ public function setOptions(&$var) { diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index cfa0cb3e..3c3a9e22 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -12,38 +12,32 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.EnumOptions + * Generated from protobuf message google.protobuf.EnumOptions */ class EnumOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Set this option to true to allow mapping different tag names to the same
      * value.
-     * 
* - * optional bool allow_alias = 2; + * Generated from protobuf field optional bool allow_alias = 2; */ private $allow_alias = false; private $has_allow_alias = false; /** - *
      * Is this enum deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating enums.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -54,12 +48,11 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Set this option to true to allow mapping different tag names to the same
      * value.
-     * 
* - * optional bool allow_alias = 2; + * Generated from protobuf field optional bool allow_alias = 2; + * @return bool */ public function getAllowAlias() { @@ -67,12 +60,12 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Set this option to true to allow mapping different tag names to the same
      * value.
-     * 
* - * optional bool allow_alias = 2; + * Generated from protobuf field optional bool allow_alias = 2; + * @param bool $var + * @return $this */ public function setAllowAlias($var) { @@ -89,14 +82,13 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this enum deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating enums.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @return bool */ public function getDeprecated() { @@ -104,14 +96,14 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this enum deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating enums.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -128,11 +120,10 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -140,11 +131,11 @@ class EnumOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 43eee73f..89d6707f 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -12,26 +12,24 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a value within an enum.
- * 
* - * Protobuf type google.protobuf.EnumValueDescriptorProto + * Generated from protobuf message google.protobuf.EnumValueDescriptorProto */ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * optional int32 number = 2; + * Generated from protobuf field optional int32 number = 2; */ private $number = 0; private $has_number = false; /** - * optional .google.protobuf.EnumValueOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumValueOptions options = 3; */ private $options = null; private $has_options = false; @@ -42,7 +40,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -50,7 +49,9 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -67,7 +68,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional int32 number = 2; + * Generated from protobuf field optional int32 number = 2; + * @return int */ public function getNumber() { @@ -75,7 +77,9 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional int32 number = 2; + * Generated from protobuf field optional int32 number = 2; + * @param int $var + * @return $this */ public function setNumber($var) { @@ -92,7 +96,8 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.EnumValueOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumValueOptions options = 3; + * @return \Google\Protobuf\Internal\EnumValueOptions */ public function getOptions() { @@ -100,7 +105,9 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.EnumValueOptions options = 3; + * Generated from protobuf field optional .google.protobuf.EnumValueOptions options = 3; + * @param \Google\Protobuf\Internal\EnumValueOptions $var + * @return $this */ public function setOptions(&$var) { diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index d66c7684..3b5c58e4 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -12,28 +12,24 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.EnumValueOptions + * Generated from protobuf message google.protobuf.EnumValueOptions */ class EnumValueOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Is this enum value deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum value, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating enum values.
-     * 
* - * optional bool deprecated = 1 [default = false]; + * Generated from protobuf field optional bool deprecated = 1 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -44,14 +40,13 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this enum value deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum value, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating enum values.
-     * 
* - * optional bool deprecated = 1 [default = false]; + * Generated from protobuf field optional bool deprecated = 1 [default = false]; + * @return bool */ public function getDeprecated() { @@ -59,14 +54,14 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this enum value deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the enum value, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating enum values.
-     * 
* - * optional bool deprecated = 1 [default = false]; + * Generated from protobuf field optional bool deprecated = 1 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -83,11 +78,10 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -95,11 +89,11 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index 2af9c0a0..ae61be47 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -12,99 +12,85 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a field within a message.
- * 
* - * Protobuf type google.protobuf.FieldDescriptorProto + * Generated from protobuf message google.protobuf.FieldDescriptorProto */ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * optional int32 number = 3; + * Generated from protobuf field optional int32 number = 3; */ private $number = 0; private $has_number = false; /** - * optional .google.protobuf.FieldDescriptorProto.Label label = 4; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Label label = 4; */ private $label = 0; private $has_label = false; /** - *
      * If type_name is set, this need not be set.  If both this and type_name
      * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
-     * 
* - * optional .google.protobuf.FieldDescriptorProto.Type type = 5; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Type type = 5; */ private $type = 0; private $has_type = false; /** - *
      * For message and enum types, this is the name of the type.  If the name
      * starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
      * rules are used to find the type (i.e. first the nested types within this
      * message are searched, then within the parent, on up to the root
      * namespace).
-     * 
* - * optional string type_name = 6; + * Generated from protobuf field optional string type_name = 6; */ private $type_name = ''; private $has_type_name = false; /** - *
      * For extensions, this is the name of the type being extended.  It is
      * resolved in the same manner as type_name.
-     * 
* - * optional string extendee = 2; + * Generated from protobuf field optional string extendee = 2; */ private $extendee = ''; private $has_extendee = false; /** - *
      * For numeric types, contains the original text representation of the value.
      * For booleans, "true" or "false".
      * For strings, contains the default text contents (not escaped in any way).
-     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
+     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
      * TODO(kenton):  Base-64 encode?
-     * 
* - * optional string default_value = 7; + * Generated from protobuf field optional string default_value = 7; */ private $default_value = ''; private $has_default_value = false; /** - *
      * If set, gives the index of a oneof in the containing type's oneof_decl
      * list.  This field is a member of that oneof.
-     * 
* - * optional int32 oneof_index = 9; + * Generated from protobuf field optional int32 oneof_index = 9; */ private $oneof_index = 0; private $has_oneof_index = false; /** - *
      * JSON name of this field. The value is set by protocol compiler. If the
      * user has set a "json_name" option on this field, that option's value
      * will be used. Otherwise, it's deduced from the field's name by converting
      * it to camelCase.
-     * 
* - * optional string json_name = 10; + * Generated from protobuf field optional string json_name = 10; */ private $json_name = ''; private $has_json_name = false; /** - * optional .google.protobuf.FieldOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FieldOptions options = 8; */ private $options = null; private $has_options = false; @@ -115,7 +101,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -123,7 +110,9 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -140,7 +129,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional int32 number = 3; + * Generated from protobuf field optional int32 number = 3; + * @return int */ public function getNumber() { @@ -148,7 +138,9 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional int32 number = 3; + * Generated from protobuf field optional int32 number = 3; + * @param int $var + * @return $this */ public function setNumber($var) { @@ -165,7 +157,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FieldDescriptorProto.Label label = 4; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Label label = 4; + * @return int */ public function getLabel() { @@ -173,7 +166,9 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FieldDescriptorProto.Label label = 4; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Label label = 4; + * @param int $var + * @return $this */ public function setLabel($var) { @@ -190,12 +185,11 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * If type_name is set, this need not be set.  If both this and type_name
      * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
-     * 
* - * optional .google.protobuf.FieldDescriptorProto.Type type = 5; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Type type = 5; + * @return int */ public function getType() { @@ -203,12 +197,12 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * If type_name is set, this need not be set.  If both this and type_name
      * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
-     * 
* - * optional .google.protobuf.FieldDescriptorProto.Type type = 5; + * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Type type = 5; + * @param int $var + * @return $this */ public function setType($var) { @@ -225,15 +219,14 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For message and enum types, this is the name of the type.  If the name
      * starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
      * rules are used to find the type (i.e. first the nested types within this
      * message are searched, then within the parent, on up to the root
      * namespace).
-     * 
* - * optional string type_name = 6; + * Generated from protobuf field optional string type_name = 6; + * @return string */ public function getTypeName() { @@ -241,15 +234,15 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For message and enum types, this is the name of the type.  If the name
      * starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping
      * rules are used to find the type (i.e. first the nested types within this
      * message are searched, then within the parent, on up to the root
      * namespace).
-     * 
* - * optional string type_name = 6; + * Generated from protobuf field optional string type_name = 6; + * @param string $var + * @return $this */ public function setTypeName($var) { @@ -266,12 +259,11 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For extensions, this is the name of the type being extended.  It is
      * resolved in the same manner as type_name.
-     * 
* - * optional string extendee = 2; + * Generated from protobuf field optional string extendee = 2; + * @return string */ public function getExtendee() { @@ -279,12 +271,12 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For extensions, this is the name of the type being extended.  It is
      * resolved in the same manner as type_name.
-     * 
* - * optional string extendee = 2; + * Generated from protobuf field optional string extendee = 2; + * @param string $var + * @return $this */ public function setExtendee($var) { @@ -301,15 +293,14 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For numeric types, contains the original text representation of the value.
      * For booleans, "true" or "false".
      * For strings, contains the default text contents (not escaped in any way).
-     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
+     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
      * TODO(kenton):  Base-64 encode?
-     * 
* - * optional string default_value = 7; + * Generated from protobuf field optional string default_value = 7; + * @return string */ public function getDefaultValue() { @@ -317,15 +308,15 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * For numeric types, contains the original text representation of the value.
      * For booleans, "true" or "false".
      * For strings, contains the default text contents (not escaped in any way).
-     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
+     * For bytes, contains the C escaped value.  All bytes >= 128 are escaped.
      * TODO(kenton):  Base-64 encode?
-     * 
* - * optional string default_value = 7; + * Generated from protobuf field optional string default_value = 7; + * @param string $var + * @return $this */ public function setDefaultValue($var) { @@ -342,12 +333,11 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * If set, gives the index of a oneof in the containing type's oneof_decl
      * list.  This field is a member of that oneof.
-     * 
* - * optional int32 oneof_index = 9; + * Generated from protobuf field optional int32 oneof_index = 9; + * @return int */ public function getOneofIndex() { @@ -355,12 +345,12 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * If set, gives the index of a oneof in the containing type's oneof_decl
      * list.  This field is a member of that oneof.
-     * 
* - * optional int32 oneof_index = 9; + * Generated from protobuf field optional int32 oneof_index = 9; + * @param int $var + * @return $this */ public function setOneofIndex($var) { @@ -377,14 +367,13 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * JSON name of this field. The value is set by protocol compiler. If the
      * user has set a "json_name" option on this field, that option's value
      * will be used. Otherwise, it's deduced from the field's name by converting
      * it to camelCase.
-     * 
* - * optional string json_name = 10; + * Generated from protobuf field optional string json_name = 10; + * @return string */ public function getJsonName() { @@ -392,14 +381,14 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * JSON name of this field. The value is set by protocol compiler. If the
      * user has set a "json_name" option on this field, that option's value
      * will be used. Otherwise, it's deduced from the field's name by converting
      * it to camelCase.
-     * 
* - * optional string json_name = 10; + * Generated from protobuf field optional string json_name = 10; + * @param string $var + * @return $this */ public function setJsonName($var) { @@ -416,7 +405,8 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FieldOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FieldOptions options = 8; + * @return \Google\Protobuf\Internal\FieldOptions */ public function getOptions() { @@ -424,7 +414,9 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FieldOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FieldOptions options = 8; + * @param \Google\Protobuf\Internal\FieldOptions $var + * @return $this */ public function setOptions(&$var) { diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php index a3cd8ef9..f2a32fdf 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php @@ -5,24 +5,22 @@ namespace Google\Protobuf\Internal; /** - * Protobuf enum google.protobuf.FieldDescriptorProto.Label + * Protobuf enum Google\Protobuf\Internal */ class FieldDescriptorProto_Label { /** - *
      * 0 is reserved for errors
-     * 
* - * LABEL_OPTIONAL = 1; + * Generated from protobuf enum LABEL_OPTIONAL = 1; */ const LABEL_OPTIONAL = 1; /** - * LABEL_REQUIRED = 2; + * Generated from protobuf enum LABEL_REQUIRED = 2; */ const LABEL_REQUIRED = 2; /** - * LABEL_REPEATED = 3; + * Generated from protobuf enum LABEL_REPEATED = 3; */ const LABEL_REPEATED = 3; } diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php index 8335f9b1..1b022deb 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php @@ -5,118 +5,102 @@ namespace Google\Protobuf\Internal; /** - * Protobuf enum google.protobuf.FieldDescriptorProto.Type + * Protobuf enum Google\Protobuf\Internal */ class FieldDescriptorProto_Type { /** - *
      * 0 is reserved for errors.
      * Order is weird for historical reasons.
-     * 
* - * TYPE_DOUBLE = 1; + * Generated from protobuf enum TYPE_DOUBLE = 1; */ const TYPE_DOUBLE = 1; /** - * TYPE_FLOAT = 2; + * Generated from protobuf enum TYPE_FLOAT = 2; */ const TYPE_FLOAT = 2; /** - *
      * Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT64 if
      * negative values are likely.
-     * 
* - * TYPE_INT64 = 3; + * Generated from protobuf enum TYPE_INT64 = 3; */ const TYPE_INT64 = 3; /** - * TYPE_UINT64 = 4; + * Generated from protobuf enum TYPE_UINT64 = 4; */ const TYPE_UINT64 = 4; /** - *
      * Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT32 if
      * negative values are likely.
-     * 
* - * TYPE_INT32 = 5; + * Generated from protobuf enum TYPE_INT32 = 5; */ const TYPE_INT32 = 5; /** - * TYPE_FIXED64 = 6; + * Generated from protobuf enum TYPE_FIXED64 = 6; */ const TYPE_FIXED64 = 6; /** - * TYPE_FIXED32 = 7; + * Generated from protobuf enum TYPE_FIXED32 = 7; */ const TYPE_FIXED32 = 7; /** - * TYPE_BOOL = 8; + * Generated from protobuf enum TYPE_BOOL = 8; */ const TYPE_BOOL = 8; /** - * TYPE_STRING = 9; + * Generated from protobuf enum TYPE_STRING = 9; */ const TYPE_STRING = 9; /** - *
      * Tag-delimited aggregate.
      * Group type is deprecated and not supported in proto3. However, Proto3
      * implementations should still be able to parse the group wire format and
      * treat group fields as unknown fields.
-     * 
* - * TYPE_GROUP = 10; + * Generated from protobuf enum TYPE_GROUP = 10; */ const TYPE_GROUP = 10; /** - *
      * Length-delimited aggregate.
-     * 
* - * TYPE_MESSAGE = 11; + * Generated from protobuf enum TYPE_MESSAGE = 11; */ const TYPE_MESSAGE = 11; /** - *
      * New in version 2.
-     * 
* - * TYPE_BYTES = 12; + * Generated from protobuf enum TYPE_BYTES = 12; */ const TYPE_BYTES = 12; /** - * TYPE_UINT32 = 13; + * Generated from protobuf enum TYPE_UINT32 = 13; */ const TYPE_UINT32 = 13; /** - * TYPE_ENUM = 14; + * Generated from protobuf enum TYPE_ENUM = 14; */ const TYPE_ENUM = 14; /** - * TYPE_SFIXED32 = 15; + * Generated from protobuf enum TYPE_SFIXED32 = 15; */ const TYPE_SFIXED32 = 15; /** - * TYPE_SFIXED64 = 16; + * Generated from protobuf enum TYPE_SFIXED64 = 16; */ const TYPE_SFIXED64 = 16; /** - *
      * Uses ZigZag encoding.
-     * 
* - * TYPE_SINT32 = 17; + * Generated from protobuf enum TYPE_SINT32 = 17; */ const TYPE_SINT32 = 17; /** - *
      * Uses ZigZag encoding.
-     * 
* - * TYPE_SINT64 = 18; + * Generated from protobuf enum TYPE_SINT64 = 18; */ const TYPE_SINT64 = 18; } diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index b30caa75..157c0f82 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -12,37 +12,32 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.FieldOptions + * Generated from protobuf message google.protobuf.FieldOptions */ class FieldOptions extends \Google\Protobuf\Internal\Message { /** - *
      * The ctype option instructs the C++ code generator to use a different
      * representation of the field than it normally would.  See the specific
      * options below.  This option is not yet implemented in the open source
      * release -- sorry, we'll try to include it in a future version!
-     * 
* - * optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; */ private $ctype = 0; private $has_ctype = false; /** - *
      * The packed option can be enabled for repeated primitive fields to enable
      * a more efficient representation on the wire. Rather than repeatedly
      * writing the tag and type for each element, the entire array is encoded as
      * a single length-delimited blob. In proto3, only explicit setting it to
      * false will avoid using packed encoding.
-     * 
* - * optional bool packed = 2; + * Generated from protobuf field optional bool packed = 2; */ private $packed = false; private $has_packed = false; /** - *
      * The jstype option determines the JavaScript type used for values of the
      * field.  The option is permitted only for 64 bit integral and fixed types
      * (int64, uint64, sint64, fixed64, sfixed64).  By default these types are
@@ -52,14 +47,12 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * JavaScript code to use the JavaScript "number" type instead of strings.
      * This option is an enum to permit additional types to be added,
      * e.g. goog.math.Integer.
-     * 
* - * optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; */ private $jstype = 0; private $has_jstype = false; /** - *
      * Should this field be parsed lazily?  Lazy applies only to message-type
      * fields.  It means that when the outer message is initially parsed, the
      * inner message's contents will not be parsed but instead stored in encoded
@@ -84,39 +77,32 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * implementation must either *always* check its required fields, or *never*
      * check its required fields, regardless of whether or not the message has
      * been parsed.
-     * 
* - * optional bool lazy = 5 [default = false]; + * Generated from protobuf field optional bool lazy = 5 [default = false]; */ private $lazy = false; private $has_lazy = false; /** - *
      * Is this field deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for accessors, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating fields.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * For Google-internal migration only. Do not use.
-     * 
* - * optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false]; */ private $weak = false; private $has_weak = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -127,14 +113,13 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The ctype option instructs the C++ code generator to use a different
      * representation of the field than it normally would.  See the specific
      * options below.  This option is not yet implemented in the open source
      * release -- sorry, we'll try to include it in a future version!
-     * 
* - * optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; + * @return int */ public function getCtype() { @@ -142,14 +127,14 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The ctype option instructs the C++ code generator to use a different
      * representation of the field than it normally would.  See the specific
      * options below.  This option is not yet implemented in the open source
      * release -- sorry, we'll try to include it in a future version!
-     * 
* - * optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; + * @param int $var + * @return $this */ public function setCtype($var) { @@ -166,15 +151,14 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The packed option can be enabled for repeated primitive fields to enable
      * a more efficient representation on the wire. Rather than repeatedly
      * writing the tag and type for each element, the entire array is encoded as
      * a single length-delimited blob. In proto3, only explicit setting it to
      * false will avoid using packed encoding.
-     * 
* - * optional bool packed = 2; + * Generated from protobuf field optional bool packed = 2; + * @return bool */ public function getPacked() { @@ -182,15 +166,15 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The packed option can be enabled for repeated primitive fields to enable
      * a more efficient representation on the wire. Rather than repeatedly
      * writing the tag and type for each element, the entire array is encoded as
      * a single length-delimited blob. In proto3, only explicit setting it to
      * false will avoid using packed encoding.
-     * 
* - * optional bool packed = 2; + * Generated from protobuf field optional bool packed = 2; + * @param bool $var + * @return $this */ public function setPacked($var) { @@ -207,7 +191,6 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The jstype option determines the JavaScript type used for values of the
      * field.  The option is permitted only for 64 bit integral and fixed types
      * (int64, uint64, sint64, fixed64, sfixed64).  By default these types are
@@ -217,9 +200,9 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * JavaScript code to use the JavaScript "number" type instead of strings.
      * This option is an enum to permit additional types to be added,
      * e.g. goog.math.Integer.
-     * 
* - * optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + * @return int */ public function getJstype() { @@ -227,7 +210,6 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The jstype option determines the JavaScript type used for values of the
      * field.  The option is permitted only for 64 bit integral and fixed types
      * (int64, uint64, sint64, fixed64, sfixed64).  By default these types are
@@ -237,9 +219,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * JavaScript code to use the JavaScript "number" type instead of strings.
      * This option is an enum to permit additional types to be added,
      * e.g. goog.math.Integer.
-     * 
* - * optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + * Generated from protobuf field optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; + * @param int $var + * @return $this */ public function setJstype($var) { @@ -256,7 +239,6 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Should this field be parsed lazily?  Lazy applies only to message-type
      * fields.  It means that when the outer message is initially parsed, the
      * inner message's contents will not be parsed but instead stored in encoded
@@ -281,9 +263,9 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * implementation must either *always* check its required fields, or *never*
      * check its required fields, regardless of whether or not the message has
      * been parsed.
-     * 
* - * optional bool lazy = 5 [default = false]; + * Generated from protobuf field optional bool lazy = 5 [default = false]; + * @return bool */ public function getLazy() { @@ -291,7 +273,6 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Should this field be parsed lazily?  Lazy applies only to message-type
      * fields.  It means that when the outer message is initially parsed, the
      * inner message's contents will not be parsed but instead stored in encoded
@@ -316,9 +297,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
      * implementation must either *always* check its required fields, or *never*
      * check its required fields, regardless of whether or not the message has
      * been parsed.
-     * 
* - * optional bool lazy = 5 [default = false]; + * Generated from protobuf field optional bool lazy = 5 [default = false]; + * @param bool $var + * @return $this */ public function setLazy($var) { @@ -335,14 +317,13 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this field deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for accessors, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating fields.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @return bool */ public function getDeprecated() { @@ -350,14 +331,14 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this field deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for accessors, or it will be completely ignored; in the very least, this
      * is a formalization for deprecating fields.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -374,11 +355,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * For Google-internal migration only. Do not use.
-     * 
* - * optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false]; + * @return bool */ public function getWeak() { @@ -386,11 +366,11 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * For Google-internal migration only. Do not use.
-     * 
* - * optional bool weak = 10 [default = false]; + * Generated from protobuf field optional bool weak = 10 [default = false]; + * @param bool $var + * @return $this */ public function setWeak($var) { @@ -407,11 +387,10 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -419,11 +398,11 @@ class FieldOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_CType.php b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php index f59f20be..0f33072d 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions_CType.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php @@ -5,24 +5,22 @@ namespace Google\Protobuf\Internal; /** - * Protobuf enum google.protobuf.FieldOptions.CType + * Protobuf enum Google\Protobuf\Internal */ class FieldOptions_CType { /** - *
      * Default mode.
-     * 
* - * STRING = 0; + * Generated from protobuf enum STRING = 0; */ const STRING = 0; /** - * CORD = 1; + * Generated from protobuf enum CORD = 1; */ const CORD = 1; /** - * STRING_PIECE = 2; + * Generated from protobuf enum STRING_PIECE = 2; */ const STRING_PIECE = 2; } diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php index 0c6995b7..73bdf3f2 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php @@ -5,32 +5,26 @@ namespace Google\Protobuf\Internal; /** - * Protobuf enum google.protobuf.FieldOptions.JSType + * Protobuf enum Google\Protobuf\Internal */ class FieldOptions_JSType { /** - *
      * Use the default type.
-     * 
* - * JS_NORMAL = 0; + * Generated from protobuf enum JS_NORMAL = 0; */ const JS_NORMAL = 0; /** - *
      * Use JavaScript strings.
-     * 
* - * JS_STRING = 1; + * Generated from protobuf enum JS_STRING = 1; */ const JS_STRING = 1; /** - *
      * Use JavaScript numbers.
-     * 
* - * JS_NUMBER = 2; + * Generated from protobuf enum JS_NUMBER = 2; */ const JS_NUMBER = 2; } diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index b229522a..3b1567d1 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -12,108 +12,90 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a complete .proto file.
- * 
* - * Protobuf type google.protobuf.FileDescriptorProto + * Generated from protobuf message google.protobuf.FileDescriptorProto */ class FileDescriptorProto extends \Google\Protobuf\Internal\Message { /** - *
      * file name, relative to root of source tree
-     * 
* - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - *
      * e.g. "foo", "foo.bar", etc.
-     * 
* - * optional string package = 2; + * Generated from protobuf field optional string package = 2; */ private $package = ''; private $has_package = false; /** - *
      * Names of files imported by this file.
-     * 
* - * repeated string dependency = 3; + * Generated from protobuf field repeated string dependency = 3; */ private $dependency; private $has_dependency = false; /** - *
      * Indexes of the public imported files in the dependency list above.
-     * 
* - * repeated int32 public_dependency = 10; + * Generated from protobuf field repeated int32 public_dependency = 10; */ private $public_dependency; private $has_public_dependency = false; /** - *
      * Indexes of the weak imported files in the dependency list.
      * For Google-internal migration only. Do not use.
-     * 
* - * repeated int32 weak_dependency = 11; + * Generated from protobuf field repeated int32 weak_dependency = 11; */ private $weak_dependency; private $has_weak_dependency = false; /** - *
      * All top-level definitions in this file.
-     * 
* - * repeated .google.protobuf.DescriptorProto message_type = 4; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto message_type = 4; */ private $message_type; private $has_message_type = false; /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 5; */ private $enum_type; private $has_enum_type = false; /** - * repeated .google.protobuf.ServiceDescriptorProto service = 6; + * Generated from protobuf field repeated .google.protobuf.ServiceDescriptorProto service = 6; */ private $service; private $has_service = false; /** - * repeated .google.protobuf.FieldDescriptorProto extension = 7; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 7; */ private $extension; private $has_extension = false; /** - * optional .google.protobuf.FileOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FileOptions options = 8; */ private $options = null; private $has_options = false; /** - *
      * This field contains optional information about the original source code.
      * You may safely remove this entire field without harming runtime
      * functionality of the descriptors -- the information is needed only by
      * development tools.
-     * 
* - * optional .google.protobuf.SourceCodeInfo source_code_info = 9; + * Generated from protobuf field optional .google.protobuf.SourceCodeInfo source_code_info = 9; */ private $source_code_info = null; private $has_source_code_info = false; /** - *
      * The syntax of the proto file.
      * The supported values are "proto2" and "proto3".
-     * 
* - * optional string syntax = 12; + * Generated from protobuf field optional string syntax = 12; */ private $syntax = ''; private $has_syntax = false; @@ -124,11 +106,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * file name, relative to root of source tree
-     * 
* - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -136,11 +117,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * file name, relative to root of source tree
-     * 
* - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -157,11 +138,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * e.g. "foo", "foo.bar", etc.
-     * 
* - * optional string package = 2; + * Generated from protobuf field optional string package = 2; + * @return string */ public function getPackage() { @@ -169,11 +149,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * e.g. "foo", "foo.bar", etc.
-     * 
* - * optional string package = 2; + * Generated from protobuf field optional string package = 2; + * @param string $var + * @return $this */ public function setPackage($var) { @@ -190,11 +170,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Names of files imported by this file.
-     * 
* - * repeated string dependency = 3; + * Generated from protobuf field repeated string dependency = 3; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getDependency() { @@ -202,11 +181,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Names of files imported by this file.
-     * 
* - * repeated string dependency = 3; + * Generated from protobuf field repeated string dependency = 3; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setDependency(&$var) { @@ -223,11 +202,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Indexes of the public imported files in the dependency list above.
-     * 
* - * repeated int32 public_dependency = 10; + * Generated from protobuf field repeated int32 public_dependency = 10; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getPublicDependency() { @@ -235,11 +213,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Indexes of the public imported files in the dependency list above.
-     * 
* - * repeated int32 public_dependency = 10; + * Generated from protobuf field repeated int32 public_dependency = 10; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setPublicDependency(&$var) { @@ -256,12 +234,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Indexes of the weak imported files in the dependency list.
      * For Google-internal migration only. Do not use.
-     * 
* - * repeated int32 weak_dependency = 11; + * Generated from protobuf field repeated int32 weak_dependency = 11; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getWeakDependency() { @@ -269,12 +246,12 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Indexes of the weak imported files in the dependency list.
      * For Google-internal migration only. Do not use.
-     * 
* - * repeated int32 weak_dependency = 11; + * Generated from protobuf field repeated int32 weak_dependency = 11; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setWeakDependency(&$var) { @@ -291,11 +268,10 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * All top-level definitions in this file.
-     * 
* - * repeated .google.protobuf.DescriptorProto message_type = 4; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto message_type = 4; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getMessageType() { @@ -303,11 +279,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * All top-level definitions in this file.
-     * 
* - * repeated .google.protobuf.DescriptorProto message_type = 4; + * Generated from protobuf field repeated .google.protobuf.DescriptorProto message_type = 4; + * @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setMessageType(&$var) { @@ -324,7 +300,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getEnumType() { @@ -332,7 +309,9 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + * Generated from protobuf field repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + * @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setEnumType(&$var) { @@ -349,7 +328,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.ServiceDescriptorProto service = 6; + * Generated from protobuf field repeated .google.protobuf.ServiceDescriptorProto service = 6; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getService() { @@ -357,7 +337,9 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.ServiceDescriptorProto service = 6; + * Generated from protobuf field repeated .google.protobuf.ServiceDescriptorProto service = 6; + * @param \Google\Protobuf\Internal\ServiceDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setService(&$var) { @@ -374,7 +356,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto extension = 7; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 7; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getExtension() { @@ -382,7 +365,9 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FieldDescriptorProto extension = 7; + * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto extension = 7; + * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setExtension(&$var) { @@ -399,7 +384,8 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FileOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FileOptions options = 8; + * @return \Google\Protobuf\Internal\FileOptions */ public function getOptions() { @@ -407,7 +393,9 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FileOptions options = 8; + * Generated from protobuf field optional .google.protobuf.FileOptions options = 8; + * @param \Google\Protobuf\Internal\FileOptions $var + * @return $this */ public function setOptions(&$var) { @@ -424,14 +412,13 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * This field contains optional information about the original source code.
      * You may safely remove this entire field without harming runtime
      * functionality of the descriptors -- the information is needed only by
      * development tools.
-     * 
* - * optional .google.protobuf.SourceCodeInfo source_code_info = 9; + * Generated from protobuf field optional .google.protobuf.SourceCodeInfo source_code_info = 9; + * @return \Google\Protobuf\Internal\SourceCodeInfo */ public function getSourceCodeInfo() { @@ -439,14 +426,14 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * This field contains optional information about the original source code.
      * You may safely remove this entire field without harming runtime
      * functionality of the descriptors -- the information is needed only by
      * development tools.
-     * 
* - * optional .google.protobuf.SourceCodeInfo source_code_info = 9; + * Generated from protobuf field optional .google.protobuf.SourceCodeInfo source_code_info = 9; + * @param \Google\Protobuf\Internal\SourceCodeInfo $var + * @return $this */ public function setSourceCodeInfo(&$var) { @@ -463,12 +450,11 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * The syntax of the proto file.
      * The supported values are "proto2" and "proto3".
-     * 
* - * optional string syntax = 12; + * Generated from protobuf field optional string syntax = 12; + * @return string */ public function getSyntax() { @@ -476,12 +462,12 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * The syntax of the proto file.
      * The supported values are "proto2" and "proto3".
-     * 
* - * optional string syntax = 12; + * Generated from protobuf field optional string syntax = 12; + * @param string $var + * @return $this */ public function setSyntax($var) { diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php index 8271ee66..591e2a81 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -12,17 +12,15 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * The protocol compiler can output a FileDescriptorSet containing the .proto
  * files it parses.
- * 
* - * Protobuf type google.protobuf.FileDescriptorSet + * Generated from protobuf message google.protobuf.FileDescriptorSet */ class FileDescriptorSet extends \Google\Protobuf\Internal\Message { /** - * repeated .google.protobuf.FileDescriptorProto file = 1; + * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; */ private $file; private $has_file = false; @@ -33,7 +31,8 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FileDescriptorProto file = 1; + * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getFile() { @@ -41,7 +40,9 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.FileDescriptorProto file = 1; + * Generated from protobuf field repeated .google.protobuf.FileDescriptorProto file = 1; + * @param \Google\Protobuf\Internal\FileDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setFile(&$var) { diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 332da3dc..2202102b 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -12,92 +12,79 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.FileOptions + * Generated from protobuf message google.protobuf.FileOptions */ class FileOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Sets the Java package where classes generated from this .proto will be
      * placed.  By default, the proto package is used, but this is often
      * inappropriate because proto packages do not normally start with backwards
      * domain names.
-     * 
* - * optional string java_package = 1; + * Generated from protobuf field optional string java_package = 1; */ private $java_package = ''; private $has_java_package = false; /** - *
      * If set, all the classes from the .proto file are wrapped in a single
      * outer class with the given name.  This applies to both Proto1
      * (equivalent to the old "--one_java_file" option) and Proto2 (where
      * a .proto always translates to a single class, but you may want to
      * explicitly choose the class name).
-     * 
* - * optional string java_outer_classname = 8; + * Generated from protobuf field optional string java_outer_classname = 8; */ private $java_outer_classname = ''; private $has_java_outer_classname = false; /** - *
      * If set true, then the Java code generator will generate a separate .java
      * file for each top-level message, enum, and service defined in the .proto
      * file.  Thus, these types will *not* be nested inside the outer class
      * named by java_outer_classname.  However, the outer class will still be
      * generated to contain the file's getDescriptor() method as well as any
      * top-level extensions defined in the file.
-     * 
* - * optional bool java_multiple_files = 10 [default = false]; + * Generated from protobuf field optional bool java_multiple_files = 10 [default = false]; */ private $java_multiple_files = false; private $has_java_multiple_files = false; /** - *
      * This option does nothing.
-     * 
* - * optional bool java_generate_equals_and_hash = 20 [deprecated = true]; + * Generated from protobuf field optional bool java_generate_equals_and_hash = 20 [deprecated = true]; */ private $java_generate_equals_and_hash = false; private $has_java_generate_equals_and_hash = false; /** - *
      * If set true, then the Java2 code generator will generate code that
      * throws an exception whenever an attempt is made to assign a non-UTF-8
      * byte sequence to a string field.
      * Message reflection will do the same.
      * However, an extension field still accepts non-UTF-8 byte sequences.
      * This option has no effect on when used with the lite runtime.
-     * 
* - * optional bool java_string_check_utf8 = 27 [default = false]; + * Generated from protobuf field optional bool java_string_check_utf8 = 27 [default = false]; */ private $java_string_check_utf8 = false; private $has_java_string_check_utf8 = false; /** - * optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + * Generated from protobuf field optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; */ private $optimize_for = 0; private $has_optimize_for = false; /** - *
      * Sets the Go package where structs generated from this .proto will be
      * placed. If omitted, the Go package will be derived from the following:
      *   - The basename of the package import path, if provided.
      *   - Otherwise, the package statement in the .proto file, if present.
      *   - Otherwise, the basename of the .proto file, without extension.
-     * 
* - * optional string go_package = 11; + * Generated from protobuf field optional string go_package = 11; */ private $go_package = ''; private $has_go_package = false; /** - *
      * Should generic services be generated in each language?  "Generic" services
      * are not specific to any particular RPC system.  They are generated by the
      * main code generators in each language (without additional plugins).
@@ -107,102 +94,85 @@ class FileOptions extends \Google\Protobuf\Internal\Message
      * that generate code specific to your particular RPC system.  Therefore,
      * these default to false.  Old code which depends on generic services should
      * explicitly set them to true.
-     * 
* - * optional bool cc_generic_services = 16 [default = false]; + * Generated from protobuf field optional bool cc_generic_services = 16 [default = false]; */ private $cc_generic_services = false; private $has_cc_generic_services = false; /** - * optional bool java_generic_services = 17 [default = false]; + * Generated from protobuf field optional bool java_generic_services = 17 [default = false]; */ private $java_generic_services = false; private $has_java_generic_services = false; /** - * optional bool py_generic_services = 18 [default = false]; + * Generated from protobuf field optional bool py_generic_services = 18 [default = false]; */ private $py_generic_services = false; private $has_py_generic_services = false; /** - *
      * Is this file deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for everything in the file, or it will be completely ignored; in the very
      * least, this is a formalization for deprecating files.
-     * 
* - * optional bool deprecated = 23 [default = false]; + * Generated from protobuf field optional bool deprecated = 23 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * Enables the use of arenas for the proto messages in this file. This applies
      * only to generated classes for C++.
-     * 
* - * optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; */ private $cc_enable_arenas = false; private $has_cc_enable_arenas = false; /** - *
      * Sets the objective c class prefix which is prepended to all objective c
      * generated classes from this .proto. There is no default.
-     * 
* - * optional string objc_class_prefix = 36; + * Generated from protobuf field optional string objc_class_prefix = 36; */ private $objc_class_prefix = ''; private $has_objc_class_prefix = false; /** - *
      * Namespace for generated classes; defaults to the package.
-     * 
* - * optional string csharp_namespace = 37; + * Generated from protobuf field optional string csharp_namespace = 37; */ private $csharp_namespace = ''; private $has_csharp_namespace = false; /** - *
      * By default Swift generators will take the proto package and CamelCase it
      * replacing '.' with underscore and use that to prefix the types/symbols
      * defined. When this options is provided, they will use this value instead
      * to prefix the types/symbols defined.
-     * 
* - * optional string swift_prefix = 39; + * Generated from protobuf field optional string swift_prefix = 39; */ private $swift_prefix = ''; private $has_swift_prefix = false; /** - *
      * Sets the php class prefix which is prepended to all php generated classes
      * from this .proto. Default is empty.
-     * 
* - * optional string php_class_prefix = 40; + * Generated from protobuf field optional string php_class_prefix = 40; */ private $php_class_prefix = ''; private $has_php_class_prefix = false; /** - *
      * Use this option to change the namespace of php generated classes. Default
      * is empty. When this option is empty, the package name will be used for
      * determining the namespace.
-     * 
* - * optional string php_namespace = 41; + * Generated from protobuf field optional string php_namespace = 41; */ private $php_namespace = ''; private $has_php_namespace = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -213,14 +183,13 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the Java package where classes generated from this .proto will be
      * placed.  By default, the proto package is used, but this is often
      * inappropriate because proto packages do not normally start with backwards
      * domain names.
-     * 
* - * optional string java_package = 1; + * Generated from protobuf field optional string java_package = 1; + * @return string */ public function getJavaPackage() { @@ -228,14 +197,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the Java package where classes generated from this .proto will be
      * placed.  By default, the proto package is used, but this is often
      * inappropriate because proto packages do not normally start with backwards
      * domain names.
-     * 
* - * optional string java_package = 1; + * Generated from protobuf field optional string java_package = 1; + * @param string $var + * @return $this */ public function setJavaPackage($var) { @@ -252,15 +221,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set, all the classes from the .proto file are wrapped in a single
      * outer class with the given name.  This applies to both Proto1
      * (equivalent to the old "--one_java_file" option) and Proto2 (where
      * a .proto always translates to a single class, but you may want to
      * explicitly choose the class name).
-     * 
* - * optional string java_outer_classname = 8; + * Generated from protobuf field optional string java_outer_classname = 8; + * @return string */ public function getJavaOuterClassname() { @@ -268,15 +236,15 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set, all the classes from the .proto file are wrapped in a single
      * outer class with the given name.  This applies to both Proto1
      * (equivalent to the old "--one_java_file" option) and Proto2 (where
      * a .proto always translates to a single class, but you may want to
      * explicitly choose the class name).
-     * 
* - * optional string java_outer_classname = 8; + * Generated from protobuf field optional string java_outer_classname = 8; + * @param string $var + * @return $this */ public function setJavaOuterClassname($var) { @@ -293,16 +261,15 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set true, then the Java code generator will generate a separate .java
      * file for each top-level message, enum, and service defined in the .proto
      * file.  Thus, these types will *not* be nested inside the outer class
      * named by java_outer_classname.  However, the outer class will still be
      * generated to contain the file's getDescriptor() method as well as any
      * top-level extensions defined in the file.
-     * 
* - * optional bool java_multiple_files = 10 [default = false]; + * Generated from protobuf field optional bool java_multiple_files = 10 [default = false]; + * @return bool */ public function getJavaMultipleFiles() { @@ -310,16 +277,16 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set true, then the Java code generator will generate a separate .java
      * file for each top-level message, enum, and service defined in the .proto
      * file.  Thus, these types will *not* be nested inside the outer class
      * named by java_outer_classname.  However, the outer class will still be
      * generated to contain the file's getDescriptor() method as well as any
      * top-level extensions defined in the file.
-     * 
* - * optional bool java_multiple_files = 10 [default = false]; + * Generated from protobuf field optional bool java_multiple_files = 10 [default = false]; + * @param bool $var + * @return $this */ public function setJavaMultipleFiles($var) { @@ -336,11 +303,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * This option does nothing.
-     * 
* - * optional bool java_generate_equals_and_hash = 20 [deprecated = true]; + * Generated from protobuf field optional bool java_generate_equals_and_hash = 20 [deprecated = true]; + * @return bool */ public function getJavaGenerateEqualsAndHash() { @@ -348,11 +314,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * This option does nothing.
-     * 
* - * optional bool java_generate_equals_and_hash = 20 [deprecated = true]; + * Generated from protobuf field optional bool java_generate_equals_and_hash = 20 [deprecated = true]; + * @param bool $var + * @return $this */ public function setJavaGenerateEqualsAndHash($var) { @@ -369,16 +335,15 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set true, then the Java2 code generator will generate code that
      * throws an exception whenever an attempt is made to assign a non-UTF-8
      * byte sequence to a string field.
      * Message reflection will do the same.
      * However, an extension field still accepts non-UTF-8 byte sequences.
      * This option has no effect on when used with the lite runtime.
-     * 
* - * optional bool java_string_check_utf8 = 27 [default = false]; + * Generated from protobuf field optional bool java_string_check_utf8 = 27 [default = false]; + * @return bool */ public function getJavaStringCheckUtf8() { @@ -386,16 +351,16 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * If set true, then the Java2 code generator will generate code that
      * throws an exception whenever an attempt is made to assign a non-UTF-8
      * byte sequence to a string field.
      * Message reflection will do the same.
      * However, an extension field still accepts non-UTF-8 byte sequences.
      * This option has no effect on when used with the lite runtime.
-     * 
* - * optional bool java_string_check_utf8 = 27 [default = false]; + * Generated from protobuf field optional bool java_string_check_utf8 = 27 [default = false]; + * @param bool $var + * @return $this */ public function setJavaStringCheckUtf8($var) { @@ -412,7 +377,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + * Generated from protobuf field optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + * @return int */ public function getOptimizeFor() { @@ -420,7 +386,9 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + * Generated from protobuf field optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + * @param int $var + * @return $this */ public function setOptimizeFor($var) { @@ -437,15 +405,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the Go package where structs generated from this .proto will be
      * placed. If omitted, the Go package will be derived from the following:
      *   - The basename of the package import path, if provided.
      *   - Otherwise, the package statement in the .proto file, if present.
      *   - Otherwise, the basename of the .proto file, without extension.
-     * 
* - * optional string go_package = 11; + * Generated from protobuf field optional string go_package = 11; + * @return string */ public function getGoPackage() { @@ -453,15 +420,15 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the Go package where structs generated from this .proto will be
      * placed. If omitted, the Go package will be derived from the following:
      *   - The basename of the package import path, if provided.
      *   - Otherwise, the package statement in the .proto file, if present.
      *   - Otherwise, the basename of the .proto file, without extension.
-     * 
* - * optional string go_package = 11; + * Generated from protobuf field optional string go_package = 11; + * @param string $var + * @return $this */ public function setGoPackage($var) { @@ -478,7 +445,6 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Should generic services be generated in each language?  "Generic" services
      * are not specific to any particular RPC system.  They are generated by the
      * main code generators in each language (without additional plugins).
@@ -488,9 +454,9 @@ class FileOptions extends \Google\Protobuf\Internal\Message
      * that generate code specific to your particular RPC system.  Therefore,
      * these default to false.  Old code which depends on generic services should
      * explicitly set them to true.
-     * 
* - * optional bool cc_generic_services = 16 [default = false]; + * Generated from protobuf field optional bool cc_generic_services = 16 [default = false]; + * @return bool */ public function getCcGenericServices() { @@ -498,7 +464,6 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Should generic services be generated in each language?  "Generic" services
      * are not specific to any particular RPC system.  They are generated by the
      * main code generators in each language (without additional plugins).
@@ -508,9 +473,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message
      * that generate code specific to your particular RPC system.  Therefore,
      * these default to false.  Old code which depends on generic services should
      * explicitly set them to true.
-     * 
* - * optional bool cc_generic_services = 16 [default = false]; + * Generated from protobuf field optional bool cc_generic_services = 16 [default = false]; + * @param bool $var + * @return $this */ public function setCcGenericServices($var) { @@ -527,7 +493,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional bool java_generic_services = 17 [default = false]; + * Generated from protobuf field optional bool java_generic_services = 17 [default = false]; + * @return bool */ public function getJavaGenericServices() { @@ -535,7 +502,9 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional bool java_generic_services = 17 [default = false]; + * Generated from protobuf field optional bool java_generic_services = 17 [default = false]; + * @param bool $var + * @return $this */ public function setJavaGenericServices($var) { @@ -552,7 +521,8 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional bool py_generic_services = 18 [default = false]; + * Generated from protobuf field optional bool py_generic_services = 18 [default = false]; + * @return bool */ public function getPyGenericServices() { @@ -560,7 +530,9 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - * optional bool py_generic_services = 18 [default = false]; + * Generated from protobuf field optional bool py_generic_services = 18 [default = false]; + * @param bool $var + * @return $this */ public function setPyGenericServices($var) { @@ -577,14 +549,13 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this file deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for everything in the file, or it will be completely ignored; in the very
      * least, this is a formalization for deprecating files.
-     * 
* - * optional bool deprecated = 23 [default = false]; + * Generated from protobuf field optional bool deprecated = 23 [default = false]; + * @return bool */ public function getDeprecated() { @@ -592,14 +563,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this file deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for everything in the file, or it will be completely ignored; in the very
      * least, this is a formalization for deprecating files.
-     * 
* - * optional bool deprecated = 23 [default = false]; + * Generated from protobuf field optional bool deprecated = 23 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -616,12 +587,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Enables the use of arenas for the proto messages in this file. This applies
      * only to generated classes for C++.
-     * 
* - * optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; + * @return bool */ public function getCcEnableArenas() { @@ -629,12 +599,12 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Enables the use of arenas for the proto messages in this file. This applies
      * only to generated classes for C++.
-     * 
* - * optional bool cc_enable_arenas = 31 [default = false]; + * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; + * @param bool $var + * @return $this */ public function setCcEnableArenas($var) { @@ -651,12 +621,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the objective c class prefix which is prepended to all objective c
      * generated classes from this .proto. There is no default.
-     * 
* - * optional string objc_class_prefix = 36; + * Generated from protobuf field optional string objc_class_prefix = 36; + * @return string */ public function getObjcClassPrefix() { @@ -664,12 +633,12 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the objective c class prefix which is prepended to all objective c
      * generated classes from this .proto. There is no default.
-     * 
* - * optional string objc_class_prefix = 36; + * Generated from protobuf field optional string objc_class_prefix = 36; + * @param string $var + * @return $this */ public function setObjcClassPrefix($var) { @@ -686,11 +655,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Namespace for generated classes; defaults to the package.
-     * 
* - * optional string csharp_namespace = 37; + * Generated from protobuf field optional string csharp_namespace = 37; + * @return string */ public function getCsharpNamespace() { @@ -698,11 +666,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Namespace for generated classes; defaults to the package.
-     * 
* - * optional string csharp_namespace = 37; + * Generated from protobuf field optional string csharp_namespace = 37; + * @param string $var + * @return $this */ public function setCsharpNamespace($var) { @@ -719,14 +687,13 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * By default Swift generators will take the proto package and CamelCase it
      * replacing '.' with underscore and use that to prefix the types/symbols
      * defined. When this options is provided, they will use this value instead
      * to prefix the types/symbols defined.
-     * 
* - * optional string swift_prefix = 39; + * Generated from protobuf field optional string swift_prefix = 39; + * @return string */ public function getSwiftPrefix() { @@ -734,14 +701,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * By default Swift generators will take the proto package and CamelCase it
      * replacing '.' with underscore and use that to prefix the types/symbols
      * defined. When this options is provided, they will use this value instead
      * to prefix the types/symbols defined.
-     * 
* - * optional string swift_prefix = 39; + * Generated from protobuf field optional string swift_prefix = 39; + * @param string $var + * @return $this */ public function setSwiftPrefix($var) { @@ -758,12 +725,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the php class prefix which is prepended to all php generated classes
      * from this .proto. Default is empty.
-     * 
* - * optional string php_class_prefix = 40; + * Generated from protobuf field optional string php_class_prefix = 40; + * @return string */ public function getPhpClassPrefix() { @@ -771,12 +737,12 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Sets the php class prefix which is prepended to all php generated classes
      * from this .proto. Default is empty.
-     * 
* - * optional string php_class_prefix = 40; + * Generated from protobuf field optional string php_class_prefix = 40; + * @param string $var + * @return $this */ public function setPhpClassPrefix($var) { @@ -793,13 +759,12 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Use this option to change the namespace of php generated classes. Default
      * is empty. When this option is empty, the package name will be used for
      * determining the namespace.
-     * 
* - * optional string php_namespace = 41; + * Generated from protobuf field optional string php_namespace = 41; + * @return string */ public function getPhpNamespace() { @@ -807,13 +772,13 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Use this option to change the namespace of php generated classes. Default
      * is empty. When this option is empty, the package name will be used for
      * determining the namespace.
-     * 
* - * optional string php_namespace = 41; + * Generated from protobuf field optional string php_namespace = 41; + * @param string $var + * @return $this */ public function setPhpNamespace($var) { @@ -830,11 +795,10 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -842,11 +806,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php index b550e7f1..4dd56ef8 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php +++ b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php @@ -5,36 +5,28 @@ namespace Google\Protobuf\Internal; /** - *
  * Generated classes can be optimized for speed or code size.
- * 
* - * Protobuf enum google.protobuf.FileOptions.OptimizeMode + * Protobuf enum Google\Protobuf\Internal */ class FileOptions_OptimizeMode { /** - *
      * Generate complete code for parsing, serialization,
-     * 
* - * SPEED = 1; + * Generated from protobuf enum SPEED = 1; */ const SPEED = 1; /** - *
      * etc.
-     * 
* - * CODE_SIZE = 2; + * Generated from protobuf enum CODE_SIZE = 2; */ const CODE_SIZE = 2; /** - *
      * Generate code using MessageLite and the lite runtime.
-     * 
* - * LITE_RUNTIME = 3; + * Generated from protobuf enum LITE_RUNTIME = 3; */ const LITE_RUNTIME = 3; } diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php index 1e666f31..35b47526 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php @@ -12,23 +12,19 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes the relationship between generated code and its original source
  * file. A GeneratedCodeInfo message is associated with only one generated
  * source file, but may contain references to different source .proto files.
- * 
* - * Protobuf type google.protobuf.GeneratedCodeInfo + * Generated from protobuf message google.protobuf.GeneratedCodeInfo */ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message { /** - *
      * An Annotation connects some span of text in generated code to an element
      * of its generating .proto file.
-     * 
* - * repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + * Generated from protobuf field repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; */ private $annotation; private $has_annotation = false; @@ -39,12 +35,11 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message } /** - *
      * An Annotation connects some span of text in generated code to an element
      * of its generating .proto file.
-     * 
* - * repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + * Generated from protobuf field repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getAnnotation() { @@ -52,12 +47,12 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message } /** - *
      * An Annotation connects some span of text in generated code to an element
      * of its generating .proto file.
-     * 
* - * repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + * Generated from protobuf field repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + * @param \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setAnnotation(&$var) { diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php index 8d227e1c..c2e22e89 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php @@ -12,47 +12,39 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.GeneratedCodeInfo.Annotation + * Generated from protobuf message google.protobuf.GeneratedCodeInfo.Annotation */ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message { /** - *
      * Identifies the element in the original source .proto file. This field
      * is formatted the same as SourceCodeInfo.Location.path.
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; */ private $path; private $has_path = false; /** - *
      * Identifies the filesystem path to the original source .proto.
-     * 
* - * optional string source_file = 2; + * Generated from protobuf field optional string source_file = 2; */ private $source_file = ''; private $has_source_file = false; /** - *
      * Identifies the starting offset in bytes in the generated code
      * that relates to the identified object.
-     * 
* - * optional int32 begin = 3; + * Generated from protobuf field optional int32 begin = 3; */ private $begin = 0; private $has_begin = false; /** - *
      * Identifies the ending offset in bytes in the generated code that
      * relates to the identified offset. The end offset should be one past
      * the last relevant byte (so the length of the text = end - begin).
-     * 
* - * optional int32 end = 4; + * Generated from protobuf field optional int32 end = 4; */ private $end = 0; private $has_end = false; @@ -63,12 +55,11 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the element in the original source .proto file. This field
      * is formatted the same as SourceCodeInfo.Location.path.
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getPath() { @@ -76,12 +67,12 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the element in the original source .proto file. This field
      * is formatted the same as SourceCodeInfo.Location.path.
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setPath(&$var) { @@ -98,11 +89,10 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the filesystem path to the original source .proto.
-     * 
* - * optional string source_file = 2; + * Generated from protobuf field optional string source_file = 2; + * @return string */ public function getSourceFile() { @@ -110,11 +100,11 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the filesystem path to the original source .proto.
-     * 
* - * optional string source_file = 2; + * Generated from protobuf field optional string source_file = 2; + * @param string $var + * @return $this */ public function setSourceFile($var) { @@ -131,12 +121,11 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the starting offset in bytes in the generated code
      * that relates to the identified object.
-     * 
* - * optional int32 begin = 3; + * Generated from protobuf field optional int32 begin = 3; + * @return int */ public function getBegin() { @@ -144,12 +133,12 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the starting offset in bytes in the generated code
      * that relates to the identified object.
-     * 
* - * optional int32 begin = 3; + * Generated from protobuf field optional int32 begin = 3; + * @param int $var + * @return $this */ public function setBegin($var) { @@ -166,13 +155,12 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the ending offset in bytes in the generated code that
      * relates to the identified offset. The end offset should be one past
      * the last relevant byte (so the length of the text = end - begin).
-     * 
* - * optional int32 end = 4; + * Generated from protobuf field optional int32 end = 4; + * @return int */ public function getEnd() { @@ -180,13 +168,13 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies the ending offset in bytes in the generated code that
      * relates to the identified offset. The end offset should be one past
      * the last relevant byte (so the length of the text = end - begin).
-     * 
* - * optional int32 end = 4; + * Generated from protobuf field optional int32 end = 4; + * @param int $var + * @return $this */ public function setEnd($var) { diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index a5835358..3677ca38 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -12,12 +12,11 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.MessageOptions + * Generated from protobuf message google.protobuf.MessageOptions */ class MessageOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Set true to use the old proto1 MessageSet wire format for extensions.
      * This is provided for backwards-compatibility with the MessageSet wire
      * format.  You should not use this for any other reason:  It's less
@@ -33,41 +32,35 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * be int32s, enums, or repeated messages.
      * Because this is an option, the above two restrictions are not enforced by
      * the protocol compiler.
-     * 
* - * optional bool message_set_wire_format = 1 [default = false]; + * Generated from protobuf field optional bool message_set_wire_format = 1 [default = false]; */ private $message_set_wire_format = false; private $has_message_set_wire_format = false; /** - *
      * Disables the generation of the standard "descriptor()" accessor, which can
      * conflict with a field of the same name.  This is meant to make migration
      * from proto1 easier; new code should avoid fields named "descriptor".
-     * 
* - * optional bool no_standard_descriptor_accessor = 2 [default = false]; + * Generated from protobuf field optional bool no_standard_descriptor_accessor = 2 [default = false]; */ private $no_standard_descriptor_accessor = false; private $has_no_standard_descriptor_accessor = false; /** - *
      * Is this message deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the message, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating messages.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * Whether the message is an automatically generated map entry type for the
      * maps field.
      * For maps fields:
-     *     map<KeyType, ValueType> map_field = 1;
+     *     map map_field = 1;
      * The parsed descriptor looks like:
      *     message MapFieldEntry {
      *         option map_entry = true;
@@ -82,18 +75,15 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * NOTE: Do not set the option in .proto files. Always use the maps syntax
      * instead. The option should only be implicitly set by the proto compiler
      * parser.
-     * 
* - * optional bool map_entry = 7; + * Generated from protobuf field optional bool map_entry = 7; */ private $map_entry = false; private $has_map_entry = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -104,7 +94,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Set true to use the old proto1 MessageSet wire format for extensions.
      * This is provided for backwards-compatibility with the MessageSet wire
      * format.  You should not use this for any other reason:  It's less
@@ -120,9 +109,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * be int32s, enums, or repeated messages.
      * Because this is an option, the above two restrictions are not enforced by
      * the protocol compiler.
-     * 
* - * optional bool message_set_wire_format = 1 [default = false]; + * Generated from protobuf field optional bool message_set_wire_format = 1 [default = false]; + * @return bool */ public function getMessageSetWireFormat() { @@ -130,7 +119,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Set true to use the old proto1 MessageSet wire format for extensions.
      * This is provided for backwards-compatibility with the MessageSet wire
      * format.  You should not use this for any other reason:  It's less
@@ -146,9 +134,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * be int32s, enums, or repeated messages.
      * Because this is an option, the above two restrictions are not enforced by
      * the protocol compiler.
-     * 
* - * optional bool message_set_wire_format = 1 [default = false]; + * Generated from protobuf field optional bool message_set_wire_format = 1 [default = false]; + * @param bool $var + * @return $this */ public function setMessageSetWireFormat($var) { @@ -165,13 +154,12 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Disables the generation of the standard "descriptor()" accessor, which can
      * conflict with a field of the same name.  This is meant to make migration
      * from proto1 easier; new code should avoid fields named "descriptor".
-     * 
* - * optional bool no_standard_descriptor_accessor = 2 [default = false]; + * Generated from protobuf field optional bool no_standard_descriptor_accessor = 2 [default = false]; + * @return bool */ public function getNoStandardDescriptorAccessor() { @@ -179,13 +167,13 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Disables the generation of the standard "descriptor()" accessor, which can
      * conflict with a field of the same name.  This is meant to make migration
      * from proto1 easier; new code should avoid fields named "descriptor".
-     * 
* - * optional bool no_standard_descriptor_accessor = 2 [default = false]; + * Generated from protobuf field optional bool no_standard_descriptor_accessor = 2 [default = false]; + * @param bool $var + * @return $this */ public function setNoStandardDescriptorAccessor($var) { @@ -202,14 +190,13 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this message deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the message, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating messages.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @return bool */ public function getDeprecated() { @@ -217,14 +204,14 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this message deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the message, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating messages.
-     * 
* - * optional bool deprecated = 3 [default = false]; + * Generated from protobuf field optional bool deprecated = 3 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -241,11 +228,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Whether the message is an automatically generated map entry type for the
      * maps field.
      * For maps fields:
-     *     map<KeyType, ValueType> map_field = 1;
+     *     map map_field = 1;
      * The parsed descriptor looks like:
      *     message MapFieldEntry {
      *         option map_entry = true;
@@ -260,9 +246,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * NOTE: Do not set the option in .proto files. Always use the maps syntax
      * instead. The option should only be implicitly set by the proto compiler
      * parser.
-     * 
* - * optional bool map_entry = 7; + * Generated from protobuf field optional bool map_entry = 7; + * @return bool */ public function getMapEntry() { @@ -270,11 +256,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Whether the message is an automatically generated map entry type for the
      * maps field.
      * For maps fields:
-     *     map<KeyType, ValueType> map_field = 1;
+     *     map map_field = 1;
      * The parsed descriptor looks like:
      *     message MapFieldEntry {
      *         option map_entry = true;
@@ -289,9 +274,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
      * NOTE: Do not set the option in .proto files. Always use the maps syntax
      * instead. The option should only be implicitly set by the proto compiler
      * parser.
-     * 
* - * optional bool map_entry = 7; + * Generated from protobuf field optional bool map_entry = 7; + * @param bool $var + * @return $this */ public function setMapEntry($var) { @@ -308,11 +294,10 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -320,11 +305,11 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index c3f9f064..69c25b69 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -12,54 +12,46 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a method of a service.
- * 
* - * Protobuf type google.protobuf.MethodDescriptorProto + * Generated from protobuf message google.protobuf.MethodDescriptorProto */ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - *
      * Input and output type names.  These are resolved in the same way as
      * FieldDescriptorProto.type_name, but must refer to a message type.
-     * 
* - * optional string input_type = 2; + * Generated from protobuf field optional string input_type = 2; */ private $input_type = ''; private $has_input_type = false; /** - * optional string output_type = 3; + * Generated from protobuf field optional string output_type = 3; */ private $output_type = ''; private $has_output_type = false; /** - * optional .google.protobuf.MethodOptions options = 4; + * Generated from protobuf field optional .google.protobuf.MethodOptions options = 4; */ private $options = null; private $has_options = false; /** - *
      * Identifies if client streams multiple client messages
-     * 
* - * optional bool client_streaming = 5 [default = false]; + * Generated from protobuf field optional bool client_streaming = 5 [default = false]; */ private $client_streaming = false; private $has_client_streaming = false; /** - *
      * Identifies if server streams multiple server messages
-     * 
* - * optional bool server_streaming = 6 [default = false]; + * Generated from protobuf field optional bool server_streaming = 6 [default = false]; */ private $server_streaming = false; private $has_server_streaming = false; @@ -70,7 +62,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -78,7 +71,9 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -95,12 +90,11 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Input and output type names.  These are resolved in the same way as
      * FieldDescriptorProto.type_name, but must refer to a message type.
-     * 
* - * optional string input_type = 2; + * Generated from protobuf field optional string input_type = 2; + * @return string */ public function getInputType() { @@ -108,12 +102,12 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Input and output type names.  These are resolved in the same way as
      * FieldDescriptorProto.type_name, but must refer to a message type.
-     * 
* - * optional string input_type = 2; + * Generated from protobuf field optional string input_type = 2; + * @param string $var + * @return $this */ public function setInputType($var) { @@ -130,7 +124,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string output_type = 3; + * Generated from protobuf field optional string output_type = 3; + * @return string */ public function getOutputType() { @@ -138,7 +133,9 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string output_type = 3; + * Generated from protobuf field optional string output_type = 3; + * @param string $var + * @return $this */ public function setOutputType($var) { @@ -155,7 +152,8 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MethodOptions options = 4; + * Generated from protobuf field optional .google.protobuf.MethodOptions options = 4; + * @return \Google\Protobuf\Internal\MethodOptions */ public function getOptions() { @@ -163,7 +161,9 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MethodOptions options = 4; + * Generated from protobuf field optional .google.protobuf.MethodOptions options = 4; + * @param \Google\Protobuf\Internal\MethodOptions $var + * @return $this */ public function setOptions(&$var) { @@ -180,11 +180,10 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies if client streams multiple client messages
-     * 
* - * optional bool client_streaming = 5 [default = false]; + * Generated from protobuf field optional bool client_streaming = 5 [default = false]; + * @return bool */ public function getClientStreaming() { @@ -192,11 +191,11 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies if client streams multiple client messages
-     * 
* - * optional bool client_streaming = 5 [default = false]; + * Generated from protobuf field optional bool client_streaming = 5 [default = false]; + * @param bool $var + * @return $this */ public function setClientStreaming($var) { @@ -213,11 +212,10 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies if server streams multiple server messages
-     * 
* - * optional bool server_streaming = 6 [default = false]; + * Generated from protobuf field optional bool server_streaming = 6 [default = false]; + * @return bool */ public function getServerStreaming() { @@ -225,11 +223,11 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies if server streams multiple server messages
-     * 
* - * optional bool server_streaming = 6 [default = false]; + * Generated from protobuf field optional bool server_streaming = 6 [default = false]; + * @param bool $var + * @return $this */ public function setServerStreaming($var) { diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index e8d36d3c..5b2db776 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -12,33 +12,29 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.MethodOptions + * Generated from protobuf message google.protobuf.MethodOptions */ class MethodOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Is this method deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the method, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating methods.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - * optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + * Generated from protobuf field optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; */ private $idempotency_level = 0; private $has_idempotency_level = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -49,14 +45,13 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this method deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the method, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating methods.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; + * @return bool */ public function getDeprecated() { @@ -64,14 +59,14 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this method deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the method, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating methods.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -88,7 +83,8 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + * Generated from protobuf field optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + * @return int */ public function getIdempotencyLevel() { @@ -96,7 +92,9 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + * Generated from protobuf field optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + * @param int $var + * @return $this */ public function setIdempotencyLevel($var) { @@ -113,11 +111,10 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -125,11 +122,11 @@ class MethodOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php index ce4adfe7..9e06d8ee 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php @@ -5,34 +5,28 @@ namespace Google\Protobuf\Internal; /** - *
  * Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
  * or neither? HTTP based RPC implementation may choose GET verb for safe
  * methods, and PUT verb for idempotent methods instead of the default POST.
- * 
* - * Protobuf enum google.protobuf.MethodOptions.IdempotencyLevel + * Protobuf enum Google\Protobuf\Internal */ class MethodOptions_IdempotencyLevel { /** - * IDEMPOTENCY_UNKNOWN = 0; + * Generated from protobuf enum IDEMPOTENCY_UNKNOWN = 0; */ const IDEMPOTENCY_UNKNOWN = 0; /** - *
      * implies idempotent
-     * 
* - * NO_SIDE_EFFECTS = 1; + * Generated from protobuf enum NO_SIDE_EFFECTS = 1; */ const NO_SIDE_EFFECTS = 1; /** - *
      * idempotent, but may have side effects
-     * 
* - * IDEMPOTENT = 2; + * Generated from protobuf enum IDEMPOTENT = 2; */ const IDEMPOTENT = 2; } diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index 744ca638..0d4f3bdc 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -12,21 +12,19 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a oneof.
- * 
* - * Protobuf type google.protobuf.OneofDescriptorProto + * Generated from protobuf message google.protobuf.OneofDescriptorProto */ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * optional .google.protobuf.OneofOptions options = 2; + * Generated from protobuf field optional .google.protobuf.OneofOptions options = 2; */ private $options = null; private $has_options = false; @@ -37,7 +35,8 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -45,7 +44,9 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -62,7 +63,8 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.OneofOptions options = 2; + * Generated from protobuf field optional .google.protobuf.OneofOptions options = 2; + * @return \Google\Protobuf\Internal\OneofOptions */ public function getOptions() { @@ -70,7 +72,9 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.OneofOptions options = 2; + * Generated from protobuf field optional .google.protobuf.OneofOptions options = 2; + * @param \Google\Protobuf\Internal\OneofOptions $var + * @return $this */ public function setOptions(&$var) { diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php index b3cd51ed..aa8c934c 100644 --- a/php/src/Google/Protobuf/Internal/OneofOptions.php +++ b/php/src/Google/Protobuf/Internal/OneofOptions.php @@ -12,16 +12,14 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.OneofOptions + * Generated from protobuf message google.protobuf.OneofOptions */ class OneofOptions extends \Google\Protobuf\Internal\Message { /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -32,11 +30,10 @@ class OneofOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -44,11 +41,11 @@ class OneofOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index 7c85728a..963cd650 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -12,26 +12,24 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Describes a service.
- * 
* - * Protobuf type google.protobuf.ServiceDescriptorProto + * Generated from protobuf message google.protobuf.ServiceDescriptorProto */ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message { /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; */ private $name = ''; private $has_name = false; /** - * repeated .google.protobuf.MethodDescriptorProto method = 2; + * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; */ private $method; private $has_method = false; /** - * optional .google.protobuf.ServiceOptions options = 3; + * Generated from protobuf field optional .google.protobuf.ServiceOptions options = 3; */ private $options = null; private $has_options = false; @@ -42,7 +40,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @return string */ public function getName() { @@ -50,7 +49,9 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional string name = 1; + * Generated from protobuf field optional string name = 1; + * @param string $var + * @return $this */ public function setName($var) { @@ -67,7 +68,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.MethodDescriptorProto method = 2; + * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getMethod() { @@ -75,7 +77,9 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.MethodDescriptorProto method = 2; + * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; + * @param \Google\Protobuf\Internal\MethodDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setMethod(&$var) { @@ -92,7 +96,8 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.ServiceOptions options = 3; + * Generated from protobuf field optional .google.protobuf.ServiceOptions options = 3; + * @return \Google\Protobuf\Internal\ServiceOptions */ public function getOptions() { @@ -100,7 +105,9 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message } /** - * optional .google.protobuf.ServiceOptions options = 3; + * Generated from protobuf field optional .google.protobuf.ServiceOptions options = 3; + * @param \Google\Protobuf\Internal\ServiceOptions $var + * @return $this */ public function setOptions(&$var) { diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php index 0f3a8d74..ea649865 100644 --- a/php/src/Google/Protobuf/Internal/ServiceOptions.php +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -12,28 +12,24 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.ServiceOptions + * Generated from protobuf message google.protobuf.ServiceOptions */ class ServiceOptions extends \Google\Protobuf\Internal\Message { /** - *
      * Is this service deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the service, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating services.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; */ private $deprecated = false; private $has_deprecated = false; /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; */ private $uninterpreted_option; private $has_uninterpreted_option = false; @@ -44,14 +40,13 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this service deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the service, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating services.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; + * @return bool */ public function getDeprecated() { @@ -59,14 +54,14 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message } /** - *
      * Is this service deprecated?
      * Depending on the target platform, this can emit Deprecated annotations
      * for the service, or it will be completely ignored; in the very least,
      * this is a formalization for deprecating services.
-     * 
* - * optional bool deprecated = 33 [default = false]; + * Generated from protobuf field optional bool deprecated = 33 [default = false]; + * @param bool $var + * @return $this */ public function setDeprecated($var) { @@ -83,11 +78,10 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getUninterpretedOption() { @@ -95,11 +89,11 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message } /** - *
      * The parser stores options it doesn't recognize here. See above.
-     * 
* - * repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setUninterpretedOption(&$var) { diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php index 7eef3424..65530586 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php @@ -12,17 +12,14 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Encapsulates information about the original source file from which a
  * FileDescriptorProto was generated.
- * 
* - * Protobuf type google.protobuf.SourceCodeInfo + * Generated from protobuf message google.protobuf.SourceCodeInfo */ class SourceCodeInfo extends \Google\Protobuf\Internal\Message { /** - *
      * A Location identifies a piece of source code in a .proto file which
      * corresponds to a particular definition.  This information is intended
      * to be useful to IDEs, code indexers, documentation generators, and similar
@@ -64,9 +61,8 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message
      * - Code which tries to interpret locations should probably be designed to
      *   ignore those that it doesn't understand, as more types of locations could
      *   be recorded in the future.
-     * 
* - * repeated .google.protobuf.SourceCodeInfo.Location location = 1; + * Generated from protobuf field repeated .google.protobuf.SourceCodeInfo.Location location = 1; */ private $location; private $has_location = false; @@ -77,7 +73,6 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message } /** - *
      * A Location identifies a piece of source code in a .proto file which
      * corresponds to a particular definition.  This information is intended
      * to be useful to IDEs, code indexers, documentation generators, and similar
@@ -119,9 +114,9 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message
      * - Code which tries to interpret locations should probably be designed to
      *   ignore those that it doesn't understand, as more types of locations could
      *   be recorded in the future.
-     * 
* - * repeated .google.protobuf.SourceCodeInfo.Location location = 1; + * Generated from protobuf field repeated .google.protobuf.SourceCodeInfo.Location location = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getLocation() { @@ -129,7 +124,6 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message } /** - *
      * A Location identifies a piece of source code in a .proto file which
      * corresponds to a particular definition.  This information is intended
      * to be useful to IDEs, code indexers, documentation generators, and similar
@@ -171,9 +165,10 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message
      * - Code which tries to interpret locations should probably be designed to
      *   ignore those that it doesn't understand, as more types of locations could
      *   be recorded in the future.
-     * 
* - * repeated .google.protobuf.SourceCodeInfo.Location location = 1; + * Generated from protobuf field repeated .google.protobuf.SourceCodeInfo.Location location = 1; + * @param \Google\Protobuf\Internal\SourceCodeInfo_Location[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setLocation(&$var) { diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php index cf23e38b..b33013b8 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php @@ -12,12 +12,11 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type google.protobuf.SourceCodeInfo.Location + * Generated from protobuf message google.protobuf.SourceCodeInfo.Location */ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message { /** - *
      * Identifies which part of the FileDescriptorProto was defined at this
      * location.
      * Each element is a field number or an index.  They form a path from
@@ -39,27 +38,23 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *   [ 4, 3, 2, 7 ]
      * this path refers to the whole field declaration (from the beginning
      * of the label to the terminating semicolon).
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; */ private $path; private $has_path = false; /** - *
      * Always has exactly three or four elements: start line, start column,
      * end line (optional, otherwise assumed same as start line), end column.
      * These are packed into a single field for efficiency.  Note that line
      * and column numbers are zero-based -- typically you will want to add
      * 1 to each before displaying to a user.
-     * 
* - * repeated int32 span = 2 [packed = true]; + * Generated from protobuf field repeated int32 span = 2 [packed = true]; */ private $span; private $has_span = false; /** - *
      * If this SourceCodeInfo represents a complete declaration, these are any
      * comments appearing before and after the declaration which appear to be
      * attached to the declaration.
@@ -96,19 +91,18 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *    * grault. */
      *   optional int32 grault = 6;
      *   // ignored detached comments.
-     * 
* - * optional string leading_comments = 3; + * Generated from protobuf field optional string leading_comments = 3; */ private $leading_comments = ''; private $has_leading_comments = false; /** - * optional string trailing_comments = 4; + * Generated from protobuf field optional string trailing_comments = 4; */ private $trailing_comments = ''; private $has_trailing_comments = false; /** - * repeated string leading_detached_comments = 6; + * Generated from protobuf field repeated string leading_detached_comments = 6; */ private $leading_detached_comments; private $has_leading_detached_comments = false; @@ -119,7 +113,6 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies which part of the FileDescriptorProto was defined at this
      * location.
      * Each element is a field number or an index.  They form a path from
@@ -141,9 +134,9 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *   [ 4, 3, 2, 7 ]
      * this path refers to the whole field declaration (from the beginning
      * of the label to the terminating semicolon).
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getPath() { @@ -151,7 +144,6 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * Identifies which part of the FileDescriptorProto was defined at this
      * location.
      * Each element is a field number or an index.  They form a path from
@@ -173,9 +165,10 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *   [ 4, 3, 2, 7 ]
      * this path refers to the whole field declaration (from the beginning
      * of the label to the terminating semicolon).
-     * 
* - * repeated int32 path = 1 [packed = true]; + * Generated from protobuf field repeated int32 path = 1 [packed = true]; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setPath(&$var) { @@ -192,15 +185,14 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * Always has exactly three or four elements: start line, start column,
      * end line (optional, otherwise assumed same as start line), end column.
      * These are packed into a single field for efficiency.  Note that line
      * and column numbers are zero-based -- typically you will want to add
      * 1 to each before displaying to a user.
-     * 
* - * repeated int32 span = 2 [packed = true]; + * Generated from protobuf field repeated int32 span = 2 [packed = true]; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getSpan() { @@ -208,15 +200,15 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * Always has exactly three or four elements: start line, start column,
      * end line (optional, otherwise assumed same as start line), end column.
      * These are packed into a single field for efficiency.  Note that line
      * and column numbers are zero-based -- typically you will want to add
      * 1 to each before displaying to a user.
-     * 
* - * repeated int32 span = 2 [packed = true]; + * Generated from protobuf field repeated int32 span = 2 [packed = true]; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setSpan(&$var) { @@ -233,7 +225,6 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * If this SourceCodeInfo represents a complete declaration, these are any
      * comments appearing before and after the declaration which appear to be
      * attached to the declaration.
@@ -270,9 +261,9 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *    * grault. */
      *   optional int32 grault = 6;
      *   // ignored detached comments.
-     * 
* - * optional string leading_comments = 3; + * Generated from protobuf field optional string leading_comments = 3; + * @return string */ public function getLeadingComments() { @@ -280,7 +271,6 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - *
      * If this SourceCodeInfo represents a complete declaration, these are any
      * comments appearing before and after the declaration which appear to be
      * attached to the declaration.
@@ -317,9 +307,10 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message
      *    * grault. */
      *   optional int32 grault = 6;
      *   // ignored detached comments.
-     * 
* - * optional string leading_comments = 3; + * Generated from protobuf field optional string leading_comments = 3; + * @param string $var + * @return $this */ public function setLeadingComments($var) { @@ -336,7 +327,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - * optional string trailing_comments = 4; + * Generated from protobuf field optional string trailing_comments = 4; + * @return string */ public function getTrailingComments() { @@ -344,7 +336,9 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - * optional string trailing_comments = 4; + * Generated from protobuf field optional string trailing_comments = 4; + * @param string $var + * @return $this */ public function setTrailingComments($var) { @@ -361,7 +355,8 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - * repeated string leading_detached_comments = 6; + * Generated from protobuf field repeated string leading_detached_comments = 6; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getLeadingDetachedComments() { @@ -369,7 +364,9 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message } /** - * repeated string leading_detached_comments = 6; + * Generated from protobuf field repeated string leading_detached_comments = 6; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setLeadingDetachedComments(&$var) { diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php index 08e071d4..a4fab343 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -12,56 +12,52 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * A message representing a option the parser does not recognize. This only
  * appears in options protos created by the compiler::Parser class.
  * DescriptorPool resolves these when building Descriptor objects. Therefore,
  * options protos in descriptor objects (e.g. returned by Descriptor::options(),
  * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
  * in them.
- * 
* - * Protobuf type google.protobuf.UninterpretedOption + * Generated from protobuf message google.protobuf.UninterpretedOption */ class UninterpretedOption extends \Google\Protobuf\Internal\Message { /** - * repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; */ private $name; private $has_name = false; /** - *
      * The value of the uninterpreted option, in whatever type the tokenizer
      * identified it as during parsing. Exactly one of these should be set.
-     * 
* - * optional string identifier_value = 3; + * Generated from protobuf field optional string identifier_value = 3; */ private $identifier_value = ''; private $has_identifier_value = false; /** - * optional uint64 positive_int_value = 4; + * Generated from protobuf field optional uint64 positive_int_value = 4; */ private $positive_int_value = 0; private $has_positive_int_value = false; /** - * optional int64 negative_int_value = 5; + * Generated from protobuf field optional int64 negative_int_value = 5; */ private $negative_int_value = 0; private $has_negative_int_value = false; /** - * optional double double_value = 6; + * Generated from protobuf field optional double double_value = 6; */ private $double_value = 0.0; private $has_double_value = false; /** - * optional bytes string_value = 7; + * Generated from protobuf field optional bytes string_value = 7; */ private $string_value = ''; private $has_string_value = false; /** - * optional string aggregate_value = 8; + * Generated from protobuf field optional string aggregate_value = 8; */ private $aggregate_value = ''; private $has_aggregate_value = false; @@ -72,7 +68,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getName() { @@ -80,7 +77,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + * Generated from protobuf field repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + * @param \Google\Protobuf\Internal\UninterpretedOption_NamePart[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ public function setName(&$var) { @@ -97,12 +96,11 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - *
      * The value of the uninterpreted option, in whatever type the tokenizer
      * identified it as during parsing. Exactly one of these should be set.
-     * 
* - * optional string identifier_value = 3; + * Generated from protobuf field optional string identifier_value = 3; + * @return string */ public function getIdentifierValue() { @@ -110,12 +108,12 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - *
      * The value of the uninterpreted option, in whatever type the tokenizer
      * identified it as during parsing. Exactly one of these should be set.
-     * 
* - * optional string identifier_value = 3; + * Generated from protobuf field optional string identifier_value = 3; + * @param string $var + * @return $this */ public function setIdentifierValue($var) { @@ -132,7 +130,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional uint64 positive_int_value = 4; + * Generated from protobuf field optional uint64 positive_int_value = 4; + * @return int|string */ public function getPositiveIntValue() { @@ -140,7 +139,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional uint64 positive_int_value = 4; + * Generated from protobuf field optional uint64 positive_int_value = 4; + * @param int|string $var + * @return $this */ public function setPositiveIntValue($var) { @@ -157,7 +158,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional int64 negative_int_value = 5; + * Generated from protobuf field optional int64 negative_int_value = 5; + * @return int|string */ public function getNegativeIntValue() { @@ -165,7 +167,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional int64 negative_int_value = 5; + * Generated from protobuf field optional int64 negative_int_value = 5; + * @param int|string $var + * @return $this */ public function setNegativeIntValue($var) { @@ -182,7 +186,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional double double_value = 6; + * Generated from protobuf field optional double double_value = 6; + * @return float */ public function getDoubleValue() { @@ -190,7 +195,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional double double_value = 6; + * Generated from protobuf field optional double double_value = 6; + * @param float $var + * @return $this */ public function setDoubleValue($var) { @@ -207,7 +214,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional bytes string_value = 7; + * Generated from protobuf field optional bytes string_value = 7; + * @return string */ public function getStringValue() { @@ -215,7 +223,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional bytes string_value = 7; + * Generated from protobuf field optional bytes string_value = 7; + * @param string $var + * @return $this */ public function setStringValue($var) { @@ -232,7 +242,8 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional string aggregate_value = 8; + * Generated from protobuf field optional string aggregate_value = 8; + * @return string */ public function getAggregateValue() { @@ -240,7 +251,9 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message } /** - * optional string aggregate_value = 8; + * Generated from protobuf field optional string aggregate_value = 8; + * @param string $var + * @return $this */ public function setAggregateValue($var) { diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php index eb27754c..69a96d45 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php @@ -12,25 +12,23 @@ use Google\Protobuf\Internal\InputStream; use Google\Protobuf\Internal\GPBUtil; /** - *
  * The name of the uninterpreted option.  Each string represents a segment in
  * a dot-separated name.  is_extension is true iff a segment represents an
  * extension (denoted with parentheses in options specs in .proto files).
  * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
  * "foo.(bar.baz).qux".
- * 
* - * Protobuf type google.protobuf.UninterpretedOption.NamePart + * Generated from protobuf message google.protobuf.UninterpretedOption.NamePart */ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message { /** - * required string name_part = 1; + * Generated from protobuf field required string name_part = 1; */ private $name_part = ''; private $has_name_part = false; /** - * required bool is_extension = 2; + * Generated from protobuf field required bool is_extension = 2; */ private $is_extension = false; private $has_is_extension = false; @@ -41,7 +39,8 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message } /** - * required string name_part = 1; + * Generated from protobuf field required string name_part = 1; + * @return string */ public function getNamePart() { @@ -49,7 +48,9 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message } /** - * required string name_part = 1; + * Generated from protobuf field required string name_part = 1; + * @param string $var + * @return $this */ public function setNamePart($var) { @@ -66,7 +67,8 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message } /** - * required bool is_extension = 2; + * Generated from protobuf field required bool is_extension = 2; + * @return bool */ public function getIsExtension() { @@ -74,7 +76,9 @@ class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message } /** - * required bool is_extension = 2; + * Generated from protobuf field required bool is_extension = 2; + * @param bool $var + * @return $this */ public function setIsExtension($var) { diff --git a/php/tests/generated_phpdoc_test.php b/php/tests/generated_phpdoc_test.php new file mode 100644 index 00000000..6c1a26f7 --- /dev/null +++ b/php/tests/generated_phpdoc_test.php @@ -0,0 +1,337 @@ +getDocComment(); + $this->assertContains('foo.TestMessage', $doc); + } + + /** + * @dataProvider providePhpDocForGettersAndSetters + */ + public function testPhpDocForIntGetters($methods, $expectedDoc) + { + $class = new ReflectionClass('Foo\TestMessage'); + foreach ($methods as $method) { + $doc = $class->getMethod($method)->getDocComment(); + $this->assertContains($expectedDoc, $doc); + } + } + + public function providePhpDocForGettersAndSetters() + { + return [ + [ + [ + 'setOptionalInt32', + 'setOptionalUint32', + 'setOptionalSint32', + 'setOptionalFixed32', + 'setOptionalSfixed32', + 'setOneofInt32', + 'setOneofUint32', + 'setOneofSint32', + 'setOneofFixed32', + 'setOneofSfixed32', + 'setOptionalEnum', + 'setOptionalNoNamespaceEnum', + 'setOptionalNestedEnum', + 'setOneofEnum' + ], + '@param int $var' + ], + [ + [ + 'setOptionalInt64', + 'setOptionalUint64', + 'setOptionalSint64', + 'setOptionalFixed64', + 'setOptionalSfixed64', + 'setOneofInt64', + 'setOneofUint64', + 'setOneofSint64', + 'setOneofFixed64', + 'setOneofSfixed64', + ], + '@param int|string $var' + ], + [ + [ + 'getOptionalInt32', + 'getOptionalUint32', + 'getOptionalSint32', + 'getOptionalFixed32', + 'getOptionalSfixed32', + 'getOneofInt32', + 'getOneofUint32', + 'getOneofSint32', + 'getOneofFixed32', + 'getOneofSfixed32', + 'getOptionalEnum', + 'getOptionalNoNamespaceEnum', + 'getOptionalNestedEnum', + 'getOneofEnum', + ], + '@return int' + ], + [ + [ + 'setOptionalInt64', + 'setOptionalUint64', + 'setOptionalSint64', + 'setOptionalFixed64', + 'setOptionalSfixed64', + 'setOneofInt64', + 'setOneofUint64', + 'setOneofSint64', + 'setOneofFixed64', + 'setOneofSfixed64', + ], + '@param int|string $var' + ], + [ + [ + 'getRepeatedInt32', + 'getRepeatedInt64', + 'getRepeatedUint32', + 'getRepeatedUint64', + 'getRepeatedSint32', + 'getRepeatedSint64', + 'getRepeatedFixed32', + 'getRepeatedFixed64', + 'getRepeatedSfixed32', + 'getRepeatedSfixed64', + 'getRepeatedFloat', + 'getRepeatedDouble', + 'getRepeatedBool', + 'getRepeatedString', + 'getRepeatedBytes', + 'getRepeatedEnum', + 'getRepeatedMessage', + 'getRepeatedRecursive', + 'getRepeatedNoNamespaceMessage', + 'getRepeatedNoNamespaceEnum', + ], + '@return \Google\Protobuf\Internal\RepeatedField' + ], + [ + [ + 'getMapInt32Int32', + 'getMapInt64Int64', + 'getMapUint32Uint32', + 'getMapUint64Uint64', + 'getMapSint32Sint32', + 'getMapSint64Sint64', + 'getMapFixed32Fixed32', + 'getMapFixed64Fixed64', + 'getMapSfixed32Sfixed32', + 'getMapSfixed64Sfixed64', + 'getMapInt32Float', + 'getMapInt32Double', + 'getMapBoolBool', + 'getMapStringString', + 'getMapInt32Bytes', + 'getMapInt32Enum', + 'getMapInt32Message', + 'getMapRecursive', + ], + '@return \Google\Protobuf\Internal\MapField' + ], + [ + [ + 'setRepeatedInt32', + 'setRepeatedUint32', + 'setRepeatedSint32', + 'setRepeatedFixed32', + 'setRepeatedSfixed32', + 'setRepeatedEnum', + 'setRepeatedNoNamespaceEnum', + ], + '@param int[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedInt64', + 'setRepeatedUint64', + 'setRepeatedSint64', + 'setRepeatedFixed64', + 'setRepeatedSfixed64', + ], + '@param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedFloat', + 'setRepeatedDouble', + ], + '@param float[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedBool', + ], + '@param bool[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedString', + 'setRepeatedBytes', + ], + '@param string[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedMessage', + ], + '@param \Foo\TestMessage_Sub[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedRecursive', + ], + '@param \Foo\TestMessage[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setRepeatedNoNamespaceMessage', + ], + '@param \NoNamespaceMessage[]|\Google\Protobuf\Internal\RepeatedField $var' + ], + [ + [ + 'setMapInt32Int32', + 'setMapInt64Int64', + 'setMapUint32Uint32', + 'setMapUint64Uint64', + 'setMapSint32Sint32', + 'setMapSint64Sint64', + 'setMapFixed32Fixed32', + 'setMapFixed64Fixed64', + 'setMapSfixed32Sfixed32', + 'setMapSfixed64Sfixed64', + 'setMapInt32Float', + 'setMapInt32Double', + 'setMapBoolBool', + 'setMapStringString', + 'setMapInt32Bytes', + 'setMapInt32Enum', + 'setMapInt32Message', + 'setMapRecursive', + ], + '@param array|\Google\Protobuf\Internal\MapField $var' + ], + [ + [ + 'getOptionalFloat', + 'getOptionalDouble', + 'getOneofDouble', + 'getOneofFloat', + ], + '@return float' + ], + [ + [ + 'setOptionalFloat', + 'setOptionalDouble', + 'setOneofDouble', + 'setOneofFloat', + ], + '@param float $var' + ], + [ + [ + 'getOptionalBool', + 'getOneofBool', + ], + '@return bool'], + [ + [ + 'setOptionalBool', + 'setOneofBool', + ], + '@param bool $var' + ], + [ + [ + 'getOptionalString', + 'getOptionalBytes', + 'getOneofString', + 'getOneofBytes', + 'getMyOneof', + ], + '@return string' + ], + [ + [ + 'setOptionalString', + 'setOptionalBytes', + 'setOneofString', + 'setOneofBytes', + ], + '@param string $var' + ], + + [ + [ + 'getOptionalMessage', + 'getOneofMessage' + ], + '@return \Foo\TestMessage_Sub' + ], + [ + [ + 'setOptionalMessage', + 'setOneofMessage' + ], + '@param \Foo\TestMessage_Sub $var' + ], + [ + [ + 'getOptionalIncludedMessage' + ], + '@return \Bar\TestInclude' + ], + [ + [ + 'setOptionalIncludedMessage' + ], + '@param \Bar\TestInclude $var' + ], + [ + [ + 'getRecursive' + ], + '@return \Foo\TestMessage' + ], + [ + [ + 'setRecursive' + ], + '@param \Foo\TestMessage $var' + ], + + [ + [ + 'getOptionalNoNamespaceMessage' + ], + '@return \NoNamespaceMessage' + ], + [ + [ + 'setOptionalNoNamespaceMessage' + ], + '@param \NoNamespaceMessage $var' + ], + ]; + } +} diff --git a/php/tests/test.sh b/php/tests/test.sh index 69849ab3..6c6edd56 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -8,7 +8,7 @@ set -e phpize && ./configure CFLAGS='-g -O0' && make popd -tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) +tests=( array_test.php encode_decode_test.php generated_class_test.php generated_phpdoc_test.php map_field_test.php well_known_test.php ) for t in "${tests[@]}" do diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 78252817..03aebdb9 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -51,6 +51,9 @@ const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; const char* const kReservedNames[] = {"ARRAY", "Empty", "ECHO"}; const int kReservedNamesSize = 3; +const int kFieldSetter = 1; +const int kFieldGetter = 2; +const int kFieldProperty = 3; namespace google { namespace protobuf { @@ -71,10 +74,12 @@ std::string EscapeDollor(const string& to_escape); std::string BinaryToHex(const string& binary); void Indent(io::Printer* printer); void Outdent(io::Printer* printer); -void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message); -void GenerateFieldDocComment(io::Printer* printer, - const FieldDescriptor* field); -void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); +void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message, + int is_descriptor); +void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, + int is_descriptor, int function_type); +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, + int is_descriptor); void GenerateEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); @@ -306,6 +311,87 @@ std::string TypeName(const FieldDescriptor* field) { } } +std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor) { + if (field->is_map()) { + return "array|\\Google\\Protobuf\\Internal\\MapField"; + } + string type; + switch (field->type()) { + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_ENUM: + type = "int"; + break; + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: + type = "int|string"; + break; + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: + type = "float"; + break; + case FieldDescriptor::TYPE_BOOL: + type = "bool"; + break; + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: + type = "string"; + break; + case FieldDescriptor::TYPE_MESSAGE: + type = "\\" + FullClassName(field->message_type(), is_descriptor); + break; + case FieldDescriptor::TYPE_GROUP: + return "null"; + default: assert(false); return ""; + } + if (field->is_repeated()) { + // accommodate for edge case with multiple types. + size_t start_pos = type.find("|"); + if (start_pos != std::string::npos) { + type.replace(start_pos, 1, "[]|"); + } + type += "[]|\\Google\\Protobuf\\Internal\\RepeatedField"; + } + return type; +} + +std::string PhpGetterTypeName(const FieldDescriptor* field, bool is_descriptor) { + if (field->is_map()) { + return "\\Google\\Protobuf\\Internal\\MapField"; + } + if (field->is_repeated()) { + return "\\Google\\Protobuf\\Internal\\RepeatedField"; + } + switch (field->type()) { + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_ENUM: return "int"; + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_SINT64: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_SFIXED64: return "int|string"; + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: return "float"; + case FieldDescriptor::TYPE_BOOL: return "bool"; + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: return "string"; + case FieldDescriptor::TYPE_MESSAGE: + return "\\" + FullClassName(field->message_type(), is_descriptor); + case FieldDescriptor::TYPE_GROUP: return "null"; + default: assert(false); return ""; + } +} + std::string EnumOrMessageSuffix( const FieldDescriptor* field, bool is_descriptor) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { @@ -390,7 +476,7 @@ void Outdent(io::Printer* printer) { void GenerateField(const FieldDescriptor* field, io::Printer* printer, bool is_descriptor) { if (field->is_repeated()) { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); printer->Print( "private $^name^;\n", "name", field->name()); @@ -398,7 +484,7 @@ void GenerateField(const FieldDescriptor* field, io::Printer* printer, // Oneof fields are handled by GenerateOneofField. return; } else { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldProperty); printer->Print( "private $^name^ = ^default^;\n", "name", field->name(), @@ -426,7 +512,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, // Generate getter. if (oneof != NULL) { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( "public function get^camel_name^()\n" "{\n" @@ -435,7 +521,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, "camel_name", UnderscoresToCamelCase(field->name(), true), "number", IntToString(field->number())); } else { - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter); printer->Print( "public function get^camel_name^()\n" "{\n" @@ -446,7 +532,7 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, } // Generate setter. - GenerateFieldDocComment(printer, field); + GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter); printer->Print( "public function set^camel_name^(^var^)\n" "{\n", @@ -844,7 +930,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, "name", fullname.substr(0, lastindex)); } - GenerateEnumDocComment(&printer, en); + GenerateEnumDocComment(&printer, en, is_descriptor); if (lastindex != string::npos) { printer.Print( @@ -905,7 +991,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, GenerateUseDeclaration(is_descriptor, &printer); - GenerateMessageDocComment(&printer, message); + GenerateMessageDocComment(&printer, message, is_descriptor); if (lastindex != string::npos) { printer.Print( "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" @@ -953,6 +1039,9 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, for (int i = 0; i < message->oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); printer.Print( + "/**\n" + " * @return string\n" + " */\n" "public function get^camel_name^()\n" "{\n" " return $this->whichOneof(\"^name^\");\n" @@ -1019,22 +1108,6 @@ static string EscapePhpdoc(const string& input) { // does not have a corresponding @Deprecated annotation. result.append("@"); break; - case '<': - // Avoid interpretation as HTML. - result.append("<"); - break; - case '>': - // Avoid interpretation as HTML. - result.append(">"); - break; - case '&': - // Avoid interpretation as HTML. - result.append("&"); - break; - case '\\': - // Java interprets Unicode escape sequences anywhere! - result.append("\"); - break; default: result.push_back(c); break; @@ -1053,7 +1126,7 @@ static void GenerateDocCommentBodyForLocation( if (!comments.empty()) { // TODO(teboring): Ideally we should parse the comment text as Markdown and // write it back as HTML, but this requires a Markdown parser. For now - // we just use
 to get fixed-width text formatting.
+    //   we just use the proto comments unchanged.
 
     // If the comment itself contains block comment start or end markers,
     // HTML-escape them so that they don't accidentally close the doc comment.
@@ -1064,7 +1137,6 @@ static void GenerateDocCommentBodyForLocation(
       lines.pop_back();
     }
 
-    printer->Print(" * 
\n");
     for (int i = 0; i < lines.size(); i++) {
       // Most lines should start with a space.  Watch out for lines that start
       // with a /, since putting that right after the leading asterisk will
@@ -1076,7 +1148,6 @@ static void GenerateDocCommentBodyForLocation(
       }
     }
     printer->Print(
-        " * 
\n" " *\n"); } } @@ -1102,17 +1173,18 @@ static string FirstLineOf(const string& value) { } void GenerateMessageDocComment(io::Printer* printer, - const Descriptor* message) { + const Descriptor* message, int is_descriptor) { printer->Print("/**\n"); GenerateDocCommentBody(printer, message); printer->Print( - " * Protobuf type ^fullname^\n" + " * Generated from protobuf message ^messagename^\n" " */\n", - "fullname", EscapePhpdoc(message->full_name())); + "fullname", EscapePhpdoc(PhpName(message->full_name(), is_descriptor)), + "messagename", EscapePhpdoc(message->full_name())); } -void GenerateFieldDocComment(io::Printer* printer, - const FieldDescriptor* field) { +void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, + int is_descriptor, int function_type) { // In theory we should have slightly different comments for setters, getters, // etc., but in practice everyone already knows the difference between these // so it's redundant information. @@ -1124,18 +1196,27 @@ void GenerateFieldDocComment(io::Printer* printer, printer->Print("/**\n"); GenerateDocCommentBody(printer, field); printer->Print( - " * ^def^\n", + " * Generated from protobuf field ^def^\n", "def", EscapePhpdoc(FirstLineOf(field->DebugString()))); + if (function_type == kFieldSetter) { + printer->Print(" * @param ^php_type^ $var\n", + "php_type", PhpSetterTypeName(field, is_descriptor)); + printer->Print(" * @return $this\n"); + } else if (function_type == kFieldGetter) { + printer->Print(" * @return ^php_type^\n", + "php_type", PhpGetterTypeName(field, is_descriptor)); + } printer->Print(" */\n"); } -void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) { +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, + int is_descriptor) { printer->Print("/**\n"); GenerateDocCommentBody(printer, enum_); printer->Print( " * Protobuf enum ^fullname^\n" " */\n", - "fullname", EscapePhpdoc(enum_->full_name())); + "fullname", EscapePhpdoc(PhpName(enum_->full_name(), is_descriptor))); } void GenerateEnumValueDocComment(io::Printer* printer, @@ -1143,7 +1224,7 @@ void GenerateEnumValueDocComment(io::Printer* printer, printer->Print("/**\n"); GenerateDocCommentBody(printer, value); printer->Print( - " * ^def^\n" + " * Generated from protobuf enum ^def^\n" " */\n", "def", EscapePhpdoc(FirstLineOf(value->DebugString()))); } -- cgit v1.2.3 From ecca6ea95d56a6f70ff7b223ec3f904758acc8b1 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 30 Jun 2017 12:14:09 -0700 Subject: Add json encode/decode for php. (#3226) * Add json encode/decode for php. * Fix php conformance test on 32-bit machines. * Fix conformance test for c extension. * Fix comments --- Makefile.am | 92 ++- conformance/Makefile.am | 5 +- conformance/autoload.php | 21 + conformance/conformance_php.php | 7 +- conformance/failure_list_php.txt | 513 +----------- conformance/failure_list_php_c.txt | 32 +- conformance/failure_list_php_zts_c.txt | 225 +++++ php/ext/google/protobuf/encode_decode.c | 120 ++- php/ext/google/protobuf/message.c | 4 +- php/ext/google/protobuf/protobuf.h | 4 +- php/ext/google/protobuf/upb.c | 3 + .../Google/Protobuf/Internal/CodedInputStream.php | 373 +++++++++ .../Google/Protobuf/Internal/CodedOutputStream.php | 159 ++++ php/src/Google/Protobuf/Internal/Descriptor.php | 32 +- .../Google/Protobuf/Internal/EnumDescriptor.php | 16 + .../Protobuf/Internal/EnumValueDescriptor.php | 22 + .../Google/Protobuf/Internal/FieldDescriptor.php | 85 +- php/src/Google/Protobuf/Internal/GPBJsonWire.php | 285 +++++++ php/src/Google/Protobuf/Internal/GPBUtil.php | 70 +- php/src/Google/Protobuf/Internal/GPBWire.php | 49 +- php/src/Google/Protobuf/Internal/GPBWireType.php | 43 + php/src/Google/Protobuf/Internal/InputStream.php | 370 --------- php/src/Google/Protobuf/Internal/MapField.php | 2 +- php/src/Google/Protobuf/Internal/MapFieldIter.php | 14 +- php/src/Google/Protobuf/Internal/Message.php | 586 ++++++++++++- php/src/Google/Protobuf/Internal/OutputStream.php | 159 ---- .../Google/Protobuf/Internal/RawInputStream.php | 50 ++ php/tests/array_test.php | 625 +++----------- php/tests/compatibility_test.sh | 34 +- php/tests/encode_decode_test.php | 821 +++++++++--------- php/tests/gdb_test.sh | 2 +- php/tests/generated_class_test.php | 241 ------ php/tests/map_field_test.php | 277 +------ php/tests/memory_leak_test.php | 2 +- php/tests/php_implementation_test.php | 107 +-- php/tests/test_base.php | 3 + php/tests/undefined_test.php | 920 +++++++++++++++++++++ tests.sh | 59 +- 38 files changed, 3638 insertions(+), 2794 deletions(-) create mode 100644 conformance/autoload.php create mode 100644 conformance/failure_list_php_zts_c.txt create mode 100644 php/src/Google/Protobuf/Internal/CodedInputStream.php create mode 100644 php/src/Google/Protobuf/Internal/CodedOutputStream.php create mode 100644 php/src/Google/Protobuf/Internal/GPBJsonWire.php create mode 100644 php/src/Google/Protobuf/Internal/GPBWireType.php delete mode 100644 php/src/Google/Protobuf/Internal/InputStream.php delete mode 100644 php/src/Google/Protobuf/Internal/OutputStream.php create mode 100644 php/src/Google/Protobuf/Internal/RawInputStream.php create mode 100644 php/tests/undefined_test.php (limited to 'php/src/Google/Protobuf') diff --git a/Makefile.am b/Makefile.am index 2798a7fa..f613c0f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -597,60 +597,63 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/upb.c \ php/ext/google/protobuf/protobuf.c \ php/src/phpdoc.dist.xml \ - php/src/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/CodedInputStream.php \ + php/src/Google/Protobuf/Internal/CodedOutputStream.php \ php/src/Google/Protobuf/Internal/DescriptorPool.php \ - php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ - php/src/Google/Protobuf/Internal/OneofField.php \ - php/src/Google/Protobuf/Internal/MessageOptions.php \ - php/src/Google/Protobuf/Internal/FileDescriptor.php \ - php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ - php/src/Google/Protobuf/Internal/MapEntry.php \ - php/src/Google/Protobuf/Internal/FieldDescriptor.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ - php/src/Google/Protobuf/Internal/InputStream.php \ - php/src/Google/Protobuf/Internal/UninterpretedOption.php \ - php/src/Google/Protobuf/Internal/ServiceOptions.php \ - php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ - php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ - php/src/Google/Protobuf/Internal/OneofDescriptor.php \ - php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ - php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ - php/src/Google/Protobuf/Internal/OutputStream.php \ - php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ - php/src/Google/Protobuf/Internal/EnumValueDescriptor.php \ - php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ - php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ - php/src/Google/Protobuf/Internal/DescriptorProto.php \ - php/src/Google/Protobuf/Internal/MapField.php \ - php/src/Google/Protobuf/Internal/MapFieldIter.php \ - php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \ php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \ - php/src/Google/Protobuf/Internal/RepeatedField.php \ - php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ - php/src/Google/Protobuf/Internal/EnumValueOptions.php \ - php/src/Google/Protobuf/Internal/MethodOptions.php \ - php/src/Google/Protobuf/Internal/OneofOptions.php \ - php/src/Google/Protobuf/Internal/Message.php \ - php/src/Google/Protobuf/Internal/FileOptions.php \ - php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/DescriptorProto.php \ + php/src/Google/Protobuf/Internal/Descriptor.php \ + php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ php/src/Google/Protobuf/Internal/EnumDescriptor.php \ php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \ - php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/EnumOptions.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptor.php \ + php/src/Google/Protobuf/Internal/EnumValueOptions.php \ php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FieldDescriptor.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ + php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ php/src/Google/Protobuf/Internal/FieldOptions.php \ + php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/FileDescriptor.php \ + php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ + php/src/Google/Protobuf/Internal/FileOptions.php \ php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ - php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ + php/src/Google/Protobuf/Internal/GPBDecodeException.php \ + php/src/Google/Protobuf/Internal/GPBJsonWire.php \ + php/src/Google/Protobuf/Internal/GPBLabel.php \ php/src/Google/Protobuf/Internal/GPBType.php \ - php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ + php/src/Google/Protobuf/Internal/GPBUtil.php \ + php/src/Google/Protobuf/Internal/GPBWireType.php \ + php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/MapEntry.php \ + php/src/Google/Protobuf/Internal/MapFieldIter.php \ + php/src/Google/Protobuf/Internal/MapField.php \ + php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ + php/src/Google/Protobuf/Internal/MessageOptions.php \ + php/src/Google/Protobuf/Internal/Message.php \ + php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ + php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ + php/src/Google/Protobuf/Internal/MethodOptions.php \ + php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ + php/src/Google/Protobuf/Internal/OneofDescriptor.php \ + php/src/Google/Protobuf/Internal/OneofField.php \ + php/src/Google/Protobuf/Internal/OneofOptions.php \ + php/src/Google/Protobuf/Internal/RawInputStream.php \ + php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \ + php/src/Google/Protobuf/Internal/RepeatedField.php \ + php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ + php/src/Google/Protobuf/Internal/ServiceOptions.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ - php/src/Google/Protobuf/Internal/EnumOptions.php \ - php/src/Google/Protobuf/Internal/GPBLabel.php \ - php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ - php/src/Google/Protobuf/Internal/GPBUtil.php \ - php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ - php/src/Google/Protobuf/Internal/GPBDecodeException.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption.php \ php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ php/tests/array_test.php \ php/tests/autoload.php \ @@ -673,10 +676,11 @@ php_EXTRA_DIST= \ php/tests/test_base.php \ php/tests/test_util.php \ php/tests/well_known_test.php \ + php/tests/undefined_test.php \ php/README.md \ - php/phpunit.xml \ php/composer.json \ php/generate_descriptor_protos.sh \ + php/phpunit.xml \ composer.json python_EXTRA_DIST= \ diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 1a8b5748..fe604374 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -305,7 +305,7 @@ conformance-csharp: $(other_language_protoc_outputs) conformance-php: @echo "Writing shortcut script conformance-php..." @echo '#! /bin/sh' > conformance-php - @echo 'php ./conformance_php.php' >> conformance-php + @echo 'php -d auto_prepend_file=autoload.php ./conformance_php.php' >> conformance-php @chmod +x conformance-php conformance-php-c: @@ -336,6 +336,9 @@ test_php: protoc_middleman conformance-test-runner conformance-php $(other_langu test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c +test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt ./conformance-php-c + # These depend on library paths being properly set up. The easiest way to # run them is to just use "tox" from the python dir. test_python: protoc_middleman conformance-test-runner diff --git a/conformance/autoload.php b/conformance/autoload.php new file mode 100644 index 00000000..2cee31c4 --- /dev/null +++ b/conformance/autoload.php @@ -0,0 +1,21 @@ +getPayload() == "json_payload") { try { - $test_message->jsonDecode($request->getJsonPayload()); + $test_message->mergeFromJsonString($request->getJsonPayload()); } catch (Exception $e) { $response->setParseError($e->getMessage()); return $response; @@ -67,7 +67,7 @@ function doTest($request) } elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) { $response->setProtobufPayload($test_message->serializeToString()); } elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) { - $response->setJsonPayload($test_message->jsonEncode()); + $response->setJsonPayload($test_message->serializeToJsonString()); } return $response; @@ -79,7 +79,8 @@ function doTestIO() if (strlen($length_bytes) == 0) { return false; # EOF } elseif (strlen($length_bytes) != 4) { - trigger_error("I/O error", E_USER_ERROR); + fwrite(STDERR, "I/O error\n"); + return false; } $length = unpack("V", $length_bytes)[1]; diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt index 6dd93918..2bf9bb12 100644 --- a/conformance/failure_list_php.txt +++ b/conformance/failure_list_php.txt @@ -1,117 +1,17 @@ Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput -Recommended.JsonInput.BoolFieldAllCapitalFalse -Recommended.JsonInput.BoolFieldAllCapitalTrue -Recommended.JsonInput.BoolFieldCamelCaseFalse -Recommended.JsonInput.BoolFieldCamelCaseTrue -Recommended.JsonInput.BoolFieldDoubleQuotedFalse -Recommended.JsonInput.BoolFieldDoubleQuotedTrue -Recommended.JsonInput.BoolFieldIntegerOne -Recommended.JsonInput.BoolFieldIntegerZero -Recommended.JsonInput.BoolMapFieldKeyNotQuoted -Recommended.JsonInput.DoubleFieldInfinityNotQuoted -Recommended.JsonInput.DoubleFieldNanNotQuoted -Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.JsonInput.DurationHas3FractionalDigits.Validator Recommended.JsonInput.DurationHas6FractionalDigits.Validator Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator -Recommended.JsonInput.FieldMaskInvalidCharacter -Recommended.JsonInput.FieldNameDuplicate -Recommended.JsonInput.FieldNameDuplicateDifferentCasing1 -Recommended.JsonInput.FieldNameDuplicateDifferentCasing2 -Recommended.JsonInput.FieldNameNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator -Recommended.JsonInput.FloatFieldInfinityNotQuoted -Recommended.JsonInput.FloatFieldNanNotQuoted -Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted -Recommended.JsonInput.Int32MapFieldKeyNotQuoted -Recommended.JsonInput.Int64FieldBeString.Validator -Recommended.JsonInput.Int64MapFieldKeyNotQuoted -Recommended.JsonInput.JsonWithComments -Recommended.JsonInput.MapFieldKeyIsNull -Recommended.JsonInput.MapFieldValueIsNull -Recommended.JsonInput.MissingCommaMultiline -Recommended.JsonInput.MissingCommaOneLine -Recommended.JsonInput.MultilineNoSpaces.JsonOutput -Recommended.JsonInput.MultilineNoSpaces.ProtobufOutput -Recommended.JsonInput.MultilineWithSpaces.JsonOutput -Recommended.JsonInput.MultilineWithSpaces.ProtobufOutput -Recommended.JsonInput.OneLineNoSpaces.JsonOutput -Recommended.JsonInput.OneLineNoSpaces.ProtobufOutput -Recommended.JsonInput.OneLineWithSpaces.JsonOutput -Recommended.JsonInput.OneLineWithSpaces.ProtobufOutput -Recommended.JsonInput.OneofZeroBool.JsonOutput -Recommended.JsonInput.OneofZeroBool.ProtobufOutput -Recommended.JsonInput.OneofZeroBytes.JsonOutput -Recommended.JsonInput.OneofZeroBytes.ProtobufOutput -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroEnum.JsonOutput -Recommended.JsonInput.OneofZeroEnum.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput -Recommended.JsonInput.OneofZeroMessage.JsonOutput -Recommended.JsonInput.OneofZeroMessage.ProtobufOutput -Recommended.JsonInput.OneofZeroString.JsonOutput -Recommended.JsonInput.OneofZeroString.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput -Recommended.JsonInput.RepeatedFieldMessageElementIsNull -Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull -Recommended.JsonInput.RepeatedFieldTrailingComma -Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines -Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace -Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace -Recommended.JsonInput.StringEndsWithEscapeChar -Recommended.JsonInput.StringFieldInvalidEscape -Recommended.JsonInput.StringFieldSingleQuoteBoth -Recommended.JsonInput.StringFieldSingleQuoteKey -Recommended.JsonInput.StringFieldSingleQuoteValue -Recommended.JsonInput.StringFieldSurrogateInWrongOrder -Recommended.JsonInput.StringFieldUnpairedHighSurrogate -Recommended.JsonInput.StringFieldUnpairedLowSurrogate -Recommended.JsonInput.StringFieldUnterminatedEscape -Recommended.JsonInput.StringFieldUppercaseEscapeLetter Recommended.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.JsonInput.TimestampHas6FractionalDigits.Validator Recommended.JsonInput.TimestampHas9FractionalDigits.Validator Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator Recommended.JsonInput.TimestampZeroNormalized.Validator -Recommended.JsonInput.TrailingCommaInAnObject -Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines -Recommended.JsonInput.TrailingCommaInAnObjectWithSpace -Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace -Recommended.JsonInput.Uint32MapFieldKeyNotQuoted -Recommended.JsonInput.Uint64FieldBeString.Validator -Recommended.JsonInput.Uint64MapFieldKeyNotQuoted -Recommended.ProtobufInput.OneofZeroBool.JsonOutput -Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput -Recommended.ProtobufInput.OneofZeroBytes.JsonOutput -Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput -Recommended.ProtobufInput.OneofZeroDouble.JsonOutput -Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput -Recommended.ProtobufInput.OneofZeroEnum.JsonOutput -Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput -Recommended.ProtobufInput.OneofZeroFloat.JsonOutput -Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput -Recommended.ProtobufInput.OneofZeroMessage.JsonOutput -Recommended.ProtobufInput.OneofZeroMessage.ProtobufOutput -Recommended.ProtobufInput.OneofZeroString.JsonOutput -Recommended.ProtobufInput.OneofZeroString.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint32.JsonOutput -Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint64.JsonOutput -Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput -Required.JsonInput.AllFieldAcceptNull.JsonOutput -Required.JsonInput.AllFieldAcceptNull.ProtobufOutput Required.JsonInput.Any.JsonOutput Required.JsonInput.Any.ProtobufOutput Required.JsonInput.AnyNested.JsonOutput @@ -132,141 +32,14 @@ Required.JsonInput.AnyWithValueForInteger.JsonOutput Required.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.JsonInput.AnyWithValueForJsonObject.JsonOutput Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.BoolFieldFalse.JsonOutput -Required.JsonInput.BoolFieldFalse.ProtobufOutput -Required.JsonInput.BoolFieldTrue.JsonOutput -Required.JsonInput.BoolFieldTrue.ProtobufOutput -Required.JsonInput.BoolMapEscapedKey.JsonOutput -Required.JsonInput.BoolMapEscapedKey.ProtobufOutput -Required.JsonInput.BoolMapField.JsonOutput -Required.JsonInput.BoolMapField.ProtobufOutput -Required.JsonInput.BytesField.JsonOutput -Required.JsonInput.BytesField.ProtobufOutput -Required.JsonInput.BytesFieldInvalidBase64Characters -Required.JsonInput.BytesRepeatedField.JsonOutput -Required.JsonInput.BytesRepeatedField.ProtobufOutput -Required.JsonInput.DoubleFieldInfinity.JsonOutput -Required.JsonInput.DoubleFieldInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldNan.JsonOutput -Required.JsonInput.DoubleFieldNan.ProtobufOutput -Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput -Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldQuotedValue.JsonOutput -Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput -Required.JsonInput.DoubleFieldTooLarge -Required.JsonInput.DoubleFieldTooSmall -Required.JsonInput.DurationJsonInputTooLarge -Required.JsonInput.DurationJsonInputTooSmall Required.JsonInput.DurationMaxValue.JsonOutput Required.JsonInput.DurationMaxValue.ProtobufOutput Required.JsonInput.DurationMinValue.JsonOutput Required.JsonInput.DurationMinValue.ProtobufOutput -Required.JsonInput.DurationMissingS Required.JsonInput.DurationRepeatedValue.JsonOutput Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumField.JsonOutput -Required.JsonInput.EnumField.ProtobufOutput -Required.JsonInput.EnumFieldNotQuoted -Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput -Required.JsonInput.EnumFieldUnknownValue.Validator -Required.JsonInput.EnumRepeatedField.JsonOutput -Required.JsonInput.EnumRepeatedField.ProtobufOutput Required.JsonInput.FieldMask.JsonOutput Required.JsonInput.FieldMask.ProtobufOutput -Required.JsonInput.FieldNameEscaped.JsonOutput -Required.JsonInput.FieldNameEscaped.ProtobufOutput -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput -Required.JsonInput.FieldNameWithMixedCases.JsonOutput -Required.JsonInput.FieldNameWithMixedCases.ProtobufOutput -Required.JsonInput.FieldNameWithMixedCases.Validator -Required.JsonInput.FieldNameWithNumbers.JsonOutput -Required.JsonInput.FieldNameWithNumbers.ProtobufOutput -Required.JsonInput.FieldNameWithNumbers.Validator -Required.JsonInput.FloatFieldInfinity.JsonOutput -Required.JsonInput.FloatFieldInfinity.ProtobufOutput -Required.JsonInput.FloatFieldMaxNegativeValue.JsonOutput -Required.JsonInput.FloatFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.FloatFieldMaxPositiveValue.JsonOutput -Required.JsonInput.FloatFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.FloatFieldMinNegativeValue.JsonOutput -Required.JsonInput.FloatFieldMinNegativeValue.ProtobufOutput -Required.JsonInput.FloatFieldMinPositiveValue.JsonOutput -Required.JsonInput.FloatFieldMinPositiveValue.ProtobufOutput -Required.JsonInput.FloatFieldNan.JsonOutput -Required.JsonInput.FloatFieldNan.ProtobufOutput -Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput -Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.FloatFieldQuotedValue.JsonOutput -Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput -Required.JsonInput.FloatFieldTooLarge -Required.JsonInput.FloatFieldTooSmall -Required.JsonInput.HelloWorld.JsonOutput -Required.JsonInput.HelloWorld.ProtobufOutput -Required.JsonInput.Int32FieldExponentialFormat.JsonOutput -Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput -Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput -Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -Required.JsonInput.Int32FieldLeadingSpace -Required.JsonInput.Int32FieldLeadingZero -Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMaxValue.JsonOutput -Required.JsonInput.Int32FieldMaxValue.ProtobufOutput -Required.JsonInput.Int32FieldMinFloatValue.JsonOutput -Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMinValue.JsonOutput -Required.JsonInput.Int32FieldMinValue.ProtobufOutput -Required.JsonInput.Int32FieldNegativeWithLeadingZero -Required.JsonInput.Int32FieldNotInteger -Required.JsonInput.Int32FieldNotNumber -Required.JsonInput.Int32FieldPlusSign -Required.JsonInput.Int32FieldStringValue.JsonOutput -Required.JsonInput.Int32FieldStringValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput -Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput -Required.JsonInput.Int32FieldTooLarge -Required.JsonInput.Int32FieldTooSmall -Required.JsonInput.Int32FieldTrailingSpace -Required.JsonInput.Int32MapEscapedKey.JsonOutput -Required.JsonInput.Int32MapEscapedKey.ProtobufOutput -Required.JsonInput.Int32MapField.JsonOutput -Required.JsonInput.Int32MapField.ProtobufOutput -Required.JsonInput.Int64FieldMaxValue.JsonOutput -Required.JsonInput.Int64FieldMaxValue.ProtobufOutput -Required.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput -Required.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput -Required.JsonInput.Int64FieldMinValue.JsonOutput -Required.JsonInput.Int64FieldMinValue.ProtobufOutput -Required.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput -Required.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput -Required.JsonInput.Int64FieldNotInteger -Required.JsonInput.Int64FieldNotNumber -Required.JsonInput.Int64FieldTooLarge -Required.JsonInput.Int64FieldTooSmall -Required.JsonInput.Int64MapEscapedKey.JsonOutput -Required.JsonInput.Int64MapEscapedKey.ProtobufOutput -Required.JsonInput.Int64MapField.JsonOutput -Required.JsonInput.Int64MapField.ProtobufOutput -Required.JsonInput.MessageField.JsonOutput -Required.JsonInput.MessageField.ProtobufOutput -Required.JsonInput.MessageMapField.JsonOutput -Required.JsonInput.MessageMapField.ProtobufOutput -Required.JsonInput.MessageRepeatedField.JsonOutput -Required.JsonInput.MessageRepeatedField.ProtobufOutput -Required.JsonInput.OneofFieldDuplicate Required.JsonInput.OptionalBoolWrapper.JsonOutput Required.JsonInput.OptionalBoolWrapper.ProtobufOutput Required.JsonInput.OptionalBytesWrapper.JsonOutput @@ -287,25 +60,12 @@ Required.JsonInput.OptionalUint64Wrapper.JsonOutput Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput -Required.JsonInput.OriginalProtoFieldName.JsonOutput -Required.JsonInput.OriginalProtoFieldName.ProtobufOutput -Required.JsonInput.PrimitiveRepeatedField.JsonOutput -Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput Required.JsonInput.RepeatedBoolWrapper.JsonOutput Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput Required.JsonInput.RepeatedBytesWrapper.JsonOutput Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput Required.JsonInput.RepeatedDoubleWrapper.JsonOutput Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage Required.JsonInput.RepeatedFloatWrapper.JsonOutput Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput Required.JsonInput.RepeatedInt32Wrapper.JsonOutput @@ -318,29 +78,8 @@ Required.JsonInput.RepeatedUint32Wrapper.JsonOutput Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput Required.JsonInput.RepeatedUint64Wrapper.JsonOutput Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput -Required.JsonInput.StringField.JsonOutput -Required.JsonInput.StringField.ProtobufOutput -Required.JsonInput.StringFieldEscape.JsonOutput -Required.JsonInput.StringFieldEscape.ProtobufOutput -Required.JsonInput.StringFieldNotAString -Required.JsonInput.StringFieldSurrogatePair.JsonOutput -Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput -Required.JsonInput.StringFieldUnicode.JsonOutput -Required.JsonInput.StringFieldUnicode.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscape.JsonOutput -Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput -Required.JsonInput.StringRepeatedField.JsonOutput -Required.JsonInput.StringRepeatedField.ProtobufOutput Required.JsonInput.Struct.JsonOutput Required.JsonInput.Struct.ProtobufOutput -Required.JsonInput.TimestampJsonInputLowercaseT -Required.JsonInput.TimestampJsonInputLowercaseZ -Required.JsonInput.TimestampJsonInputMissingT -Required.JsonInput.TimestampJsonInputMissingZ -Required.JsonInput.TimestampJsonInputTooLarge -Required.JsonInput.TimestampJsonInputTooSmall Required.JsonInput.TimestampMaxValue.JsonOutput Required.JsonInput.TimestampMaxValue.ProtobufOutput Required.JsonInput.TimestampMinValue.JsonOutput @@ -351,24 +90,6 @@ Required.JsonInput.TimestampWithNegativeOffset.JsonOutput Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput Required.JsonInput.TimestampWithPositiveOffset.JsonOutput Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput -Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Uint32FieldMaxValue.JsonOutput -Required.JsonInput.Uint32FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint32FieldNotInteger -Required.JsonInput.Uint32FieldNotNumber -Required.JsonInput.Uint32FieldTooLarge -Required.JsonInput.Uint32MapField.JsonOutput -Required.JsonInput.Uint32MapField.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValue.JsonOutput -Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput -Required.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput -Required.JsonInput.Uint64FieldNotInteger -Required.JsonInput.Uint64FieldNotNumber -Required.JsonInput.Uint64FieldTooLarge -Required.JsonInput.Uint64MapField.JsonOutput -Required.JsonInput.Uint64MapField.ProtobufOutput Required.JsonInput.ValueAcceptBool.JsonOutput Required.JsonInput.ValueAcceptBool.ProtobufOutput Required.JsonInput.ValueAcceptFloat.JsonOutput @@ -383,229 +104,15 @@ Required.JsonInput.ValueAcceptObject.JsonOutput Required.JsonInput.ValueAcceptObject.ProtobufOutput Required.JsonInput.ValueAcceptString.JsonOutput Required.JsonInput.ValueAcceptString.ProtobufOutput -Required.JsonInput.WrapperTypesWithNullValue.JsonOutput -Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput -Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeKnownNonRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.BOOL -Required.ProtobufInput.PrematureEofBeforeUnknownValue.BYTES -Required.ProtobufInput.PrematureEofBeforeUnknownValue.DOUBLE -Required.ProtobufInput.PrematureEofBeforeUnknownValue.ENUM -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FIXED64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.FLOAT -Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.INT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SFIXED64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.SINT64 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.STRING -Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT32 -Required.ProtobufInput.PrematureEofBeforeUnknownValue.UINT64 -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.BYTES -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofInDelimitedDataForUnknownValue.STRING -Required.ProtobufInput.PrematureEofInPackedField.BOOL -Required.ProtobufInput.PrematureEofInPackedField.DOUBLE -Required.ProtobufInput.PrematureEofInPackedField.ENUM -Required.ProtobufInput.PrematureEofInPackedField.FIXED32 -Required.ProtobufInput.PrematureEofInPackedField.FIXED64 -Required.ProtobufInput.PrematureEofInPackedField.FLOAT -Required.ProtobufInput.PrematureEofInPackedField.INT32 -Required.ProtobufInput.PrematureEofInPackedField.INT64 -Required.ProtobufInput.PrematureEofInPackedField.SFIXED32 -Required.ProtobufInput.PrematureEofInPackedField.SFIXED64 -Required.ProtobufInput.PrematureEofInPackedField.SINT32 -Required.ProtobufInput.PrematureEofInPackedField.SINT64 -Required.ProtobufInput.PrematureEofInPackedField.UINT32 -Required.ProtobufInput.PrematureEofInPackedField.UINT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.BOOL -Required.ProtobufInput.PrematureEofInPackedFieldValue.DOUBLE -Required.ProtobufInput.PrematureEofInPackedFieldValue.ENUM -Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.FIXED64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.FLOAT -Required.ProtobufInput.PrematureEofInPackedFieldValue.INT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.INT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SFIXED64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.SINT64 -Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT32 -Required.ProtobufInput.PrematureEofInPackedFieldValue.UINT64 -Required.ProtobufInput.PrematureEofInSubmessageValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofInsideKnownNonRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BOOL -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.BYTES -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.ENUM -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.FLOAT -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.INT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.SINT64 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.STRING -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT32 -Required.ProtobufInput.PrematureEofInsideKnownRepeatedValue.UINT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.BOOL -Required.ProtobufInput.PrematureEofInsideUnknownValue.BYTES -Required.ProtobufInput.PrematureEofInsideUnknownValue.DOUBLE -Required.ProtobufInput.PrematureEofInsideUnknownValue.ENUM -Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.FIXED64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.FLOAT -Required.ProtobufInput.PrematureEofInsideUnknownValue.INT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.INT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.MESSAGE -Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SFIXED64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.SINT64 -Required.ProtobufInput.PrematureEofInsideUnknownValue.STRING -Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT32 -Required.ProtobufInput.PrematureEofInsideUnknownValue.UINT64 -Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.DOUBLE.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FLOAT.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.INT64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SFIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.SINT64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.BOOL.JsonOutput -Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.DOUBLE.JsonOutput -Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FIXED32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FIXED64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput -Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.INT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.INT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SINT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.SINT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.UINT32.JsonOutput -Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput -Required.ProtobufInput.ValidDataRepeated.UINT64.JsonOutput -Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.BOOL.JsonOutput -Required.ProtobufInput.ValidDataScalar.BOOL.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.DOUBLE.JsonOutput -Required.ProtobufInput.ValidDataScalar.DOUBLE.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FIXED32.JsonOutput -Required.ProtobufInput.ValidDataScalar.FIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FIXED64.JsonOutput -Required.ProtobufInput.ValidDataScalar.FIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.FLOAT.JsonOutput -Required.ProtobufInput.ValidDataScalar.FLOAT.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.INT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.INT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.INT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.INT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SFIXED32.JsonOutput -Required.ProtobufInput.ValidDataScalar.SFIXED32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SFIXED64.JsonOutput -Required.ProtobufInput.ValidDataScalar.SFIXED64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SINT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.SINT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.SINT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.SINT64.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.UINT32.JsonOutput -Required.ProtobufInput.ValidDataScalar.UINT32.ProtobufOutput -Required.ProtobufInput.ValidDataScalar.UINT64.JsonOutput -Required.ProtobufInput.ValidDataScalar.UINT64.ProtobufOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput +Required.JsonInput.FloatFieldTooLarge +Required.JsonInput.FloatFieldTooSmall +Required.JsonInput.DoubleFieldTooSmall +Required.JsonInput.Int32FieldNotInteger +Required.JsonInput.Int64FieldNotInteger +Required.JsonInput.Uint32FieldNotInteger +Required.JsonInput.Uint64FieldNotInteger +Required.JsonInput.Int32FieldLeadingSpace +Required.JsonInput.OneofFieldDuplicate +Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt index f53449f7..591997ef 100644 --- a/conformance/failure_list_php_c.txt +++ b/conformance/failure_list_php_c.txt @@ -9,22 +9,10 @@ Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator Recommended.JsonInput.Int64FieldBeString.Validator Recommended.JsonInput.MapFieldValueIsNull -Recommended.JsonInput.OneofZeroBool.JsonOutput -Recommended.JsonInput.OneofZeroBool.ProtobufOutput Recommended.JsonInput.OneofZeroBytes.JsonOutput Recommended.JsonInput.OneofZeroBytes.ProtobufOutput -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroEnum.JsonOutput -Recommended.JsonInput.OneofZeroEnum.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput Recommended.JsonInput.OneofZeroString.JsonOutput Recommended.JsonInput.OneofZeroString.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput Recommended.JsonInput.RepeatedFieldMessageElementIsNull Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull Recommended.JsonInput.StringEndsWithEscapeChar @@ -37,25 +25,12 @@ Recommended.JsonInput.TimestampHas9FractionalDigits.Validator Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator Recommended.JsonInput.TimestampZeroNormalized.Validator Recommended.JsonInput.Uint64FieldBeString.Validator -Recommended.ProtobufInput.OneofZeroBool.JsonOutput -Recommended.ProtobufInput.OneofZeroBool.ProtobufOutput Recommended.ProtobufInput.OneofZeroBytes.JsonOutput Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput -Recommended.ProtobufInput.OneofZeroDouble.JsonOutput -Recommended.ProtobufInput.OneofZeroDouble.ProtobufOutput -Recommended.ProtobufInput.OneofZeroEnum.JsonOutput -Recommended.ProtobufInput.OneofZeroEnum.ProtobufOutput -Recommended.ProtobufInput.OneofZeroFloat.JsonOutput -Recommended.ProtobufInput.OneofZeroFloat.ProtobufOutput Recommended.ProtobufInput.OneofZeroString.JsonOutput Recommended.ProtobufInput.OneofZeroString.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint32.JsonOutput -Recommended.ProtobufInput.OneofZeroUint32.ProtobufOutput -Recommended.ProtobufInput.OneofZeroUint64.JsonOutput -Recommended.ProtobufInput.OneofZeroUint64.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput -Required.JsonInput.AllFieldAcceptNull.ProtobufOutput Required.JsonInput.Any.JsonOutput Required.JsonInput.Any.ProtobufOutput Required.JsonInput.AnyNested.JsonOutput @@ -76,7 +51,6 @@ Required.JsonInput.AnyWithValueForInteger.JsonOutput Required.JsonInput.AnyWithValueForInteger.ProtobufOutput Required.JsonInput.AnyWithValueForJsonObject.JsonOutput Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.BoolFieldFalse.ProtobufOutput Required.JsonInput.BoolMapField.JsonOutput Required.JsonInput.DoubleFieldInfinity.JsonOutput Required.JsonInput.DoubleFieldInfinity.ProtobufOutput @@ -100,7 +74,6 @@ Required.JsonInput.DurationMinValue.JsonOutput Required.JsonInput.DurationMinValue.ProtobufOutput Required.JsonInput.DurationRepeatedValue.JsonOutput Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumField.ProtobufOutput Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput Required.JsonInput.EnumFieldNumericValueZero.JsonOutput @@ -215,13 +188,10 @@ Required.JsonInput.ValueAcceptObject.JsonOutput Required.JsonInput.ValueAcceptObject.ProtobufOutput Required.JsonInput.ValueAcceptString.JsonOutput Required.JsonInput.ValueAcceptString.ProtobufOutput -Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput +Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/conformance/failure_list_php_zts_c.txt b/conformance/failure_list_php_zts_c.txt new file mode 100644 index 00000000..d9a8fe36 --- /dev/null +++ b/conformance/failure_list_php_zts_c.txt @@ -0,0 +1,225 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.JsonInput.BoolFieldIntegerOne +Recommended.JsonInput.BoolFieldIntegerZero +Recommended.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.JsonInput.DurationHas9FractionalDigits.Validator +Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator +Recommended.JsonInput.Int64FieldBeString.Validator +Recommended.JsonInput.OneofZeroBytes.JsonOutput +Recommended.JsonInput.OneofZeroBytes.ProtobufOutput +Recommended.JsonInput.OneofZeroDouble.JsonOutput +Recommended.JsonInput.OneofZeroDouble.ProtobufOutput +Recommended.JsonInput.OneofZeroFloat.JsonOutput +Recommended.JsonInput.OneofZeroFloat.ProtobufOutput +Recommended.JsonInput.OneofZeroString.JsonOutput +Recommended.JsonInput.OneofZeroString.ProtobufOutput +Recommended.JsonInput.OneofZeroUint32.JsonOutput +Recommended.JsonInput.OneofZeroUint32.ProtobufOutput +Recommended.JsonInput.OneofZeroUint64.JsonOutput +Recommended.JsonInput.OneofZeroUint64.ProtobufOutput +Recommended.JsonInput.StringEndsWithEscapeChar +Recommended.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.JsonInput.TimestampHas9FractionalDigits.Validator +Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator +Recommended.JsonInput.TimestampZeroNormalized.Validator +Recommended.JsonInput.Uint64FieldBeString.Validator +Recommended.ProtobufInput.OneofZeroBytes.JsonOutput +Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput +Recommended.ProtobufInput.OneofZeroString.JsonOutput +Recommended.ProtobufInput.OneofZeroString.ProtobufOutput +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.JsonInput.AllFieldAcceptNull.ProtobufOutput +Required.JsonInput.Any.JsonOutput +Required.JsonInput.Any.ProtobufOutput +Required.JsonInput.AnyNested.JsonOutput +Required.JsonInput.AnyNested.ProtobufOutput +Required.JsonInput.AnyUnorderedTypeTag.JsonOutput +Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput +Required.JsonInput.AnyWithDuration.JsonOutput +Required.JsonInput.AnyWithDuration.ProtobufOutput +Required.JsonInput.AnyWithFieldMask.JsonOutput +Required.JsonInput.AnyWithFieldMask.ProtobufOutput +Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput +Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput +Required.JsonInput.AnyWithStruct.JsonOutput +Required.JsonInput.AnyWithStruct.ProtobufOutput +Required.JsonInput.AnyWithTimestamp.JsonOutput +Required.JsonInput.AnyWithTimestamp.ProtobufOutput +Required.JsonInput.AnyWithValueForInteger.JsonOutput +Required.JsonInput.AnyWithValueForInteger.ProtobufOutput +Required.JsonInput.AnyWithValueForJsonObject.JsonOutput +Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput +Required.JsonInput.BoolFieldFalse.ProtobufOutput +Required.JsonInput.BoolMapField.JsonOutput +Required.JsonInput.DoubleFieldInfinity.JsonOutput +Required.JsonInput.DoubleFieldInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput +Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput +Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.JsonInput.DoubleFieldNan.JsonOutput +Required.JsonInput.DoubleFieldNan.ProtobufOutput +Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput +Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.DoubleFieldQuotedValue.JsonOutput +Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput +Required.JsonInput.DurationMaxValue.JsonOutput +Required.JsonInput.DurationMaxValue.ProtobufOutput +Required.JsonInput.DurationMinValue.JsonOutput +Required.JsonInput.DurationMinValue.ProtobufOutput +Required.JsonInput.DurationRepeatedValue.JsonOutput +Required.JsonInput.DurationRepeatedValue.ProtobufOutput +Required.JsonInput.EnumField.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput +Required.JsonInput.EnumFieldNumericValueZero.JsonOutput +Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput +Required.JsonInput.EnumFieldUnknownValue.Validator +Required.JsonInput.FieldMask.JsonOutput +Required.JsonInput.FieldMask.ProtobufOutput +Required.JsonInput.FloatFieldInfinity.JsonOutput +Required.JsonInput.FloatFieldInfinity.ProtobufOutput +Required.JsonInput.FloatFieldNan.JsonOutput +Required.JsonInput.FloatFieldNan.ProtobufOutput +Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput +Required.JsonInput.FloatFieldQuotedValue.JsonOutput +Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput +Required.JsonInput.FloatFieldTooLarge +Required.JsonInput.FloatFieldTooSmall +Required.JsonInput.Int32FieldExponentialFormat.JsonOutput +Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput +Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput +Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput +Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldMinFloatValue.JsonOutput +Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValue.JsonOutput +Required.JsonInput.Int32FieldStringValue.ProtobufOutput +Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput +Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput +Required.JsonInput.Int32MapEscapedKey.JsonOutput +Required.JsonInput.Int32MapEscapedKey.ProtobufOutput +Required.JsonInput.Int32MapField.JsonOutput +Required.JsonInput.Int32MapField.ProtobufOutput +Required.JsonInput.Int64FieldMaxValue.JsonOutput +Required.JsonInput.Int64FieldMaxValue.ProtobufOutput +Required.JsonInput.Int64FieldMinValue.JsonOutput +Required.JsonInput.Int64FieldMinValue.ProtobufOutput +Required.JsonInput.Int64MapEscapedKey.JsonOutput +Required.JsonInput.Int64MapEscapedKey.ProtobufOutput +Required.JsonInput.Int64MapField.JsonOutput +Required.JsonInput.Int64MapField.ProtobufOutput +Required.JsonInput.MessageField.JsonOutput +Required.JsonInput.MessageField.ProtobufOutput +Required.JsonInput.MessageMapField.JsonOutput +Required.JsonInput.MessageMapField.ProtobufOutput +Required.JsonInput.MessageRepeatedField.JsonOutput +Required.JsonInput.MessageRepeatedField.ProtobufOutput +Required.JsonInput.OptionalBoolWrapper.JsonOutput +Required.JsonInput.OptionalBoolWrapper.ProtobufOutput +Required.JsonInput.OptionalBytesWrapper.JsonOutput +Required.JsonInput.OptionalBytesWrapper.ProtobufOutput +Required.JsonInput.OptionalDoubleWrapper.JsonOutput +Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput +Required.JsonInput.OptionalFloatWrapper.JsonOutput +Required.JsonInput.OptionalFloatWrapper.ProtobufOutput +Required.JsonInput.OptionalInt32Wrapper.JsonOutput +Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput +Required.JsonInput.OptionalInt64Wrapper.JsonOutput +Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput +Required.JsonInput.OptionalStringWrapper.JsonOutput +Required.JsonInput.OptionalStringWrapper.ProtobufOutput +Required.JsonInput.OptionalUint32Wrapper.JsonOutput +Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput +Required.JsonInput.OptionalUint64Wrapper.JsonOutput +Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput +Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.JsonInput.PrimitiveRepeatedField.JsonOutput +Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput +Required.JsonInput.RepeatedBoolWrapper.JsonOutput +Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput +Required.JsonInput.RepeatedBytesWrapper.JsonOutput +Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput +Required.JsonInput.RepeatedDoubleWrapper.JsonOutput +Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput +Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt +Required.JsonInput.RepeatedFloatWrapper.JsonOutput +Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput +Required.JsonInput.RepeatedInt32Wrapper.JsonOutput +Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedInt64Wrapper.JsonOutput +Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput +Required.JsonInput.RepeatedStringWrapper.JsonOutput +Required.JsonInput.RepeatedStringWrapper.ProtobufOutput +Required.JsonInput.RepeatedUint32Wrapper.JsonOutput +Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput +Required.JsonInput.RepeatedUint64Wrapper.JsonOutput +Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput +Required.JsonInput.StringFieldEscape.JsonOutput +Required.JsonInput.StringFieldEscape.ProtobufOutput +Required.JsonInput.StringFieldNotAString +Required.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscape.JsonOutput +Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput +Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput +Required.JsonInput.Struct.JsonOutput +Required.JsonInput.Struct.ProtobufOutput +Required.JsonInput.TimestampMaxValue.JsonOutput +Required.JsonInput.TimestampMaxValue.ProtobufOutput +Required.JsonInput.TimestampMinValue.JsonOutput +Required.JsonInput.TimestampMinValue.ProtobufOutput +Required.JsonInput.TimestampRepeatedValue.JsonOutput +Required.JsonInput.TimestampRepeatedValue.ProtobufOutput +Required.JsonInput.TimestampWithNegativeOffset.JsonOutput +Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput +Required.JsonInput.TimestampWithPositiveOffset.JsonOutput +Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput +Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput +Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput +Required.JsonInput.Uint32MapField.JsonOutput +Required.JsonInput.Uint32MapField.ProtobufOutput +Required.JsonInput.Uint64FieldMaxValue.JsonOutput +Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput +Required.JsonInput.Uint64MapField.JsonOutput +Required.JsonInput.Uint64MapField.ProtobufOutput +Required.JsonInput.ValueAcceptBool.JsonOutput +Required.JsonInput.ValueAcceptBool.ProtobufOutput +Required.JsonInput.ValueAcceptFloat.JsonOutput +Required.JsonInput.ValueAcceptFloat.ProtobufOutput +Required.JsonInput.ValueAcceptInteger.JsonOutput +Required.JsonInput.ValueAcceptInteger.ProtobufOutput +Required.JsonInput.ValueAcceptList.JsonOutput +Required.JsonInput.ValueAcceptList.ProtobufOutput +Required.JsonInput.ValueAcceptNull.JsonOutput +Required.JsonInput.ValueAcceptNull.ProtobufOutput +Required.JsonInput.ValueAcceptObject.JsonOutput +Required.JsonInput.ValueAcceptObject.ProtobufOutput +Required.JsonInput.ValueAcceptString.JsonOutput +Required.JsonInput.ValueAcceptString.ProtobufOutput +Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput +Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput +Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 6e3c606b..b07abfa7 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -164,18 +164,21 @@ typedef struct { int property_ofs; // properties table cache uint32_t oneof_case_num; // oneof-case number to place in oneof_case field const upb_msgdef *md; // msgdef, for oneof submessage handler + const upb_msgdef *parent_md; // msgdef, for parent submessage } oneof_handlerdata_t; static const void *newoneofhandlerdata(upb_handlers *h, uint32_t ofs, uint32_t case_ofs, int property_ofs, + const upb_msgdef *m, const upb_fielddef *f) { oneof_handlerdata_t* hd = (oneof_handlerdata_t*)malloc(sizeof(oneof_handlerdata_t)); hd->ofs = ofs; hd->case_ofs = case_ofs; hd->property_ofs = property_ofs; + hd->parent_md = m; // We reuse the field tag number as a oneof union discriminant tag. Note that // we don't expose these numbers to the user, so the only requirement is that // we have some unique ID for each union case/possibility. The field tag @@ -284,10 +287,19 @@ DEFINE_SINGULAR_HANDLER(double, double) #if PHP_MAJOR_VERSION < 7 static void *empty_php_string(zval** value_ptr) { SEPARATE_ZVAL_IF_NOT_REF(value_ptr); + if (Z_TYPE_PP(value_ptr) == IS_STRING && + !IS_INTERNED(Z_STRVAL_PP(value_ptr))) { + FREE(Z_STRVAL_PP(value_ptr)); + } + ZVAL_EMPTY_STRING(*value_ptr); return (void*)(*value_ptr); } #else static void *empty_php_string(zval* value_ptr) { + if (Z_TYPE_P(value_ptr) == IS_STRING) { + zend_string_release(Z_STR_P(value_ptr)); + } + ZVAL_EMPTY_STRING(value_ptr); return value_ptr; } #endif @@ -462,7 +474,7 @@ static void map_slot_init(void* memory, upb_fieldtype_t type, zval* cache) { *(zval***)memory = holder; #else *(zval**)memory = cache; - PHP_PROTO_ZVAL_STRINGL(*(zval**)memory, "", 0, 1); + // PHP_PROTO_ZVAL_STRINGL(*(zval**)memory, "", 0, 1); #endif break; } @@ -654,6 +666,44 @@ DEFINE_ONEOF_HANDLER(double, double) #undef DEFINE_ONEOF_HANDLER +static void oneof_cleanup(MessageHeader* msg, + const oneof_handlerdata_t* oneofdata) { + uint32_t old_case_num = + DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); + if (old_case_num == 0) { + return; + } + + const upb_fielddef* old_field = + upb_msgdef_itof(oneofdata->parent_md, old_case_num); + bool need_clean = false; + + switch (upb_fielddef_type(old_field)) { + case UPB_TYPE_STRING: + case UPB_TYPE_BYTES: + need_clean = true; + break; + case UPB_TYPE_MESSAGE: + if (oneofdata->oneof_case_num != old_case_num) { + need_clean = true; + } + break; + default: + break; + } + + if (need_clean) { +#if PHP_MAJOR_VERSION < 7 + SEPARATE_ZVAL_IF_NOT_REF( + DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + php_proto_zval_ptr_dtor( + *DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + MAKE_STD_ZVAL(*DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); + ZVAL_NULL(*DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)); +#endif + } +} + // Handlers for string/bytes in a oneof. static void *oneofbytes_handler(void *closure, const void *hd, @@ -661,6 +711,8 @@ static void *oneofbytes_handler(void *closure, MessageHeader* msg = closure; const oneof_handlerdata_t *oneofdata = hd; + oneof_cleanup(msg, oneofdata); + DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) = oneofdata->oneof_case_num; DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = @@ -691,22 +743,11 @@ static void* oneofsubmsg_handler(void* closure, const void* hd) { MessageHeader* submsg; if (oldcase != oneofdata->oneof_case_num) { - // Ideally, we should clean up the old data. However, we don't even know the - // type of the old data. So, we will defer the desctruction of the old data - // to the time that containing message's destroyed or the same oneof field - // is accessed again and find that the old data hasn't been cleaned. - DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = - &(msg->std.properties_table)[oneofdata->property_ofs]; - - // Old data was't cleaned when the oneof was accessed from another field. - if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(DEREF( - message_data(msg), oneofdata->ofs, CACHED_VALUE*))) != IS_NULL) { - php_proto_zval_ptr_dtor( - CACHED_PTR_TO_ZVAL_PTR( - DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*))); - } + oneof_cleanup(msg, oneofdata); // Create new message. + DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = + &(msg->std.properties_table)[oneofdata->property_ofs]; ZVAL_OBJ(CACHED_PTR_TO_ZVAL_PTR( DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*)), subklass->create_object(subklass TSRMLS_CC)); @@ -856,6 +897,7 @@ static void add_handlers_for_mapentry(const upb_msgdef* msgdef, upb_handlers* h, // Set up handlers for a oneof field. static void add_handlers_for_oneof_field(upb_handlers *h, + const upb_msgdef *m, const upb_fielddef *f, size_t offset, size_t oneof_case_offset, @@ -864,7 +906,7 @@ static void add_handlers_for_oneof_field(upb_handlers *h, upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; upb_handlerattr_sethandlerdata( &attr, newoneofhandlerdata(h, offset, oneof_case_offset, - property_cache_offset, f)); + property_cache_offset, m, f)); switch (upb_fielddef_type(f)) { @@ -936,8 +978,8 @@ static void add_handlers_for_message(const void* closure, desc->layout->fields[upb_fielddef_index(f)].case_offset; int property_cache_index = desc->layout->fields[upb_fielddef_index(f)].cache_index; - add_handlers_for_oneof_field(h, f, offset, oneof_case_offset, - property_cache_index); + add_handlers_for_oneof_field(h, desc->msgdef, f, offset, + oneof_case_offset, property_cache_index); } else if (is_map_field(f)) { add_handlers_for_mapfield(h, f, offset, desc); } else if (upb_fielddef_isseq(f)) { @@ -1198,7 +1240,7 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, } else if (upb_fielddef_isstring(f)) { zval* str = CACHED_PTR_TO_ZVAL_PTR( DEREF(message_data(msg), offset, CACHED_VALUE*)); - if (Z_STRLEN_P(str) > 0) { + if (containing_oneof || Z_STRLEN_P(str) > 0) { putstr(str, f, sink); } } else if (upb_fielddef_issubmsg(f)) { @@ -1221,10 +1263,10 @@ static void putrawmsg(MessageHeader* msg, const Descriptor* desc, T(UPB_TYPE_DOUBLE, double, double, 0.0) T(UPB_TYPE_BOOL, bool, uint8_t, 0) case UPB_TYPE_ENUM: - T(UPB_TYPE_INT32, int32, int32_t, 0) - T(UPB_TYPE_UINT32, uint32, uint32_t, 0) - T(UPB_TYPE_INT64, int64, int64_t, 0) - T(UPB_TYPE_UINT64, uint64, uint64_t, 0) + T(UPB_TYPE_INT32, int32, int32_t, 0) + T(UPB_TYPE_UINT32, uint32, uint32_t, 0) + T(UPB_TYPE_INT64, int64, int64_t, 0) + T(UPB_TYPE_UINT64, uint64, uint64_t, 0) case UPB_TYPE_STRING: case UPB_TYPE_BYTES: @@ -1246,18 +1288,23 @@ static void putstr(zval* str, const upb_fielddef *f, upb_sink *sink) { assert(Z_TYPE_P(str) == IS_STRING); - // Ensure that the string has the correct encoding. We also check at field-set - // time, but the user may have mutated the string object since then. - if (upb_fielddef_type(f) == UPB_TYPE_STRING && - !is_structurally_valid_utf8(Z_STRVAL_P(str), Z_STRLEN_P(str))) { - zend_error(E_USER_ERROR, "Given string is not UTF8 encoded."); - return; - } - upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), Z_STRLEN_P(str), &subsink); - upb_sink_putstring(&subsink, getsel(f, UPB_HANDLER_STRING), Z_STRVAL_P(str), - Z_STRLEN_P(str), NULL); + + // For oneof string field, we may get here with string length is zero. + if (Z_STRLEN_P(str) > 0) { + // Ensure that the string has the correct encoding. We also check at + // field-set time, but the user may have mutated the string object since + // then. + if (upb_fielddef_type(f) == UPB_TYPE_STRING && + !is_structurally_valid_utf8(Z_STRVAL_P(str), Z_STRLEN_P(str))) { + zend_error(E_USER_ERROR, "Given string is not UTF8 encoded."); + return; + } + upb_sink_putstring(&subsink, getsel(f, UPB_HANDLER_STRING), Z_STRVAL_P(str), + Z_STRLEN_P(str), NULL); + } + upb_sink_endstr(sink, getsel(f, UPB_HANDLER_ENDSTR)); } @@ -1452,7 +1499,7 @@ PHP_METHOD(Message, mergeFromString) { } } -PHP_METHOD(Message, jsonEncode) { +PHP_METHOD(Message, serializeToJsonString) { Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); @@ -1483,13 +1530,14 @@ PHP_METHOD(Message, jsonEncode) { } } -PHP_METHOD(Message, jsonDecode) { +PHP_METHOD(Message, mergeFromJsonString) { Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); MessageHeader* msg = UNBOX(MessageHeader, getThis()); char *data = NULL; - int data_len; + PHP_PROTO_SIZE data_len; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { return; diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 79a2739a..b8ef9fc0 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -40,8 +40,8 @@ static zend_function_entry message_methods[] = { PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, serializeToString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFromString, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Message, jsonEncode, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Message, jsonDecode, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Message, serializeToJsonString, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Message, mergeFromJsonString, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, mergeFrom, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, readOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, writeOneof, NULL, ZEND_ACC_PROTECTED) diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index e6d42eba..406a09a5 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -593,8 +593,8 @@ const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor *desc, PHP_METHOD(Message, serializeToString); PHP_METHOD(Message, mergeFromString); -PHP_METHOD(Message, jsonEncode); -PHP_METHOD(Message, jsonDecode); +PHP_METHOD(Message, serializeToJsonString); +PHP_METHOD(Message, mergeFromJsonString); // ----------------------------------------------------------------------------- // Type check / conversion. diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index cac2b401..d701dcba 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -2308,6 +2308,9 @@ bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) { bool ret; n = upb_filedef_defcount(file); + if (n == 0) { + return true; + } defs = upb_gmalloc(sizeof(*defs) * n); if (defs == NULL) { diff --git a/php/src/Google/Protobuf/Internal/CodedInputStream.php b/php/src/Google/Protobuf/Internal/CodedInputStream.php new file mode 100644 index 00000000..6131d5d1 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/CodedInputStream.php @@ -0,0 +1,373 @@ +buffer = $buffer; + $this->buffer_size_after_limit = 0; + $this->buffer_end = $end; + $this->current = $start; + $this->current_limit = $end; + $this->legitimate_message_end = false; + $this->recursion_budget = self::DEFAULT_RECURSION_LIMIT; + $this->recursion_limit = self::DEFAULT_RECURSION_LIMIT; + $this->total_bytes_limit = self::DEFAULT_TOTAL_BYTES_LIMIT; + $this->total_bytes_read = $end - $start; + } + + private function advance($amount) + { + $this->current += $amount; + } + + public function bufferSize() + { + return $this->buffer_end - $this->current; + } + + private function current() + { + return $this->total_bytes_read - + ($this->buffer_end - $this->current + + $this->buffer_size_after_limit); + } + + private function recomputeBufferLimits() + { + $this->buffer_end += $this->buffer_size_after_limit; + $closest_limit = min($this->current_limit, $this->total_bytes_limit); + if ($closest_limit < $this->total_bytes_read) { + // The limit position is in the current buffer. We must adjust the + // buffer size accordingly. + $this->buffer_size_after_limit = $this->total_bytes_read - + $closest_limit; + $this->buffer_end -= $this->buffer_size_after_limit; + } else { + $this->buffer_size_after_limit = 0; + } + } + + private function consumedEntireMessage() + { + return $this->legitimate_message_end; + } + + /** + * Read uint32 into $var. Advance buffer with consumed bytes. If the + * contained varint is larger than 32 bits, discard the high order bits. + * @param $var. + */ + public function readVarint32(&$var) + { + if (!$this->readVarint64($var)) { + return false; + } + + if (PHP_INT_SIZE == 4) { + $var = bcmod($var, 4294967296); + } else { + $var &= 0xFFFFFFFF; + } + + // Convert large uint32 to int32. + if ($var > 0x7FFFFFFF) { + if (PHP_INT_SIZE === 8) { + $var = $var | (0xFFFFFFFF << 32); + } else { + $var = bcsub($var, 4294967296); + } + } + + $var = intval($var); + return true; + } + + /** + * Read Uint64 into $var. Advance buffer with consumed bytes. + * @param $var. + */ + public function readVarint64(&$var) + { + $count = 0; + + if (PHP_INT_SIZE == 4) { + $high = 0; + $low = 0; + $b = 0; + + do { + if ($this->current === $this->buffer_end) { + return false; + } + if ($count === self::MAX_VARINT_BYTES) { + return false; + } + $b = ord($this->buffer[$this->current]); + $bits = 7 * $count; + if ($bits >= 32) { + $high |= (($b & 0x7F) << ($bits - 32)); + } else if ($bits > 25){ + // $bits is 28 in this case. + $low |= (($b & 0x7F) << 28); + $high = ($b & 0x7F) >> 4; + } else { + $low |= (($b & 0x7F) << $bits); + } + + $this->advance(1); + $count += 1; + } while ($b & 0x80); + + $var = GPBUtil::combineInt32ToInt64($high, $low); + if (bccomp($var, 0) < 0) { + $var = bcadd($var, "18446744073709551616"); + } + } else { + $result = 0; + $shift = 0; + + do { + if ($this->current === $this->buffer_end) { + return false; + } + if ($count === self::MAX_VARINT_BYTES) { + return false; + } + + $byte = ord($this->buffer[$this->current]); + $result |= ($byte & 0x7f) << $shift; + $shift += 7; + $this->advance(1); + $count += 1; + } while ($byte > 0x7f); + + $var = $result; + } + + return true; + } + + /** + * Read int into $var. If the result is larger than the largest integer, $var + * will be -1. Advance buffer with consumed bytes. + * @param $var. + */ + public function readVarintSizeAsInt(&$var) + { + if (!$this->readVarint64($var)) { + return false; + } + $var = (int)$var; + return true; + } + + /** + * Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes, + * return false. Advance buffer with consumed bytes. + * @param $var. + */ + public function readLittleEndian32(&$var) + { + $data = null; + if (!$this->readRaw(4, $data)) { + return false; + } + $var = unpack('V', $data); + $var = $var[1]; + return true; + } + + /** + * Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes, + * return false. Advance buffer with consumed bytes. + * @param $var. + */ + public function readLittleEndian64(&$var) + { + $data = null; + if (!$this->readRaw(4, $data)) { + return false; + } + $low = unpack('V', $data)[1]; + if (!$this->readRaw(4, $data)) { + return false; + } + $high = unpack('V', $data)[1]; + if (PHP_INT_SIZE == 4) { + $var = GPBUtil::combineInt32ToInt64($high, $low); + } else { + $var = ($high << 32) | $low; + } + return true; + } + + /** + * Read tag into $var. Advance buffer with consumed bytes. + * @param $var. + */ + public function readTag() + { + if ($this->current === $this->buffer_end) { + // Make sure that it failed due to EOF, not because we hit + // total_bytes_limit, which, unlike normal limits, is not a valid + // place to end a message. + $current_position = $this->total_bytes_read - + $this->buffer_size_after_limit; + if ($current_position >= $this->total_bytes_limit) { + // Hit total_bytes_limit_. But if we also hit the normal limit, + // we're still OK. + $this->legitimate_message_end = + ($this->current_limit === $this->total_bytes_limit); + } else { + $this->legitimate_message_end = true; + } + return 0; + } + + $result = 0; + // The larget tag is 2^29 - 1, which can be represented by int32. + $success = $this->readVarint32($result); + if ($success) { + return $result; + } else { + return 0; + } + } + + public function readRaw($size, &$buffer) + { + $current_buffer_size = 0; + if ($this->bufferSize() < $size) { + return false; + } + + $buffer = substr($this->buffer, $this->current, $size); + $this->advance($size); + + return true; + } + + /* Places a limit on the number of bytes that the stream may read, starting + * from the current position. Once the stream hits this limit, it will act + * like the end of the input has been reached until popLimit() is called. + * + * As the names imply, the stream conceptually has a stack of limits. The + * shortest limit on the stack is always enforced, even if it is not the top + * limit. + * + * The value returned by pushLimit() is opaque to the caller, and must be + * passed unchanged to the corresponding call to popLimit(). + * + * @param integer $byte_limit + * @throws Exception Fail to push limit. + */ + public function pushLimit($byte_limit) + { + // Current position relative to the beginning of the stream. + $current_position = $this->current(); + $old_limit = $this->current_limit; + + // security: byte_limit is possibly evil, so check for negative values + // and overflow. + if ($byte_limit >= 0 && + $byte_limit <= PHP_INT_MAX - $current_position && + $byte_limit <= $this->current_limit - $current_position) { + $this->current_limit = $current_position + $byte_limit; + $this->recomputeBufferLimits(); + } else { + throw new GPBDecodeException("Fail to push limit."); + } + + return $old_limit; + } + + /* The limit passed in is actually the *old* limit, which we returned from + * PushLimit(). + * + * @param integer $byte_limit + */ + public function popLimit($byte_limit) + { + $this->current_limit = $byte_limit; + $this->recomputeBufferLimits(); + // We may no longer be at a legitimate message end. ReadTag() needs to + // be called again to find out. + $this->legitimate_message_end = false; + } + + public function incrementRecursionDepthAndPushLimit( + $byte_limit, &$old_limit, &$recursion_budget) + { + $old_limit = $this->pushLimit($byte_limit); + $recursion_limit = --$this->recursion_limit; + } + + public function decrementRecursionDepthAndPopLimit($byte_limit) + { + $result = $this->consumedEntireMessage(); + $this->popLimit($byte_limit); + ++$this->recursion_budget; + return $result; + } + + public function bytesUntilLimit() + { + if ($this->current_limit === PHP_INT_MAX) { + return -1; + } + return $this->current_limit - $this->current; + } +} diff --git a/php/src/Google/Protobuf/Internal/CodedOutputStream.php b/php/src/Google/Protobuf/Internal/CodedOutputStream.php new file mode 100644 index 00000000..4525d8dd --- /dev/null +++ b/php/src/Google/Protobuf/Internal/CodedOutputStream.php @@ -0,0 +1,159 @@ +current = 0; + $this->buffer_size = $size; + $this->buffer = str_repeat(chr(0), $this->buffer_size); + } + + public function getData() + { + return $this->buffer; + } + + public function writeVarint32($value, $trim) + { + $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); + $size = self::writeVarintToArray($value, $bytes, $trim); + return $this->writeRaw($bytes, $size); + } + + public function writeVarint64($value) + { + $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); + $size = self::writeVarintToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeLittleEndian32($value) + { + $bytes = str_repeat(chr(0), 4); + $size = self::writeLittleEndian32ToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeLittleEndian64($value) + { + $bytes = str_repeat(chr(0), 8); + $size = self::writeLittleEndian64ToArray($value, $bytes); + return $this->writeRaw($bytes, $size); + } + + public function writeTag($tag) + { + return $this->writeVarint32($tag, true); + } + + public function writeRaw($data, $size) + { + if ($this->buffer_size < $size) { + trigger_error("Output stream doesn't have enough buffer."); + return false; + } + + for ($i = 0; $i < $size; $i++) { + $this->buffer[$this->current] = $data[$i]; + $this->current++; + $this->buffer_size--; + } + return true; + } + + private static function writeVarintToArray($value, &$buffer, $trim = false) + { + $current = 0; + + $high = 0; + $low = 0; + if (PHP_INT_SIZE == 4) { + GPBUtil::divideInt64ToInt32($value, $high, $low, $trim); + } else { + $low = $value; + } + + while (($low >= 0x80 || $low < 0) || $high != 0) { + $buffer[$current] = chr($low | 0x80); + $value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); + $carry = ($high & 0x7F) << ((PHP_INT_SIZE << 3) - 7); + $high = ($high >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); + $low = (($low >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)) | $carry); + $current++; + } + $buffer[$current] = chr($low); + return $current + 1; + } + + private static function writeLittleEndian32ToArray($value, &$buffer) + { + $buffer[0] = chr($value & 0x000000FF); + $buffer[1] = chr(($value >> 8) & 0x000000FF); + $buffer[2] = chr(($value >> 16) & 0x000000FF); + $buffer[3] = chr(($value >> 24) & 0x000000FF); + return 4; + } + + private static function writeLittleEndian64ToArray($value, &$buffer) + { + $high = 0; + $low = 0; + if (PHP_INT_SIZE == 4) { + GPBUtil::divideInt64ToInt32($value, $high, $low); + } else { + $low = $value & 0xFFFFFFFF; + $high = ($value >> 32) & 0xFFFFFFFF; + } + + $buffer[0] = chr($low & 0x000000FF); + $buffer[1] = chr(($low >> 8) & 0x000000FF); + $buffer[2] = chr(($low >> 16) & 0x000000FF); + $buffer[3] = chr(($low >> 24) & 0x000000FF); + $buffer[4] = chr($high & 0x000000FF); + $buffer[5] = chr(($high >> 8) & 0x000000FF); + $buffer[6] = chr(($high >> 16) & 0x000000FF); + $buffer[7] = chr(($high >> 24) & 0x000000FF); + return 8; + } + +} diff --git a/php/src/Google/Protobuf/Internal/Descriptor.php b/php/src/Google/Protobuf/Internal/Descriptor.php index f8d24e45..44225ad2 100644 --- a/php/src/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/Google/Protobuf/Internal/Descriptor.php @@ -37,6 +37,8 @@ class Descriptor private $full_name; private $field = []; + private $json_to_field = []; + private $name_to_field = []; private $nested_type = []; private $enum_type = []; private $klass; @@ -66,6 +68,8 @@ class Descriptor public function addField($field) { $this->field[$field->getNumber()] = $field; + $this->json_to_field[$field->getJsonName()] = $field; + $this->name_to_field[$field->getName()] = $field; } public function getField() @@ -95,11 +99,29 @@ class Descriptor public function getFieldByNumber($number) { - if (!isset($this->field[$number])) { - return NULL; - } else { - return $this->field[$number]; - } + if (!isset($this->field[$number])) { + return NULL; + } else { + return $this->field[$number]; + } + } + + public function getFieldByJsonName($json_name) + { + if (!isset($this->json_to_field[$json_name])) { + return NULL; + } else { + return $this->json_to_field[$json_name]; + } + } + + public function getFieldByName($name) + { + if (!isset($this->name_to_field[$name])) { + return NULL; + } else { + return $this->name_to_field[$name]; + } } public function setClass($klass) diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php index 7360a477..33a55a4a 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php @@ -8,6 +8,7 @@ class EnumDescriptor private $klass; private $full_name; private $value; + private $name_to_value; public function setFullName($full_name) { @@ -22,6 +23,17 @@ class EnumDescriptor public function addValue($number, $value) { $this->value[$number] = $value; + $this->name_to_value[$value->getName()] = $value; + } + + public function getValueByNumber($number) + { + return $this->value[$number]; + } + + public function getValueByName($name) + { + return $this->name_to_value[$name]; } public function setClass($klass) @@ -50,6 +62,10 @@ class EnumDescriptor $fullname); $desc->setFullName($fullname); $desc->setClass($classname); + $values = $proto->getValue(); + foreach ($values as $value) { + $desc->addValue($value->getNumber(), $value); + } return $desc; } diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php index e65a4e8d..549766e3 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptor.php @@ -34,4 +34,26 @@ namespace Google\Protobuf\Internal; class EnumValueDescriptor { + private $name; + private $number; + + public function setName($name) + { + $this->name = $name; + } + + public function getName() + { + return $this->name; + } + + public function setNumber($number) + { + $this->number = $number; + } + + public function getNumber() + { + return $this->number; + } } diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptor.php b/php/src/Google/Protobuf/Internal/FieldDescriptor.php index 6c91950f..f18bf810 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptor.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptor.php @@ -36,6 +36,7 @@ class FieldDescriptor { private $name; + private $json_name; private $setter; private $getter; private $number; @@ -67,6 +68,16 @@ class FieldDescriptor return $this->name; } + public function setJsonName($json_name) + { + $this->json_name = $json_name; + } + + public function getJsonName() + { + return $this->json_name; + } + public function setSetter($setter) { $this->setter = $setter; @@ -172,23 +183,49 @@ class FieldDescriptor $field_type !== GPBType::BYTES); } - public static function getFieldDescriptor( - $name, - $label, - $type, - $number, - $oneof_index, - $packed, - $type_name = null) + public static function getFieldDescriptor($proto) { + $type_name = null; + $type = $proto->getType(); + switch ($type) { + case GPBType::MESSAGE: + case GPBType::GROUP: + case GPBType::ENUM: + $type_name = $proto->getTypeName(); + break; + default: + break; + } + + $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; + $packed = false; + $options = $proto->getOptions(); + if ($options !== null) { + $packed = $options->getPacked(); + } + $field = new FieldDescriptor(); - $field->setName($name); - $camel_name = implode('', array_map('ucwords', explode('_', $name))); + $field->setName($proto->getName()); + + $json_name = $proto->hasJsonName() ? $proto->getJsonName() : + lcfirst(implode('', array_map('ucwords', explode('_', $proto->getName())))); + if ($proto->hasJsonName()) { + $json_name = $proto->getJsonName(); + } else { + $proto_name = $proto->getName(); + $json_name = implode('', array_map('ucwords', explode('_', $proto_name))); + if ($proto_name[0] !== "_" && !ctype_upper($proto_name[0])) { + $json_name = lcfirst($json_name); + } + } + $field->setJsonName($json_name); + + $camel_name = implode('', array_map('ucwords', explode('_', $proto->getName()))); $field->setGetter('get' . $camel_name); $field->setSetter('set' . $camel_name); - $field->setType($type); - $field->setNumber($number); - $field->setLabel($label); + $field->setType($proto->getType()); + $field->setNumber($proto->getNumber()); + $field->setLabel($proto->getLabel()); $field->setPacked($packed); $field->setOneofIndex($oneof_index); @@ -211,26 +248,6 @@ class FieldDescriptor public static function buildFromProto($proto) { - $type_name = null; - switch ($proto->getType()) { - case GPBType::MESSAGE: - case GPBType::GROUP: - case GPBType::ENUM: - $type_name = $proto->getTypeName(); - break; - default: - break; - } - - $oneof_index = $proto->hasOneofIndex() ? $proto->getOneofIndex() : -1; - $packed = false; - $options = $proto->getOptions(); - if ($options !== null) { - $packed = $options->getPacked(); - } - - return FieldDescriptor::getFieldDescriptor( - $proto->getName(), $proto->getLabel(), $proto->getType(), - $proto->getNumber(), $oneof_index, $packed, $type_name); + return FieldDescriptor::getFieldDescriptor($proto); } } diff --git a/php/src/Google/Protobuf/Internal/GPBJsonWire.php b/php/src/Google/Protobuf/Internal/GPBJsonWire.php new file mode 100644 index 00000000..97789356 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GPBJsonWire.php @@ -0,0 +1,285 @@ +writeRaw("\"", 1); + $field_name = GPBJsonWire::formatFieldName($field); + $output->writeRaw($field_name, strlen($field_name)); + $output->writeRaw("\":", 2); + return static::serializeFieldValueToStream($value, $field, $output); + } + + private static function serializeFieldValueToStream( + $values, + $field, + &$output) + { + if ($field->isMap()) { + $output->writeRaw("{", 1); + $first = true; + $map_entry = $field->getMessageType(); + $key_field = $map_entry->getFieldByNumber(1); + $value_field = $map_entry->getFieldByNumber(2); + + switch ($key_field->getType()) { + case GPBType::STRING: + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + case GPBType::FIXED64: + case GPBType::UINT64: + $additional_quote = false; + break; + default: + $additional_quote = true; + } + + foreach ($values as $key => $value) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if ($additional_quote) { + $output->writeRaw("\"", 1); + } + if (!static::serializeSingularFieldValueToStream( + $key, + $key_field, + $output)) { + return false; + } + if ($additional_quote) { + $output->writeRaw("\"", 1); + } + $output->writeRaw(":", 1); + if (!static::serializeSingularFieldValueToStream( + $value, + $value_field, + $output)) { + return false; + } + } + $output->writeRaw("}", 1); + return true; + } elseif ($field->isRepeated()) { + $output->writeRaw("[", 1); + $first = true; + foreach ($values as $value) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if (!static::serializeSingularFieldValueToStream( + $value, + $field, + $output)) { + return false; + } + } + $output->writeRaw("]", 1); + return true; + } else { + return static::serializeSingularFieldValueToStream( + $values, + $field, + $output); + } + } + + private static function serializeSingularFieldValueToStream( + $value, + $field, + &$output) + { + switch ($field->getType()) { + case GPBType::SFIXED32: + case GPBType::SINT32: + case GPBType::INT32: + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::FIXED32: + case GPBType::UINT32: + if ($value < 0) { + $value = bcadd($value, "4294967296"); + } + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::FIXED64: + case GPBType::UINT64: + if ($value < 0) { + $value = bcadd($value, "18446744073709551616"); + } + // Intentional fall through. + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + $output->writeRaw("\"", 1); + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + $output->writeRaw("\"", 1); + break; + case GPBType::FLOAT: + if (is_nan($value)) { + $str_value = "\"NaN\""; + } elseif ($value === INF) { + $str_value = "\"Infinity\""; + } elseif ($value === -INF) { + $str_value = "\"-Infinity\""; + } else { + $str_value = sprintf("%.8g", $value); + } + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::DOUBLE: + if (is_nan($value)) { + $str_value = "\"NaN\""; + } elseif ($value === INF) { + $str_value = "\"Infinity\""; + } elseif ($value === -INF) { + $str_value = "\"-Infinity\""; + } else { + $str_value = sprintf("%.17g", $value); + } + $output->writeRaw($str_value, strlen($str_value)); + break; + case GPBType::ENUM: + $enum_desc = $field->getEnumType(); + $enum_value_desc = $enum_desc->getValueByNumber($value); + if (!is_null($enum_value_desc)) { + $str_value = $enum_value_desc->getName(); + $output->writeRaw("\"", 1); + $output->writeRaw($str_value, strlen($str_value)); + $output->writeRaw("\"", 1); + } else { + $str_value = strval($value); + $output->writeRaw($str_value, strlen($str_value)); + } + break; + case GPBType::BOOL: + if ($value) { + $output->writeRaw("true", 4); + } else { + $output->writeRaw("false", 5); + } + break; + case GPBType::BYTES: + $value = base64_encode($value); + case GPBType::STRING: + $value = json_encode($value); + $output->writeRaw($value, strlen($value)); + break; + // case GPBType::GROUP: + // echo "GROUP\xA"; + // trigger_error("Not implemented.", E_ERROR); + // break; + case GPBType::MESSAGE: + $value->serializeToJsonStream($output); + break; + default: + user_error("Unsupported type."); + return false; + } + return true; + } + + private static function formatFieldName($field) + { + return $field->getJsonName(); + } + + // Used for escaping control chars in strings. + private static $k_control_char_limit = 0x20; + + private static function jsonNiceEscape($c) + { + switch ($c) { + case '"': return "\\\""; + case '\\': return "\\\\"; + case '/': return "\\/"; + case '\b': return "\\b"; + case '\f': return "\\f"; + case '\n': return "\\n"; + case '\r': return "\\r"; + case '\t': return "\\t"; + default: return NULL; + } + } + + private static function isJsonEscaped($c) + { + // See RFC 4627. + return $c < chr($k_control_char_limit) || $c === "\"" || $c === "\\"; + } + + public static function escapedJson($value) + { + $escaped_value = ""; + $unescaped_run = ""; + for ($i = 0; $i < strlen($value); $i++) { + $c = $value[$i]; + // Handle escaping. + if (static::isJsonEscaped($c)) { + // Use a "nice" escape, like \n, if one exists for this + // character. + $escape = static::jsonNiceEscape($c); + if (is_null($escape)) { + $escape = "\\u00" . bin2hex($c); + } + if ($unescaped_run !== "") { + $escaped_value .= $unescaped_run; + $unescaped_run = ""; + } + $escaped_value .= $escape; + } else { + if ($unescaped_run === "") { + $unescaped_run .= $c; + } + } + } + $escaped_value .= $unescaped_run; + return $escaped_value; + } + +} diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 8c97e9fa..22ad27f9 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -45,8 +45,13 @@ class GPBUtil $value = bcsub(0, $value); } - $high = (int) bcdiv(bcadd($value, 1), 4294967296); + $high = bcdiv($value, 4294967296); $low = bcmod($value, 4294967296); + if (bccomp($high, 2147483647) > 0) { + $high = (int) bcsub($high, 4294967296); + } else { + $high = (int) $high; + } if (bccomp($low, 2147483647) > 0) { $low = (int) bcsub($low, 4294967296); } else { @@ -58,7 +63,7 @@ class GPBUtil $low = ~$low; $low++; if (!$low) { - $high++; + $high = (int)($high + 1); } } @@ -70,15 +75,13 @@ class GPBUtil public static function checkString(&$var, $check_utf8) { if (is_array($var) || is_object($var)) { - trigger_error("Expect string.", E_USER_ERROR); - return; + throw new \InvalidArgumentException("Expect string."); } if (!is_string($var)) { $var = strval($var); } if ($check_utf8 && !preg_match('//u', $var)) { - trigger_error("Expect utf-8 encoding.", E_USER_ERROR); - return; + throw new \Exception("Expect utf-8 encoding."); } } @@ -92,7 +95,7 @@ class GPBUtil if (is_numeric($var)) { $var = intval($var); } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -109,7 +112,7 @@ class GPBUtil $var = (int) $var; } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -119,10 +122,15 @@ class GPBUtil if (PHP_INT_SIZE == 8) { $var = intval($var); } else { - $var = bcdiv($var, 1, 0); + if (is_float($var) || + is_integer($var) || + (is_string($var) && + bccomp($var, "9223372036854774784") < 0)) { + $var = number_format($var, 0, ".", ""); + } } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -132,10 +140,10 @@ class GPBUtil if (PHP_INT_SIZE == 8) { $var = intval($var); } else { - $var = bcdiv($var, 1, 0); + $var = number_format($var, 0, ".", ""); } } else { - trigger_error("Expect integer.", E_USER_ERROR); + throw new \Exception("Expect integer."); } } @@ -144,7 +152,7 @@ class GPBUtil if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { - trigger_error("Expect float.", E_USER_ERROR); + throw new \Exception("Expect float."); } } @@ -153,15 +161,14 @@ class GPBUtil if (is_float($var) || is_numeric($var)) { $var = floatval($var); } else { - trigger_error("Expect float.", E_USER_ERROR); + throw new \Exception("Expect float."); } } public static function checkBool(&$var) { if (is_array($var) || is_object($var)) { - trigger_error("Expect boolean.", E_USER_ERROR); - return; + throw new \Exception("Expect boolean."); } $var = boolval($var); } @@ -169,14 +176,14 @@ class GPBUtil public static function checkMessage(&$var, $klass) { if (!$var instanceof $klass && !is_null($var)) { - trigger_error("Expect message.", E_USER_ERROR); + throw new \Exception("Expect message."); } } public static function checkRepeatedField(&$var, $type, $klass = null) { if (!$var instanceof RepeatedField && !is_array($var)) { - trigger_error("Expect array.", E_USER_ERROR); + throw new \Exception("Expect array."); } if (is_array($var)) { $tmp = new RepeatedField($type, $klass); @@ -186,15 +193,13 @@ class GPBUtil return $tmp; } else { if ($var->getType() != $type) { - trigger_error( - "Expect repeated field of different type.", - E_USER_ERROR); + throw new \Exception( + "Expect repeated field of different type."); } if ($var->getType() === GPBType::MESSAGE && $var->getClass() !== $klass) { - trigger_error( - "Expect repeated field of different message.", - E_USER_ERROR); + throw new \Exception( + "Expect repeated field of different message."); } return $var; } @@ -203,7 +208,7 @@ class GPBUtil public static function checkMapField(&$var, $key_type, $value_type, $klass = null) { if (!$var instanceof MapField && !is_array($var)) { - trigger_error("Expect dict.", E_USER_ERROR); + throw new \Exception("Expect dict."); } if (is_array($var)) { $tmp = new MapField($key_type, $value_type, $klass); @@ -213,20 +218,15 @@ class GPBUtil return $tmp; } else { if ($var->getKeyType() != $key_type) { - trigger_error( - "Expect map field of key type.", - E_USER_ERROR); + throw new \Exception("Expect map field of key type."); } if ($var->getValueType() != $value_type) { - trigger_error( - "Expect map field of value type.", - E_USER_ERROR); + throw new \Exception("Expect map field of value type."); } if ($var->getValueType() === GPBType::MESSAGE && $var->getValueClass() !== $klass) { - trigger_error( - "Expect map field of different value message.", - E_USER_ERROR); + throw new \Exception( + "Expect map field of different value message."); } return $var; } @@ -328,7 +328,7 @@ class GPBUtil $low = ~$low; $low++; if (!$low) { - $high++; + $high = (int) ($high + 1); } } $result = bcadd(bcmul($high, 4294967296), $low); diff --git a/php/src/Google/Protobuf/Internal/GPBWire.php b/php/src/Google/Protobuf/Internal/GPBWire.php index 67eb1bee..e7eec552 100644 --- a/php/src/Google/Protobuf/Internal/GPBWire.php +++ b/php/src/Google/Protobuf/Internal/GPBWire.php @@ -117,19 +117,12 @@ class GPBWire // << decode << public static function zigZagEncode32($int32) { - // Fill high 32 bits. - if (PHP_INT_SIZE === 8) { - $int32 |= ((($int32 << 32) >> 31) & (0xFFFFFFFF << 32)); + if (PHP_INT_SIZE == 8) { + $trim_int32 = $int32 & 0xFFFFFFFF; + return (($trim_int32 << 1) ^ ($int32 << 32 >> 63)) & 0xFFFFFFFF; + } else { + return ($int32 << 1) ^ ($int32 >> 31); } - - $uint32 = ($int32 << 1) ^ ($int32 >> 31); - - // Fill high 32 bits. - if (PHP_INT_SIZE === 8) { - $uint32 |= ((($uint32 << 32) >> 31) & (0xFFFFFFFF << 32)); - } - - return $uint32; } public static function zigZagDecode32($uint32) @@ -177,7 +170,11 @@ class GPBWire public static function readInt64(&$input, &$value) { - return $input->readVarint64($value); + $success = $input->readVarint64($value); + if (PHP_INT_SIZE == 4 && bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $success; } public static function readUint32(&$input, &$value) @@ -231,7 +228,11 @@ class GPBWire public static function readSfixed64(&$input, &$value) { - return $input->readLittleEndian64($value); + $success = $input->readLittleEndian64($value); + if (PHP_INT_SIZE == 4 && bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $success; } public static function readFloat(&$input, &$value) @@ -298,7 +299,7 @@ class GPBWire public static function writeInt32(&$output, $value) { - return $output->writeVarint32($value); + return $output->writeVarint32($value, false); } public static function writeInt64(&$output, $value) @@ -308,7 +309,7 @@ class GPBWire public static function writeUint32(&$output, $value) { - return $output->writeVarint32($value); + return $output->writeVarint32($value, true); } public static function writeUint64(&$output, $value) @@ -319,7 +320,7 @@ class GPBWire public static function writeSint32(&$output, $value) { $value = GPBWire::zigZagEncode32($value); - return $output->writeVarint64($value); + return $output->writeVarint32($value, true); } public static function writeSint64(&$output, $value) @@ -351,9 +352,9 @@ class GPBWire public static function writeBool(&$output, $value) { if ($value) { - return $output->writeVarint32(1); + return $output->writeVarint32(1, true); } else { - return $output->writeVarint32(0); + return $output->writeVarint32(0, true); } } @@ -377,7 +378,7 @@ class GPBWire public static function writeBytes(&$output, $value) { $size = strlen($value); - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } return $output->writeRaw($value, $size); @@ -386,7 +387,7 @@ class GPBWire public static function writeMessage(&$output, $value) { $size = $value->byteSize(); - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } return $value->serializeToStream($output); @@ -442,7 +443,8 @@ class GPBWire public static function varint64Size($value) { if (PHP_INT_SIZE == 4) { - if (bccomp($value, 0) < 0) { + if (bccomp($value, 0) < 0 || + bccomp($value, "9223372036854775807") > 0) { return 10; } if (bccomp($value, 1 << 7) < 0) { @@ -578,6 +580,9 @@ class GPBWire } break; case GPBType::UINT32: + if (PHP_INT_SIZE === 8 && $value < 0) { + $value += 4294967296; + } if (!GPBWire::writeUint32($output, $value)) { return false; } diff --git a/php/src/Google/Protobuf/Internal/GPBWireType.php b/php/src/Google/Protobuf/Internal/GPBWireType.php new file mode 100644 index 00000000..c1ad370e --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GPBWireType.php @@ -0,0 +1,43 @@ +buffer = $buffer; - $this->buffer_size_after_limit = 0; - $this->buffer_end = $end; - $this->current = $start; - $this->current_limit = $end; - $this->legitimate_message_end = false; - $this->recursion_budget = self::DEFAULT_RECURSION_LIMIT; - $this->recursion_limit = self::DEFAULT_RECURSION_LIMIT; - $this->total_bytes_limit = self::DEFAULT_TOTAL_BYTES_LIMIT; - $this->total_bytes_read = $end - $start; - } - - private function advance($amount) - { - $this->current += $amount; - } - - private function bufferSize() - { - return $this->buffer_end - $this->current; - } - - private function current() - { - return $this->total_bytes_read - - ($this->buffer_end - $this->current + - $this->buffer_size_after_limit); - } - - private function recomputeBufferLimits() - { - $this->buffer_end += $this->buffer_size_after_limit; - $closest_limit = min($this->current_limit, $this->total_bytes_limit); - if ($closest_limit < $this->total_bytes_read) { - // The limit position is in the current buffer. We must adjust the - // buffer size accordingly. - $this->buffer_size_after_limit = $this->total_bytes_read - - $closest_limit; - $this->buffer_end -= $this->buffer_size_after_limit; - } else { - $this->buffer_size_after_limit = 0; - } - } - - private function consumedEntireMessage() - { - return $this->legitimate_message_end; - } - - /** - * Read uint32 into $var. Advance buffer with consumed bytes. If the - * contained varint is larger than 32 bits, discard the high order bits. - * @param $var. - */ - public function readVarint32(&$var) - { - if (!$this->readVarint64($var)) { - return false; - } - - if (PHP_INT_SIZE == 4) { - $var = bcmod($var, 4294967296); - } else { - $var &= 0xFFFFFFFF; - } - - // Convert large uint32 to int32. - if ($var > 0x7FFFFFFF) { - if (PHP_INT_SIZE === 8) { - $var = $var | (0xFFFFFFFF << 32); - } else { - $var = bcsub($var, 4294967296); - } - } - - $var = intval($var); - return true; - } - - /** - * Read Uint64 into $var. Advance buffer with consumed bytes. - * @param $var. - */ - public function readVarint64(&$var) - { - $count = 0; - - if (PHP_INT_SIZE == 4) { - $high = 0; - $low = 0; - $b = 0; - - do { - if ($this->current === $this->buffer_end) { - return false; - } - if ($count === self::MAX_VARINT_BYTES) { - return false; - } - $b = ord($this->buffer[$this->current]); - $bits = 7 * $count; - if ($bits >= 32) { - $high |= (($b & 0x7F) << ($bits - 32)); - } else if ($bits > 25){ - // $bits is 28 in this case. - $low |= (($b & 0x7F) << 28); - $high = ($b & 0x7F) >> 4; - } else { - $low |= (($b & 0x7F) << $bits); - } - - $this->advance(1); - $count += 1; - } while ($b & 0x80); - - $var = GPBUtil::combineInt32ToInt64($high, $low); - } else { - $result = 0; - $shift = 0; - - do { - if ($this->current === $this->buffer_end) { - return false; - } - if ($count === self::MAX_VARINT_BYTES) { - return false; - } - - $byte = ord($this->buffer[$this->current]); - $result |= ($byte & 0x7f) << $shift; - $shift += 7; - $this->advance(1); - $count += 1; - } while ($byte > 0x7f); - - $var = $result; - } - - return true; - } - - /** - * Read int into $var. If the result is larger than the largest integer, $var - * will be -1. Advance buffer with consumed bytes. - * @param $var. - */ - public function readVarintSizeAsInt(&$var) - { - if (!$this->readVarint64($var)) { - return false; - } - $var = (int)$var; - return true; - } - - /** - * Read 32-bit unsiged integer to $var. If the buffer has less than 4 bytes, - * return false. Advance buffer with consumed bytes. - * @param $var. - */ - public function readLittleEndian32(&$var) - { - $data = null; - if (!$this->readRaw(4, $data)) { - return false; - } - $var = unpack('V', $data); - $var = $var[1]; - return true; - } - - /** - * Read 64-bit unsiged integer to $var. If the buffer has less than 8 bytes, - * return false. Advance buffer with consumed bytes. - * @param $var. - */ - public function readLittleEndian64(&$var) - { - $data = null; - if (!$this->readRaw(4, $data)) { - return false; - } - $low = unpack('V', $data)[1]; - if (!$this->readRaw(4, $data)) { - return false; - } - $high = unpack('V', $data)[1]; - if (PHP_INT_SIZE == 4) { - $var = GPBUtil::combineInt32ToInt64($high, $low); - } else { - $var = ($high << 32) | $low; - } - return true; - } - - /** - * Read tag into $var. Advance buffer with consumed bytes. - * @param $var. - */ - public function readTag() - { - if ($this->current === $this->buffer_end) { - // Make sure that it failed due to EOF, not because we hit - // total_bytes_limit, which, unlike normal limits, is not a valid - // place to end a message. - $current_position = $this->total_bytes_read - - $this->buffer_size_after_limit; - if ($current_position >= $this->total_bytes_limit) { - // Hit total_bytes_limit_. But if we also hit the normal limit, - // we're still OK. - $this->legitimate_message_end = - ($this->current_limit === $this->total_bytes_limit); - } else { - $this->legitimate_message_end = true; - } - return 0; - } - - $result = 0; - // The larget tag is 2^29 - 1, which can be represented by int32. - $success = $this->readVarint32($result); - if ($success) { - return $result; - } else { - return 0; - } - } - - public function readRaw($size, &$buffer) - { - $current_buffer_size = 0; - if ($this->bufferSize() < $size) { - return false; - } - - $buffer = substr($this->buffer, $this->current, $size); - $this->advance($size); - - return true; - } - - /* Places a limit on the number of bytes that the stream may read, starting - * from the current position. Once the stream hits this limit, it will act - * like the end of the input has been reached until popLimit() is called. - * - * As the names imply, the stream conceptually has a stack of limits. The - * shortest limit on the stack is always enforced, even if it is not the top - * limit. - * - * The value returned by pushLimit() is opaque to the caller, and must be - * passed unchanged to the corresponding call to popLimit(). - * - * @param integer $byte_limit - * @throws Exception Fail to push limit. - */ - public function pushLimit($byte_limit) - { - // Current position relative to the beginning of the stream. - $current_position = $this->current(); - $old_limit = $this->current_limit; - - // security: byte_limit is possibly evil, so check for negative values - // and overflow. - if ($byte_limit >= 0 && - $byte_limit <= PHP_INT_MAX - $current_position && - $byte_limit <= $this->current_limit - $current_position) { - $this->current_limit = $current_position + $byte_limit; - $this->recomputeBufferLimits(); - } else { - throw new GPBDecodeException("Fail to push limit."); - } - - return $old_limit; - } - - /* The limit passed in is actually the *old* limit, which we returned from - * PushLimit(). - * - * @param integer $byte_limit - */ - public function popLimit($byte_limit) - { - $this->current_limit = $byte_limit; - $this->recomputeBufferLimits(); - // We may no longer be at a legitimate message end. ReadTag() needs to - // be called again to find out. - $this->legitimate_message_end = false; - } - - public function incrementRecursionDepthAndPushLimit( - $byte_limit, &$old_limit, &$recursion_budget) - { - $old_limit = $this->pushLimit($byte_limit); - $recursion_limit = --$this->recursion_limit; - } - - public function decrementRecursionDepthAndPopLimit($byte_limit) - { - $result = $this->consumedEntireMessage(); - $this->popLimit($byte_limit); - ++$this->recursion_budget; - return $result; - } - - public function bytesUntilLimit() - { - if ($this->current_limit === PHP_INT_MAX) { - return -1; - } - return $this->current_limit - $this->current; - } -} diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php index 12f09d61..38736dad 100644 --- a/php/src/Google/Protobuf/Internal/MapField.php +++ b/php/src/Google/Protobuf/Internal/MapField.php @@ -205,7 +205,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable */ public function getIterator() { - return new MapFieldIter($this->container); + return new MapFieldIter($this->container, $this->key_type); } /** diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php index a0388d92..cb707955 100644 --- a/php/src/Google/Protobuf/Internal/MapFieldIter.php +++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php @@ -54,11 +54,13 @@ class MapFieldIter implements \Iterator * * @param MapField The MapField instance for which this iterator is * created. + * @param GPBType Map key type. * @ignore */ - public function __construct($container) + public function __construct($container, $key_type) { $this->container = $container; + $this->key_type = $key_type; } /** @@ -88,7 +90,13 @@ class MapFieldIter implements \Iterator */ public function key() { - return key($this->container); + $key = key($this->container); + // PHP associative array stores bool as integer for key. + if ($this->key_type === GPBType::BOOL) { + return boolval($key); + } else { + return $key; + } } /** @@ -110,4 +118,4 @@ class MapFieldIter implements \Iterator { return key($this->container) !== null; } -} \ No newline at end of file +} diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index 9ba249a0..1ecd4fa2 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -36,8 +36,8 @@ namespace Google\Protobuf\Internal; -use Google\Protobuf\Internal\InputStream; -use Google\Protobuf\Internal\OutputStream; +use Google\Protobuf\Internal\CodedInputStream; +use Google\Protobuf\Internal\CodedOutputStream; use Google\Protobuf\Internal\DescriptorPool; use Google\Protobuf\Internal\GPBLabel; use Google\Protobuf\Internal\GPBType; @@ -68,6 +68,10 @@ class Message // specific descriptor from the descriptor pool. if (get_class($this) === 'Google\Protobuf\Internal\MapEntry') { $this->desc = $desc; + foreach ($desc->getField() as $field) { + $setter = $field->getSetter(); + $this->$setter($this->defaultValue($field)); + } return; } $pool = DescriptorPool::getGeneratedPool(); @@ -216,6 +220,58 @@ class Message } } + /** + * @ignore + */ + private static function skipField($input, $tag) + { + $number = GPBWire::getTagFieldNumber($tag); + if ($number === 0) { + throw new GPBDecodeException("Illegal field number zero."); + } + + switch (GPBWire::getTagWireType($tag)) { + case GPBWireType::VARINT: + $uint64 = 0; + if (!$input->readVarint64($uint64)) { + throw new GPBDecodeException( + "Unexpected EOF inside varint."); + } + return; + case GPBWireType::FIXED64: + $uint64 = 0; + if (!$input->readLittleEndian64($uint64)) { + throw new GPBDecodeException( + "Unexpected EOF inside fixed64."); + } + return; + case GPBWireType::FIXED32: + $uint32 = 0; + if (!$input->readLittleEndian32($uint32)) { + throw new GPBDecodeException( + "Unexpected EOF inside fixed32."); + } + return; + case GPBWireType::LENGTH_DELIMITED: + $length = 0; + if (!$input->readVarint32($length)) { + throw new GPBDecodeException( + "Unexpected EOF inside length."); + } + $data = NULL; + if (!$input->readRaw($length, $data)) { + throw new GPBDecodeException( + "Unexpected EOF inside length delimited data."); + } + return; + case GPBWireType::START_GROUP: + case GPBWireType::END_GROUP: + throw new GPBDecodeException("Unexpected wire type."); + default: + throw new GPBDecodeException("Unexpected wire type."); + } + } + /** * @ignore */ @@ -278,7 +334,6 @@ class Message } break; case GPBType::GROUP: - echo "GROUP\xA"; trigger_error("Not implemented.", E_ERROR); break; case GPBType::MESSAGE: @@ -349,19 +404,25 @@ class Message private function parseFieldFromStream($tag, $input, $field) { $value = null; - $field_type = $field->getType(); - $value_format = GPBWire::UNKNOWN; - if (GPBWire::getTagWireType($tag) === - GPBWire::getWireType($field_type)) { + if (is_null($field)) { + $value_format = GPBWire::UNKNOWN; + } elseif (GPBWire::getTagWireType($tag) === + GPBWire::getWireType($field->getType())) { $value_format = GPBWire::NORMAL_FORMAT; } elseif ($field->isPackable() && GPBWire::getTagWireType($tag) === GPBWire::WIRETYPE_LENGTH_DELIMITED) { $value_format = GPBWire::PACKED_FORMAT; + } else { + // the wire type doesn't match. Put it in our unknown field set. + $value_format = GPBWire::UNKNOWN; } - if ($value_format === GPBWire::NORMAL_FORMAT) { + if ($value_format === GPBWire::UNKNOWN) { + self::skipField($input, $tag); + return; + } elseif ($value_format === GPBWire::NORMAL_FORMAT) { self::parseFieldFromStreamNoTag($input, $field, $value); } elseif ($value_format === GPBWire::PACKED_FORMAT) { $length = 0; @@ -378,7 +439,7 @@ class Message $input->popLimit($limit); return; } else { - return false; + return; } if ($field->isMap()) { @@ -583,10 +644,28 @@ class Message */ public function mergeFromString($data) { - $input = new InputStream($data); + $input = new CodedInputStream($data); $this->parseFromStream($input); } + /** + * Parses a json string to protobuf message. + * + * This function takes a string in the json wire format, matching the + * encoding output by serializeToJsonString(). + * See mergeFrom() for merging behavior, if the field is already set in the + * specified message. + * + * @param string $data Json protobuf data. + * @return null. + * @throws Exception Invalid data. + */ + public function mergeFromJsonString($data) + { + $input = new RawInputStream($data); + $this->parseFromJsonStream($input); + } + /** * @ignore */ @@ -602,12 +681,233 @@ class Message $number = GPBWire::getTagFieldNumber($tag); $field = $this->desc->getFieldByNumber($number); - // Check whether we retrieved a known field - if ($field === NULL) { - continue; + $this->parseFieldFromStream($tag, $input, $field); + } + } + + private function convertJsonValueToProtoValue( + $value, + $field, + $is_map_key = false) + { + if (is_null($value)) { + return $this->defaultValue($field); + } + switch ($field->getType()) { + case GPBType::MESSAGE: + $klass = $field->getMessageType()->getClass(); + if (!is_object($value) && !is_array($value)) { + throw new \Exception("Expect message."); + } + $submsg = new $klass; + if (!is_null($value) && + $klass !== "Google\Protobuf\Any") { + $submsg->mergeFromJsonArray($value); + } + return $submsg; + case GPBType::ENUM: + if (is_integer($value)) { + return $value; + } else { + $enum_value = + $field->getEnumType()->getValueByName($value); + } + if (!is_null($enum_value)) { + return $enum_value->getNumber(); + } + case GPBType::STRING: + if (!is_string($value)) { + throw new GPBDecodeException("Expect string"); + } + return $value; + case GPBType::BYTES: + if (!is_string($value)) { + throw new GPBDecodeException("Expect string"); + } + $proto_value = base64_decode($value, true); + if ($proto_value === false) { + throw new GPBDecodeException( + "Invalid base64 characters"); + } + return $proto_value; + case GPBType::BOOL: + if ($is_map_key) { + if ($value === "true") { + return true; + } + if ($value === "false") { + return false; + } + throw new GPBDecodeException( + "Bool field only accept bool value"); + } + if (!is_bool($value)) { + throw new GPBDecodeException( + "Bool field only accept bool value"); + } + return $value; + case GPBType::FLOAT: + if ($value === "Infinity") { + return INF; + } + if ($value === "-Infinity") { + return -INF; + } + if ($value === "NaN") { + return NAN; + } + return $value; + case GPBType::DOUBLE: + if ($value === "Infinity") { + return INF; + } + if ($value === "-Infinity") { + return -INF; + } + if ($value === "NaN") { + return NAN; + } + return $value; + case GPBType::INT32: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int32 field"); + } + if (bccomp($value, "2147483647") > 0) { + throw new GPBDecodeException( + "Int32 too large"); + } + if (bccomp($value, "-2147483648") < 0) { + throw new GPBDecodeException( + "Int32 too small"); + } + return $value; + case GPBType::UINT32: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for uint32 field"); + } + if (bccomp($value, 4294967295) > 0) { + throw new GPBDecodeException( + "Uint32 too large"); + } + return $value; + case GPBType::INT64: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } + if (bccomp($value, "9223372036854775807") > 0) { + throw new GPBDecodeException( + "Int64 too large"); + } + if (bccomp($value, "-9223372036854775808") < 0) { + throw new GPBDecodeException( + "Int64 too small"); + } + return $value; + case GPBType::UINT64: + if (!is_numeric($value)) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } + if (bccomp($value, "18446744073709551615") > 0) { + throw new GPBDecodeException( + "Uint64 too large"); + } + if (bccomp($value, "9223372036854775807") > 0) { + $value = bcsub($value, "18446744073709551616"); + } + return $value; + case GPBType::FIXED64: + return $value; + default: + return $value; + } + } + + private function mergeFromJsonArray($array) + { + foreach ($array as $key => $value) { + $field = $this->desc->getFieldByJsonName($key); + if (is_null($field)) { + $field = $this->desc->getFieldByName($key); + if (is_null($field)) { + continue; + } + } + $setter = $field->getSetter(); + if ($field->isMap()) { + if (is_null($value)) { + continue; + } + $getter = $field->getGetter(); + $key_field = $field->getMessageType()->getFieldByNumber(1); + $value_field = $field->getMessageType()->getFieldByNumber(2); + foreach ($value as $tmp_key => $tmp_value) { + if (is_null($tmp_value)) { + throw new \Exception( + "Map value field element cannot be null."); + } + $proto_key = + $this->convertJsonValueToProtoValue( + $tmp_key, + $key_field, + true); + $proto_value = + $this->convertJsonValueToProtoValue( + $tmp_value, + $value_field); + $this->$getter()[$proto_key] = $proto_value; + } + } else if ($field->isRepeated()) { + if (is_null($value)) { + continue; + } + $getter = $field->getGetter(); + foreach ($value as $tmp) { + if (is_null($tmp)) { + throw new \Exception( + "Repeated field elements cannot be null."); + } + $proto_value = + $this->convertJsonValueToProtoValue($tmp, $field); + $this->$getter()[] = $proto_value; + } + } else { + $setter = $field->getSetter(); + $proto_value = + $this->convertJsonValueToProtoValue($value, $field); + if ($field->getType() === GPBType::MESSAGE) { + if (is_null($proto_value)) { + continue; + } + $getter = $field->getGetter(); + $submsg = $this->$getter(); + if (!is_null($submsg)) { + $submsg->mergeFrom($proto_value); + continue; + } + } + $this->$setter($proto_value); } + } + } - $this->parseFieldFromStream($tag, $input, $field); + /** + * @ignore + */ + public function parseFromJsonStream($input) + { + $array = json_decode($input->getData(), JSON_BIGINT_AS_STRING); + if (is_null($array)) { + throw new GPBDecodeException( + "Cannot decode json string."); + } + try { + $this->mergeFromJsonArray($array); + } catch (Exception $e) { + throw new GPBDecodeException($e->getMessage()); } } @@ -650,7 +950,7 @@ class Message foreach ($values as $value) { $size += $this->fieldDataOnlyByteSize($field, $value); } - if (!$output->writeVarint32($size)) { + if (!$output->writeVarint32($size, true)) { return false; } } @@ -708,6 +1008,16 @@ class Message } } + /** + * @ignore + */ + private function serializeFieldToJsonStream(&$output, $field) + { + $getter = $field->getGetter(); + $values = $this->$getter(); + return GPBJsonWire::serializeFieldToStream($values, $field, $output); + } + /** * @ignore */ @@ -722,17 +1032,52 @@ class Message return true; } + /** + * @ignore + */ + public function serializeToJsonStream(&$output) + { + $output->writeRaw("{", 1); + $fields = $this->desc->getField(); + $first = true; + foreach ($fields as $field) { + if ($this->existField($field)) { + if ($first) { + $first = false; + } else { + $output->writeRaw(",", 1); + } + if (!$this->serializeFieldToJsonStream($output, $field)) { + return false; + } + } + } + $output->writeRaw("}", 1); + return true; + } + /** * Serialize the message to string. * @return string Serialized binary protobuf data. */ public function serializeToString() { - $output = new OutputStream($this->byteSize()); + $output = new CodedOutputStream($this->byteSize()); $this->serializeToStream($output); return $output->getData(); } + /** + * Serialize the message to json string. + * @return string Serialized json protobuf data. + */ + public function serializeToJsonString() + { + $output = new CodedOutputStream($this->jsonByteSize()); + $this->serializeToJsonStream($output); + return $output->getData(); + } + /** * @ignore */ @@ -746,8 +1091,14 @@ class Message } $getter = $field->getGetter(); - $value = $this->$getter(); - return $value !== $this->defaultValue($field); + $values = $this->$getter(); + if ($field->isMap()) { + return count($values) !== 0; + } elseif ($field->isRepeated()) { + return count($values) !== 0; + } else { + return $values !== $this->defaultValue($field); + } } /** @@ -827,6 +1178,101 @@ class Message return $size; } + /** + * @ignore + */ + private function fieldDataOnlyJsonByteSize($field, $value) + { + $size = 0; + + switch ($field->getType()) { + case GPBType::SFIXED32: + case GPBType::SINT32: + case GPBType::INT32: + $size += strlen(strval($value)); + break; + case GPBType::FIXED32: + case GPBType::UINT32: + if ($value < 0) { + $value = bcadd($value, "4294967296"); + } + $size += strlen(strval($value)); + break; + case GPBType::FIXED64: + case GPBType::UINT64: + if ($value < 0) { + $value = bcadd($value, "18446744073709551616"); + } + // Intentional fall through. + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + $size += 2; // size for "" + $size += strlen(strval($value)); + break; + case GPBType::FLOAT: + if (is_nan($value)) { + $size += strlen("NaN") + 2; + } elseif ($value === INF) { + $size += strlen("Infinity") + 2; + } elseif ($value === -INF) { + $size += strlen("-Infinity") + 2; + } else { + $size += strlen(sprintf("%.8g", $value)); + } + break; + case GPBType::DOUBLE: + if (is_nan($value)) { + $size += strlen("NaN") + 2; + } elseif ($value === INF) { + $size += strlen("Infinity") + 2; + } elseif ($value === -INF) { + $size += strlen("-Infinity") + 2; + } else { + $size += strlen(sprintf("%.17g", $value)); + } + break; + case GPBType::ENUM: + $enum_desc = $field->getEnumType(); + $enum_value_desc = $enum_desc->getValueByNumber($value); + if (!is_null($enum_value_desc)) { + $size += 2; // size for "" + $size += strlen($enum_value_desc->getName()); + } else { + $str_value = strval($value); + $size += strlen($str_value); + } + break; + case GPBType::BOOL: + if ($value) { + $size += 4; + } else { + $size += 5; + } + break; + case GPBType::STRING: + $value = json_encode($value); + $size += strlen($value); + break; + case GPBType::BYTES: + $size += strlen(base64_encode($value)); + $size += 2; // size for \"\" + break; + case GPBType::MESSAGE: + $size += $value->jsonByteSize(); + break; +# case GPBType::GROUP: +# // TODO(teboring): Add support. +# user_error("Unsupported type."); +# break; + default: + user_error("Unsupported type " . $field->getType()); + return 0; + } + + return $size; + } + /** * @ignore */ @@ -844,12 +1290,18 @@ class Message $value_field = $message_type->getFieldByNumber(2); foreach ($values as $key => $value) { $data_size = 0; - $data_size += $this->fieldDataOnlyByteSize($key_field, $key); - $data_size += $this->fieldDataOnlyByteSize( - $value_field, - $value); - $data_size += GPBWire::tagSize($key_field); - $data_size += GPBWire::tagSize($value_field); + if ($key != $this->defaultValue($key_field)) { + $data_size += $this->fieldDataOnlyByteSize( + $key_field, + $key); + $data_size += GPBWire::tagSize($key_field); + } + if ($value != $this->defaultValue($value_field)) { + $data_size += $this->fieldDataOnlyByteSize( + $value_field, + $value); + $data_size += GPBWire::tagSize($value_field); + } $size += GPBWire::varint32Size($data_size) + $data_size; } } @@ -882,6 +1334,68 @@ class Message return $size; } + /** + * @ignore + */ + private function fieldJsonByteSize($field) + { + $size = 0; + if ($field->isMap()) { + $getter = $field->getGetter(); + $values = $this->$getter(); + $count = count($values); + if ($count !== 0) { + $size += 5; // size for "\"\":{}". + $size += strlen($field->getJsonName()); // size for field name + $size += $count - 1; // size for commas + $getter = $field->getGetter(); + $map_entry = $field->getMessageType(); + $key_field = $map_entry->getFieldByNumber(1); + $value_field = $map_entry->getFieldByNumber(2); + switch ($key_field->getType()) { + case GPBType::STRING: + case GPBType::SFIXED64: + case GPBType::INT64: + case GPBType::SINT64: + case GPBType::FIXED64: + case GPBType::UINT64: + $additional_quote = false; + break; + default: + $additional_quote = true; + } + foreach ($values as $key => $value) { + if ($additional_quote) { + $size += 2; // size for "" + } + $size += $this->fieldDataOnlyJsonByteSize($key_field, $key); + $size += $this->fieldDataOnlyJsonByteSize($value_field, $value); + $size += 1; // size for : + } + } + } elseif ($field->isRepeated()) { + $getter = $field->getGetter(); + $values = $this->$getter(); + $count = count($values); + if ($count !== 0) { + $size += 5; // size for "\"\":[]". + $size += strlen($field->getJsonName()); // size for field name + $size += $count - 1; // size for commas + $getter = $field->getGetter(); + foreach ($values as $value) { + $size += $this->fieldDataOnlyJsonByteSize($field, $value); + } + } + } elseif ($this->existField($field)) { + $size += 3; // size for "\"\":". + $size += strlen($field->getJsonName()); // size for field name + $getter = $field->getGetter(); + $value = $this->$getter(); + $size += $this->fieldDataOnlyJsonByteSize($field, $value); + } + return $size; + } + /** * @ignore */ @@ -921,4 +1435,28 @@ class Message $this->$setter($field_arr_value); } } + + /** + * @ignore + */ + public function jsonByteSize() + { + $size = 0; + + // Size for "{}". + $size += 2; + + $fields = $this->desc->getField(); + $count = 0; + foreach ($fields as $field) { + $field_size = $this->fieldJsonByteSize($field); + $size += $field_size; + if ($field_size != 0) { + $count++; + } + } + // size for comma + $size += $count > 0 ? ($count - 1) : 0; + return $size; + } } diff --git a/php/src/Google/Protobuf/Internal/OutputStream.php b/php/src/Google/Protobuf/Internal/OutputStream.php deleted file mode 100644 index 8c6d9b68..00000000 --- a/php/src/Google/Protobuf/Internal/OutputStream.php +++ /dev/null @@ -1,159 +0,0 @@ -current = 0; - $this->buffer_size = $size; - $this->buffer = str_repeat(chr(0), $this->buffer_size); - } - - public function getData() - { - return $this->buffer; - } - - public function writeVarint32($value) - { - $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); - $size = self::writeVarintToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeVarint64($value) - { - $bytes = str_repeat(chr(0), self::MAX_VARINT64_BYTES); - $size = self::writeVarintToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeLittleEndian32($value) - { - $bytes = str_repeat(chr(0), 4); - $size = self::writeLittleEndian32ToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeLittleEndian64($value) - { - $bytes = str_repeat(chr(0), 8); - $size = self::writeLittleEndian64ToArray($value, $bytes); - return $this->writeRaw($bytes, $size); - } - - public function writeTag($tag) - { - return $this->writeVarint32($tag); - } - - public function writeRaw($data, $size) - { - if ($this->buffer_size < $size) { - trigger_error("Output stream doesn't have enough buffer."); - return false; - } - - for ($i = 0; $i < $size; $i++) { - $this->buffer[$this->current] = $data[$i]; - $this->current++; - $this->buffer_size--; - } - return true; - } - - private static function writeVarintToArray($value, &$buffer) - { - $current = 0; - - $high = 0; - $low = 0; - if (PHP_INT_SIZE == 4) { - GPBUtil::divideInt64ToInt32($value, $high, $low); - } else { - $low = $value; - } - - while ($low >= 0x80 || $low < 0) { - $buffer[$current] = chr($low | 0x80); - $value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); - $carry = ($high & 0x7F) << ((PHP_INT_SIZE << 3) - 7); - $high = ($high >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)); - $low = (($low >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7)) | $carry); - $current++; - } - $buffer[$current] = chr($low); - return $current + 1; - } - - private static function writeLittleEndian32ToArray($value, &$buffer) - { - $buffer[0] = chr($value & 0x000000FF); - $buffer[1] = chr(($value >> 8) & 0x000000FF); - $buffer[2] = chr(($value >> 16) & 0x000000FF); - $buffer[3] = chr(($value >> 24) & 0x000000FF); - return 4; - } - - private static function writeLittleEndian64ToArray($value, &$buffer) - { - $high = 0; - $low = 0; - if (PHP_INT_SIZE == 4) { - GPBUtil::divideInt64ToInt32($value, $high, $low); - } else { - $low = $value & 0xFFFFFFFF; - $high = ($value >> 32) & 0xFFFFFFFF; - } - - $buffer[0] = chr($low & 0x000000FF); - $buffer[1] = chr(($low >> 8) & 0x000000FF); - $buffer[2] = chr(($low >> 16) & 0x000000FF); - $buffer[3] = chr(($low >> 24) & 0x000000FF); - $buffer[4] = chr($high & 0x000000FF); - $buffer[5] = chr(($high >> 8) & 0x000000FF); - $buffer[6] = chr(($high >> 16) & 0x000000FF); - $buffer[7] = chr(($high >> 24) & 0x000000FF); - return 8; - } - -} diff --git a/php/src/Google/Protobuf/Internal/RawInputStream.php b/php/src/Google/Protobuf/Internal/RawInputStream.php new file mode 100644 index 00000000..4e7ed5cb --- /dev/null +++ b/php/src/Google/Protobuf/Internal/RawInputStream.php @@ -0,0 +1,50 @@ +buffer = $buffer; + } + + public function getData() + { + return $this->buffer; + } + +} diff --git a/php/tests/array_test.php b/php/tests/array_test.php index b55408da..271389ba 100644 --- a/php/tests/array_test.php +++ b/php/tests/array_test.php @@ -19,23 +19,23 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::INT32); // Test append. - $arr []= MAX_INT32; + $arr[] = MAX_INT32; $this->assertSame(MAX_INT32, $arr[0]); - $arr []= MIN_INT32; + $arr[] = MIN_INT32; $this->assertSame(MIN_INT32, $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(1, $arr[2]); - $arr []= MAX_INT32_FLOAT; + $arr[] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[3]); - $arr []= MAX_INT32_FLOAT; + $arr[] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[4]); - $arr []= '2'; + $arr[] = '2'; $this->assertSame(2, $arr[5]); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertSame(3, $arr[6]); - $arr []= MAX_INT32_STRING; + $arr[] = MAX_INT32_STRING; $this->assertSame(MAX_INT32, $arr[7]); $this->assertEquals(8, count($arr)); @@ -46,29 +46,29 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_INT32; + $arr[0] = MAX_INT32; $this->assertSame(MAX_INT32, $arr[0]); - $arr [1]= MIN_INT32; + $arr[1] = MIN_INT32; $this->assertSame(MIN_INT32, $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame(1, $arr[2]); - $arr [3]= MAX_INT32_FLOAT; + $arr[3] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[3]); - $arr [4]= MAX_INT32_FLOAT; + $arr[4] = MAX_INT32_FLOAT; $this->assertSame(MAX_INT32, $arr[4]); - $arr [5]= '2'; + $arr[5] = '2'; $this->assertSame(2, $arr[5]); - $arr [6]= '3.1'; + $arr[6] = '3.1'; $this->assertSame(3, $arr[6]); - $arr [7]= MAX_INT32_STRING; + $arr[7] = MAX_INT32_STRING; $this->assertSame(MAX_INT32, $arr[7]); // Test foreach. $arr = new RepeatedField(GPBType::INT32); for ($i = 0; $i < 3; $i++) { - $arr []= $i; + $arr[] = $i; } $i = 0; foreach ($arr as $val) { @@ -77,44 +77,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $this->assertSame(3, $i); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint32 field. ######################################################### @@ -124,31 +86,31 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::UINT32); // Test append. - $arr []= MAX_UINT32; + $arr[] = MAX_UINT32; $this->assertSame(-1, $arr[0]); - $arr []= -1; + $arr[] = -1; $this->assertSame(-1, $arr[1]); - $arr []= MIN_UINT32; + $arr[] = MIN_UINT32; $this->assertSame(MIN_UINT32, $arr[2]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(1, $arr[3]); - $arr []= MAX_UINT32_FLOAT; + $arr[] = MAX_UINT32_FLOAT; $this->assertSame(-1, $arr[4]); - $arr []= -1.0; + $arr[] = -1.0; $this->assertSame(-1, $arr[5]); - $arr []= MIN_UINT32_FLOAT; + $arr[] = MIN_UINT32_FLOAT; $this->assertSame(MIN_UINT32, $arr[6]); - $arr []= '2'; + $arr[] = '2'; $this->assertSame(2, $arr[7]); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertSame(3, $arr[8]); - $arr []= MAX_UINT32_STRING; + $arr[] = MAX_UINT32_STRING; $this->assertSame(-1, $arr[9]); - $arr []= '-1.0'; + $arr[] = '-1.0'; $this->assertSame(-1, $arr[10]); - $arr []= MIN_UINT32_STRING; + $arr[] = MIN_UINT32_STRING; $this->assertSame(MIN_UINT32, $arr[11]); $this->assertEquals(12, count($arr)); @@ -159,72 +121,34 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_UINT32; + $arr[0] = MAX_UINT32; $this->assertSame(-1, $arr[0]); - $arr [1]= -1; + $arr[1] = -1; $this->assertSame(-1, $arr[1]); - $arr [2]= MIN_UINT32; + $arr[2] = MIN_UINT32; $this->assertSame(MIN_UINT32, $arr[2]); - $arr [3]= 1.1; + $arr[3] = 1.1; $this->assertSame(1, $arr[3]); - $arr [4]= MAX_UINT32_FLOAT; + $arr[4] = MAX_UINT32_FLOAT; $this->assertSame(-1, $arr[4]); - $arr [5]= -1.0; + $arr[5] = -1.0; $this->assertSame(-1, $arr[5]); - $arr [6]= MIN_UINT32_FLOAT; + $arr[6] = MIN_UINT32_FLOAT; $this->assertSame(MIN_UINT32, $arr[6]); - $arr [7]= '2'; + $arr[7] = '2'; $this->assertSame(2, $arr[7]); - $arr [8]= '3.1'; + $arr[8] = '3.1'; $this->assertSame(3, $arr[8]); - $arr [9]= MAX_UINT32_STRING; + $arr[9] = MAX_UINT32_STRING; $this->assertSame(-1, $arr[9]); - $arr [10]= '-1.0'; + $arr[10] = '-1.0'; $this->assertSame(-1, $arr[10]); - $arr [11]= MIN_UINT32_STRING; + $arr[11] = MIN_UINT32_STRING; $this->assertSame(MIN_UINT32, $arr[11]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT32); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test int64 field. ######################################################### @@ -234,13 +158,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::INT64); // Test append. - $arr []= MAX_INT64; - $arr []= MIN_INT64; - $arr []= 1.1; - $arr []= '2'; - $arr []= '3.1'; - $arr []= MAX_INT64_STRING; - $arr []= MIN_INT64_STRING; + $arr[] = MAX_INT64; + $arr[] = MIN_INT64; + $arr[] = 1.1; + $arr[] = '2'; + $arr[] = '3.1'; + $arr[] = MAX_INT64_STRING; + $arr[] = MIN_INT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_INT64, $arr[0]); $this->assertSame(MIN_INT64, $arr[1]); @@ -272,13 +196,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_INT64; - $arr [1]= MIN_INT64; - $arr [2]= 1.1; - $arr [3]= '2'; - $arr [4]= '3.1'; - $arr [5]= MAX_INT64_STRING; - $arr [6]= MIN_INT64_STRING; + $arr[0] = MAX_INT64; + $arr[1] = MIN_INT64; + $arr[2] = 1.1; + $arr[3] = '2'; + $arr[4] = '3.1'; + $arr[5] = MAX_INT64_STRING; + $arr[6] = MIN_INT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_INT64_STRING, $arr[0]); @@ -299,44 +223,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageFail() - { - $arr = new RepeatedField(GPBType::INT64); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint64 field. ######################################################### @@ -346,11 +232,11 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::UINT64); // Test append. - $arr []= MAX_UINT64; - $arr []= 1.1; - $arr []= '2'; - $arr []= '3.1'; - $arr []= MAX_UINT64_STRING; + $arr[] = MAX_UINT64; + $arr[] = 1.1; + $arr[] = '2'; + $arr[] = '3.1'; + $arr[] = MAX_UINT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_UINT64_STRING, $arr[0]); @@ -379,11 +265,11 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= MAX_UINT64; - $arr [1]= 1.1; - $arr [2]= '2'; - $arr [3]= '3.1'; - $arr [4]= MAX_UINT64_STRING; + $arr[0] = MAX_UINT64; + $arr[1] = 1.1; + $arr[2] = '2'; + $arr[3] = '3.1'; + $arr[4] = MAX_UINT64_STRING; if (PHP_INT_SIZE == 4) { $this->assertSame(MAX_UINT64_STRING, $arr[0]); @@ -400,44 +286,6 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64AppendMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageFail() - { - $arr = new RepeatedField(GPBType::UINT64); - $arr []= 0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test float field. ######################################################### @@ -447,15 +295,15 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::FLOAT); // Test append. - $arr []= 1; + $arr[] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr []= 1.1; + $arr[] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr []= '2'; + $arr[] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); $this->assertEquals(4, count($arr)); @@ -466,56 +314,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 1; + $arr[0] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr [1]= 1.1; + $arr[1] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr [2]= '2'; + $arr[2] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr [3]= '3.1'; + $arr[3] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetStringFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 0.0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatAppendMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetMessageFail() - { - $arr = new RepeatedField(GPBType::FLOAT); - $arr []= 0.0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test double field. ######################################################### @@ -525,15 +335,15 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::DOUBLE); // Test append. - $arr []= 1; + $arr[] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr []= 1.1; + $arr[] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr []= '2'; + $arr[] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr []= '3.1'; + $arr[] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); $this->assertEquals(4, count($arr)); @@ -544,56 +354,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 1; + $arr[0] = 1; $this->assertEquals(1.0, $arr[0], '', MAX_FLOAT_DIFF); - $arr [1]= 1.1; + $arr[1] = 1.1; $this->assertEquals(1.1, $arr[1], '', MAX_FLOAT_DIFF); - $arr [2]= '2'; + $arr[2] = '2'; $this->assertEquals(2.0, $arr[2], '', MAX_FLOAT_DIFF); - $arr [3]= '3.1'; + $arr[3] = '3.1'; $this->assertEquals(3.1, $arr[3], '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 0.0; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleAppendMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageFail() - { - $arr = new RepeatedField(GPBType::DOUBLE); - $arr []= 0.0; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test bool field. ######################################################### @@ -603,16 +375,16 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::BOOL); // Test append. - $arr []= true; + $arr[] = true; $this->assertSame(true, $arr[0]); - $arr []= -1; + $arr[] = -1; $this->assertSame(true, $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame(true, $arr[2]); - $arr []= ''; + $arr[] = ''; $this->assertSame(false, $arr[3]); $this->assertEquals(4, count($arr)); @@ -623,38 +395,19 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= true; + $arr[0] = true; $this->assertSame(true, $arr[0]); - $arr [1]= -1; + $arr[1] = -1; $this->assertSame(true, $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame(true, $arr[2]); - $arr [3]= ''; + $arr[3] = ''; $this->assertSame(false, $arr[3]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolAppendMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageFail() - { - $arr = new RepeatedField(GPBType::BOOL); - $arr []= true; - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test string field. ######################################################### @@ -664,16 +417,16 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $arr = new RepeatedField(GPBType::STRING); // Test append. - $arr []= 'abc'; + $arr[] = 'abc'; $this->assertSame('abc', $arr[0]); - $arr []= 1; + $arr[] = 1; $this->assertSame('1', $arr[1]); - $arr []= 1.1; + $arr[] = 1.1; $this->assertSame('1.1', $arr[2]); - $arr []= true; + $arr[] = true; $this->assertSame('1', $arr[3]); $this->assertEquals(4, count($arr)); @@ -684,59 +437,19 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase } // Test set. - $arr [0]= 'abc'; + $arr[0] = 'abc'; $this->assertSame('abc', $arr[0]); - $arr [1]= 1; + $arr[1] = 1; $this->assertSame('1', $arr[1]); - $arr [2]= 1.1; + $arr[2] = 1.1; $this->assertSame('1.1', $arr[2]); - $arr [3]= true; + $arr[3] = true; $this->assertSame('1', $arr[3]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageFail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= 'abc'; - $arr [0]= new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringAppendInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $hex = hex2bin("ff"); - $arr []= $hex; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8Fail() - { - $arr = new RepeatedField(GPBType::STRING); - $arr []= 'abc'; - $hex = hex2bin("ff"); - $arr [0]= $hex; - } - ######################################################### # Test message field. ######################################################### @@ -748,7 +461,7 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase // Test append. $sub_m = new TestMessage_Sub(); $sub_m->setA(1); - $arr []= $sub_m; + $arr[] = $sub_m; $this->assertSame(1, $arr[0]->getA()); $this->assertEquals(1, count($arr)); @@ -756,78 +469,10 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase // Test set. $sub_m = new TestMessage_Sub(); $sub_m->setA(2); - $arr [0]= $sub_m; + $arr[0] = $sub_m; $this->assertSame(2, $arr[0]->getA()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= 1; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub; - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendOtherMessageFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageAppendNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $null = null; - $arr []= $null; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage_Sub::class); - $arr []= new TestMessage_Sub(); - $null = null; - $arr[0] = $null; - } - ######################################################### # Test offset type ######################################################### @@ -835,18 +480,18 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase public function testOffset() { $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; + $arr[] = 0; - $arr [0]= 1; + $arr[0] = 1; $this->assertSame(1, $arr[0]); $this->assertSame(1, count($arr)); - $arr ['0']= 2; + $arr['0'] = 2; $this->assertSame(2, $arr['0']); $this->assertSame(2, $arr[0]); $this->assertSame(1, count($arr)); - $arr [0.0]= 3; + $arr[0.0] = 3; $this->assertSame(3, $arr[0.0]); $this->assertSame(1, count($arr)); } @@ -855,9 +500,9 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase { $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr []= 1; - $arr []= 2; + $arr[] = 0; + $arr[] = 1; + $arr[] = 2; $this->assertSame(3, count($arr)); unset($arr[2]); @@ -865,67 +510,13 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase $this->assertSame(0, $arr[0]); $this->assertSame(1, $arr[1]); - $arr [] = 3; + $arr[] = 3; $this->assertSame(3, count($arr)); $this->assertSame(0, $arr[0]); $this->assertSame(1, $arr[1]); $this->assertSame(3, $arr[2]); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveMiddleFail() - { - $arr = new RepeatedField(GPBType::INT32); - - $arr []= 0; - $arr []= 1; - $arr []= 2; - $this->assertSame(3, count($arr)); - - unset($arr[1]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRemoveEmptyFail() - { - $arr = new RepeatedField(GPBType::INT32); - - unset($arr[0]); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr []= 0; - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testSetNonExistedOffsetFail() - { - $arr = new RepeatedField(GPBType::INT32); - $arr [0]= 0; - } - ######################################################### # Test memory leak ######################################################### @@ -933,7 +524,7 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase public function testCycleLeak() { $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); - $arr []= new TestMessage; + $arr[] = new TestMessage; $arr[0]->SetRepeatedRecursive($arr); // Clean up memory before test. diff --git a/php/tests/compatibility_test.sh b/php/tests/compatibility_test.sh index e05b2af1..6f1e4900 100755 --- a/php/tests/compatibility_test.sh +++ b/php/tests/compatibility_test.sh @@ -1,6 +1,6 @@ #!/bin/bash -use_php() { +function use_php() { VERSION=$1 PHP=`which php` PHP_CONFIG=`which php-config` @@ -10,7 +10,7 @@ use_php() { ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE } -generate_proto() { +function generate_proto() { PROTOC1=$1 PROTOC2=$2 @@ -25,6 +25,27 @@ generate_proto() { popd } +# Remove tests to expect error. These were added to API tests by mistake. +function remove_error_test() { + local TEMPFILE=`tempfile` + cat $1 | \ + awk -v file=`basename $1` -v dir=`basename $(dirname $1)` ' + BEGIN { + show = 1 + } + /@expectedException PHPUnit_Framework_Error/ { show = 0; next; } + / *\*\// { print; next; } + / *}/ { + if (!show) { + show = 1; + next; + } + } + show { print } + ' > $TEMPFILE + cp $TEMPFILE $1 +} + set -ex # Change to the script's directory. @@ -81,6 +102,15 @@ OLD_PROTOC=`pwd`/old_protoc cd protobuf/php cp -r /usr/local/vendor-5.5 vendor wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit + +# Remove implementation detail tests. +tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) +sed -i.bak '/php_implementation_test.php/d' phpunit.xml +for t in "${tests[@]}" +do + remove_error_test tests/$t +done + cd tests # Test A.1: diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index b4cfed42..e2912ad4 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -14,417 +14,432 @@ use Foo\TestUnpackedMessage; class EncodeDecodeTest extends TestBase { - public function testEncode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()), - bin2hex($data)); - } - - public function testDecode() - { - $to = new TestMessage(); - $to->mergeFromString(TestUtil::getGoldenTestMessage()); - $this->expectFields($to); - } - - public function testEncodeDecode() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - $this->setFields($from); - $this->expectFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectFields($to); - } - - public function testEncodeDecodeEmpty() - { - $from = new TestMessage(); - $this->expectEmptyFields($from); - - $data = $from->serializeToString(); - - $to = new TestMessage(); - $to->mergeFromString($data); - $this->expectEmptyFields($to); - } +# public function testEncode() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# $this->setFields($from); +# $this->expectFields($from); +# +# $data = $from->serializeToString(); +# $this->assertSame(bin2hex(TestUtil::getGoldenTestMessage()), +# bin2hex($data)); +# } +# +# public function testDecode() +# { +# $to = new TestMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestMessage()); +# $this->expectFields($to); +# } +# +# public function testEncodeDecode() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# $this->setFields($from); +# $this->expectFields($from); +# +# $data = $from->serializeToString(); +# +# $to = new TestMessage(); +# $to->mergeFromString($data); +# $this->expectFields($to); +# } +# +# public function testEncodeDecodeEmpty() +# { +# $from = new TestMessage(); +# $this->expectEmptyFields($from); +# +# $data = $from->serializeToString(); +# +# $to = new TestMessage(); +# $to->mergeFromString($data); +# $this->expectEmptyFields($to); +# } public function testEncodeDecodeOneof() { $m = new TestMessage(); - $m->setOneofInt32(1); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofInt32()); - - $m->setOneofFloat(2.0); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(2.0, $n->getOneofFloat()); - - $m->setOneofString('abc'); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame('abc', $n->getOneofString()); - - $sub_m = new TestMessage_Sub(); - $sub_m->setA(1); - $m->setOneofMessage($sub_m); - $data = $m->serializeToString(); - $n = new TestMessage(); - $n->mergeFromString($data); - $this->assertSame(1, $n->getOneofMessage()->getA()); +# $m->setOneofInt32(1); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(1, $n->getOneofInt32()); +# +# $m->setOneofFloat(2.0); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(2.0, $n->getOneofFloat()); +# +# $m->setOneofString('abc'); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame('abc', $n->getOneofString()); +# +# $sub_m = new TestMessage_Sub(); +# $sub_m->setA(1); +# $m->setOneofMessage($sub_m); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame(1, $n->getOneofMessage()->getA()); // Encode default value - $m->setOneofEnum(TestEnum::ZERO); +# $m->setOneofEnum(TestEnum::ZERO); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame("oneof_enum", $n->getMyOneof()); +# $this->assertSame(TestEnum::ZERO, $n->getOneofEnum()); + + $m->setOneofString(""); $data = $m->serializeToString(); $n = new TestMessage(); $n->mergeFromString($data); - $this->assertSame("oneof_enum", $n->getMyOneof()); - } - - public function testPackedEncode() - { - $from = new TestPackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestPackedMessage(), - $from->serializeToString()); - } - - public function testPackedDecodePacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testPackedDecodeUnpacked() - { - $to = new TestPackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedEncode() - { - $from = new TestUnpackedMessage(); - TestUtil::setTestPackedMessage($from); - $this->assertSame(TestUtil::getGoldenTestUnpackedMessage(), - $from->serializeToString()); - } - - public function testUnpackedDecodePacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testUnpackedDecodeUnpacked() - { - $to = new TestUnpackedMessage(); - $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); - TestUtil::assertTestPackedMessage($to); - } - - public function testDecodeInt64() - { - // Read 64 testing - $testVals = array( - '10' => '100a', - '100' => '1064', - '800' => '10a006', - '6400' => '108032', - '70400' => '1080a604', - '774400' => '1080a22f', - '9292800' => '108098b704', - '74342400' => '1080c0b923', - '743424000' => '108080bfe202', - '8177664000' => '108080b5bb1e', - '65421312000' => '108080a8dbf301', - '785055744000' => '108080e0c7ec16', - '9420668928000' => '10808080dd969202', - '103627358208000' => '10808080fff9c717', - '1139900940288000' => '10808080f5bd978302', - '13678811283456000' => '10808080fce699a618', - '109430490267648000' => '10808080e0b7ceb1c201', - '984874412408832000' => '10808080e0f5c1bed50d', - ); - - $msg = new TestMessage(); - foreach ($testVals as $original => $encoded) { - $msg->setOptionalInt64($original); - $data = $msg->serializeToString(); - $this->assertSame($encoded, bin2hex($data)); - $msg->setOptionalInt64(0); - $msg->mergeFromString($data); - $this->assertEquals($original, $msg->getOptionalInt64()); - } - } - - public function testDecodeToExistingMessage() - { - $m1 = new TestMessage(); - $this->setFields($m1); - $this->expectFields($m1); - - $m2 = new TestMessage(); - $this->setFields2($m2); - $data = $m2->serializeToString(); - - $m1->mergeFromString($data); - $this->expectFieldsMerged($m1); - } - - public function testDecodeFieldNonExist() - { - $data = hex2bin('c80501'); - $m = new TestMessage(); - $m->mergeFromString($data); - } - - public function testEncodeNegativeInt32() - { - $m = new TestMessage(); - $m->setOptionalInt32(-1); - $data = $m->serializeToString(); - $this->assertSame("08ffffffffffffffffff01", bin2hex($data)); - } - - public function testDecodeNegativeInt32() - { - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffffffffffffff01")); - $this->assertEquals(-1, $m->getOptionalInt32()); - - $m = new TestMessage(); - $this->assertEquals(0, $m->getOptionalInt32()); - $m->mergeFromString(hex2bin("08ffffffff0f")); - $this->assertEquals(-1, $m->getOptionalInt32()); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('08')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSubMessage() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('9A010108')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('10')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('18')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidUInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('20')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('28')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSInt64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('30')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('3D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('41')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed32() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('4D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidSFixed64() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('51')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidFloat() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('5D')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidDouble() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('61')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBool() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('68')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('72')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidStringDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7201')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidBytesDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('7A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidEnum() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8001')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageLengthMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A01')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidMessageDataMiss() - { - $m = new TestMessage(); - $m->mergeFromString(hex2bin('8A0101')); - } - - /** - * @expectedException Exception - */ - public function testDecodeInvalidPackedMessageLength() - { - $m = new TestPackedMessage(); - $m->mergeFromString(hex2bin('D205')); - } - - # TODO(teboring): Add test back when php implementation is ready for json - # encode/decode. - # public function testJsonEncode() - # { - # $from = new TestMessage(); - # $this->setFields($from); - # $data = $from->jsonEncode(); - # $to = new TestMessage(); - # $to->jsonDecode($data); - # $this->expectFields($to); - # } + $this->assertSame("oneof_string", $n->getMyOneof()); + $this->assertSame("", $n->getOneofString()); + +# $sub_m = new TestMessage_Sub(); +# $m->setOneofMessage($sub_m); +# $data = $m->serializeToString(); +# $n = new TestMessage(); +# $n->mergeFromString($data); +# $this->assertSame("oneof_message", $n->getMyOneof()); +# $this->assertFalse(is_null($n->getOneofMessage())); + + } + +# public function testPackedEncode() +# { +# $from = new TestPackedMessage(); +# TestUtil::setTestPackedMessage($from); +# $this->assertSame(TestUtil::getGoldenTestPackedMessage(), +# $from->serializeToString()); +# } +# +# public function testPackedDecodePacked() +# { +# $to = new TestPackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testPackedDecodeUnpacked() +# { +# $to = new TestPackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testUnpackedEncode() +# { +# $from = new TestUnpackedMessage(); +# TestUtil::setTestPackedMessage($from); +# $this->assertSame(TestUtil::getGoldenTestUnpackedMessage(), +# $from->serializeToString()); +# } +# +# public function testUnpackedDecodePacked() +# { +# $to = new TestUnpackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestPackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testUnpackedDecodeUnpacked() +# { +# $to = new TestUnpackedMessage(); +# $to->mergeFromString(TestUtil::getGoldenTestUnpackedMessage()); +# TestUtil::assertTestPackedMessage($to); +# } +# +# public function testDecodeInt64() +# { +# // Read 64 testing +# $testVals = array( +# '10' => '100a', +# '100' => '1064', +# '800' => '10a006', +# '6400' => '108032', +# '70400' => '1080a604', +# '774400' => '1080a22f', +# '9292800' => '108098b704', +# '74342400' => '1080c0b923', +# '743424000' => '108080bfe202', +# '8177664000' => '108080b5bb1e', +# '65421312000' => '108080a8dbf301', +# '785055744000' => '108080e0c7ec16', +# '9420668928000' => '10808080dd969202', +# '103627358208000' => '10808080fff9c717', +# '1139900940288000' => '10808080f5bd978302', +# '13678811283456000' => '10808080fce699a618', +# '109430490267648000' => '10808080e0b7ceb1c201', +# '984874412408832000' => '10808080e0f5c1bed50d', +# ); +# +# $msg = new TestMessage(); +# foreach ($testVals as $original => $encoded) { +# $msg->setOptionalInt64($original); +# $data = $msg->serializeToString(); +# $this->assertSame($encoded, bin2hex($data)); +# $msg->setOptionalInt64(0); +# $msg->mergeFromString($data); +# $this->assertEquals($original, $msg->getOptionalInt64()); +# } +# } +# +# public function testDecodeToExistingMessage() +# { +# $m1 = new TestMessage(); +# $this->setFields($m1); +# $this->expectFields($m1); +# +# $m2 = new TestMessage(); +# $this->setFields2($m2); +# $data = $m2->serializeToString(); +# +# $m1->mergeFromString($data); +# $this->expectFieldsMerged($m1); +# } +# +# public function testDecodeFieldNonExist() +# { +# $data = hex2bin('c80501'); +# $m = new TestMessage(); +# $m->mergeFromString($data); +# } +# +# public function testEncodeNegativeInt32() +# { +# $m = new TestMessage(); +# $m->setOptionalInt32(-1); +# $data = $m->serializeToString(); +# $this->assertSame("08ffffffffffffffffff01", bin2hex($data)); +# } +# +# public function testDecodeNegativeInt32() +# { +# $m = new TestMessage(); +# $this->assertEquals(0, $m->getOptionalInt32()); +# $m->mergeFromString(hex2bin("08ffffffffffffffffff01")); +# $this->assertEquals(-1, $m->getOptionalInt32()); +# +# $m = new TestMessage(); +# $this->assertEquals(0, $m->getOptionalInt32()); +# $m->mergeFromString(hex2bin("08ffffffff0f")); +# $this->assertEquals(-1, $m->getOptionalInt32()); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('08')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSubMessage() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('9A010108')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('10')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidUInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('18')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidUInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('20')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSInt32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('28')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSInt64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('30')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFixed32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('3D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFixed64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('41')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSFixed32() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('4D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidSFixed64() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('51')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidFloat() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('5D')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidDouble() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('61')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBool() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('68')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidStringLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('72')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidStringDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7201')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBytesLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7A')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidBytesDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('7A01')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidEnum() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8001')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidMessageLengthMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8A01')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidMessageDataMiss() +# { +# $m = new TestMessage(); +# $m->mergeFromString(hex2bin('8A0101')); +# } +# +# /** +# * @expectedException Exception +# */ +# public function testDecodeInvalidPackedMessageLength() +# { +# $m = new TestPackedMessage(); +# $m->mergeFromString(hex2bin('D205')); +# } +# +# public function testJsonEncode() +# { +# $from = new TestMessage(); +# $this->setFields($from); +# $data = $from->serializeToJsonString(); +# $to = new TestMessage(); +# $to->mergeFromJsonString($data); +# $this->expectFields($to); +# } } diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh index 0809bef3..484e2edf 100755 --- a/php/tests/gdb_test.sh +++ b/php/tests/gdb_test.sh @@ -3,7 +3,7 @@ # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which # phpunit` --bootstrap autoload.php tmp_test.php # -gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php well_known_test.php +gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php # # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php # diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index 33f38e1c..56e3be20 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -62,24 +62,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(MIN_INT32, $m->getOptionalInt32()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt32('abc'); - } - ######################################################### # Test uint32 field. ######################################################### @@ -119,24 +101,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(MIN_INT32, $m->getOptionalUint32()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint32(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint32('abc'); - } - ######################################################### # Test int64 field. ######################################################### @@ -189,24 +153,6 @@ class GeneratedClassTest extends TestBase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalInt64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalInt64('abc'); - } - ######################################################### # Test uint64 field. ######################################################### @@ -254,24 +200,6 @@ class GeneratedClassTest extends TestBase } } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalUint64(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64FieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalUint64('abc'); - } - ######################################################### # Test enum field. ######################################################### @@ -326,24 +254,6 @@ class GeneratedClassTest extends TestBase $this->assertEquals(3.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalFloat(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalFloat('abc'); - } - ######################################################### # Test double field. ######################################################### @@ -367,24 +277,6 @@ class GeneratedClassTest extends TestBase $this->assertEquals(3.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidTypeFail() - { - $m = new TestMessage(); - $m->setOptionalDouble(new TestMessage()); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalDouble('abc'); - } - ######################################################### # Test bool field. ######################################################### @@ -410,15 +302,6 @@ class GeneratedClassTest extends TestBase $this->assertSame(false, $m->getOptionalBool()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolFieldInvalidStringFail() - { - $m = new TestMessage(); - $m->setOptionalBool(new TestMessage()); - } - ######################################################### # Test string field. ######################################################### @@ -444,16 +327,6 @@ class GeneratedClassTest extends TestBase $this->assertSame('1', $m->getOptionalString()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringFieldInvalidUTF8Fail() - { - $m = new TestMessage(); - $hex = hex2bin("ff"); - $m->setOptionalString($hex); - } - ######################################################### # Test bytes field. ######################################################### @@ -504,25 +377,6 @@ class GeneratedClassTest extends TestBase $this->assertNull($m->getOptionalMessage()); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setOptionalMessage($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageFieldWrongClassFail() - { - $m = new TestMessage(); - $m->setOptionalMessage(new TestMessage()); - } - ######################################################### # Test repeated field. ######################################################### @@ -556,48 +410,6 @@ class GeneratedClassTest extends TestBase $this->assertFalse($arr instanceof RepeatedField); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setRepeatedInt32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setRepeatedInt32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $repeated_int32 = new RepeatedField(GPBType::UINT32); - $m->setRepeatedInt32($repeated_int32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testRepeatedFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $repeated_message = new RepeatedField(GPBType::MESSAGE, - TestMessage::class); - $m->setRepeatedMessage($repeated_message); - } - ######################################################### # Test map field. ######################################################### @@ -629,49 +441,6 @@ class GeneratedClassTest extends TestBase $this->assertFalse($dict instanceof MapField); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongTypeFail() - { - $m = new TestMessage(); - $a = 1; - $m->setMapInt32Int32($a); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongObjectFail() - { - $m = new TestMessage(); - $m->setMapInt32Int32($m); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedTypeFail() - { - $m = new TestMessage(); - - $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); - $m->setMapInt32Int32($map_uint32_uint32); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMapFieldWrongRepeatedMessageClassFail() - { - $m = new TestMessage(); - - $map_int32_message = new MapField(GPBType::INT32, - GPBType::MESSAGE, - TestMessage::class); - $m->setMapInt32Message($map_int32_message); - } - ######################################################### # Test oneof field. ######################################################### @@ -851,16 +620,6 @@ class GeneratedClassTest extends TestBase $this->expectFields($n); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageMergeFromInvalidTypeFail() - { - $m = new TestMessage(); - $n = new TestMessage_Sub(); - $m->mergeFrom($n); - } - ######################################################### # Test message/enum without namespace. ######################################################### diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php index 2fda9135..c5d21264 100644 --- a/php/tests/map_field_test.php +++ b/php/tests/map_field_test.php @@ -58,42 +58,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetStringValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt32SetMessageValueFail() - { - $arr = new MapField(GPBType::INT32, GPBType::INT32); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint32 field. ######################################################### @@ -159,42 +123,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetStringValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint32SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT32, GPBType::UINT32); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test int64 field. ######################################################### @@ -252,42 +180,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageKeyFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testInt64SetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::INT64); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test uint64 field. ######################################################### @@ -339,42 +231,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr ['abc']= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetStringValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageKeyFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [new TestMessage_Sub()]= 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testUint64SetMessageValueFail() - { - $arr = new MapField(GPBType::UINT64, GPBType::UINT64); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test float field. ######################################################### @@ -397,24 +253,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(4, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::FLOAT); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testFloatSetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::FLOAT); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test double field. ######################################################### @@ -437,24 +275,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(4, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetStringValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr [0]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testDoubleSetMessageValueFail() - { - $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); - $arr [0]= new TestMessage_Sub(); - } - ######################################################### # Test bool field. ######################################################### @@ -515,24 +335,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageKeyFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr [new TestMessage_Sub()]= true; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testBoolSetMessageValueFail() - { - $arr = new MapField(GPBType::BOOL, GPBType::BOOL); - $arr [true]= new TestMessage_Sub(); - } - ######################################################### # Test string field. ######################################################### @@ -566,42 +368,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(0, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8KeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr[hex2bin("ff")]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetInvalidUTF8ValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr ['abc']= hex2bin("ff"); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageKeyFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr [new TestMessage_Sub()]= 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testStringSetMessageValueFail() - { - $arr = new MapField(GPBType::STRING, GPBType::STRING); - $arr ['abc']= new TestMessage_Sub(); - } - ######################################################### # Test message field. ######################################################### @@ -619,47 +385,6 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(1, count($arr)); } - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetIntValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 0; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetStringValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = 'abc'; - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetOtherMessageValueFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $arr[0] = new TestMessage_Sub(); - } - - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testMessageSetNullFail() - { - $arr = - new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); - $null = NULL; - $arr[0] = $null; - } - ######################################################### # Test memory leak ######################################################### @@ -669,7 +394,7 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { // { // $arr = new MapField(GPBType::INT32, // GPBType::MESSAGE, TestMessage::class); - // $arr [0]= new TestMessage; + // $arr[0] = new TestMessage; // $arr[0]->SetMapRecursive($arr); // // Clean up memory before test. diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php index 4f951a89..6572fdd0 100644 --- a/php/tests/memory_leak_test.php +++ b/php/tests/memory_leak_test.php @@ -49,7 +49,7 @@ TestUtil::assertTestMessage($to); $from->setRecursive($from); $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); -$arr []= new TestMessage; +$arr[] = new TestMessage; $arr[0]->SetRepeatedRecursive($arr); // Test oneof fields. diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php index e1249808..5dbc9233 100644 --- a/php/tests/php_implementation_test.php +++ b/php/tests/php_implementation_test.php @@ -6,12 +6,12 @@ require_once('test_util.php'); use Foo\TestMessage; use Foo\TestMessage_Sub; use Foo\TestPackedMessage; -use Google\Protobuf\Internal\InputStream; +use Google\Protobuf\Internal\CodedInputStream; use Google\Protobuf\Internal\FileDescriptorSet; use Google\Protobuf\Internal\GPBLabel; use Google\Protobuf\Internal\GPBType; use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\OutputStream; +use Google\Protobuf\Internal\CodedOutputStream; class ImplementationTest extends TestBase { @@ -21,17 +21,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readInt32($input, $value); $this->assertSame(1, $value); // Negative number. - $input = new InputStream(hex2bin("ffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffff0f")); GPBWire::readInt32($input, $value); $this->assertSame(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffff7f")); + $input = new CodedInputStream(hex2bin("ffffffff7f")); GPBWire::readInt32($input, $value); $this->assertSame(-1, $value); } @@ -41,17 +41,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readUint32($input, $value); $this->assertSame(1, $value); // Max uint32. - $input = new InputStream(hex2bin("ffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffff0f")); GPBWire::readUint32($input, $value); $this->assertSame(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffff7f")); + $input = new CodedInputStream(hex2bin("ffffffff7f")); GPBWire::readUint32($input, $value); $this->assertSame(-1, $value); } @@ -61,17 +61,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readInt64($input, $value); $this->assertEquals(1, $value); // Negative number. - $input = new InputStream(hex2bin("ffffffffffffffffff01")); + $input = new CodedInputStream(hex2bin("ffffffffffffffffff01")); GPBWire::readInt64($input, $value); $this->assertEquals(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("ffffffffffffffffff0f")); + $input = new CodedInputStream(hex2bin("ffffffffffffffffff0f")); GPBWire::readInt64($input, $value); $this->assertEquals(-1, $value); } @@ -81,17 +81,17 @@ class ImplementationTest extends TestBase $value = null; // Positive number. - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readUint64($input, $value); $this->assertEquals(1, $value); // Negative number. - $input = new InputStream(hex2bin("FFFFFFFFFFFFFFFFFF01")); + $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF01")); GPBWire::readUint64($input, $value); $this->assertEquals(-1, $value); // Discard overflow bits. - $input = new InputStream(hex2bin("FFFFFFFFFFFFFFFFFF0F")); + $input = new CodedInputStream(hex2bin("FFFFFFFFFFFFFFFFFF0F")); GPBWire::readUint64($input, $value); $this->assertEquals(-1, $value); } @@ -100,15 +100,15 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readSint32($input, $value); $this->assertSame(0, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readSint32($input, $value); $this->assertSame(-1, $value); - $input = new InputStream(hex2bin("02")); + $input = new CodedInputStream(hex2bin("02")); GPBWire::readSint32($input, $value); $this->assertSame(1, $value); } @@ -117,15 +117,15 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readSint64($input, $value); $this->assertEquals(0, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readSint64($input, $value); $this->assertEquals(-1, $value); - $input = new InputStream(hex2bin("02")); + $input = new CodedInputStream(hex2bin("02")); GPBWire::readSint64($input, $value); $this->assertEquals(1, $value); } @@ -133,7 +133,7 @@ class ImplementationTest extends TestBase public function testReadFixed32() { $value = null; - $input = new InputStream(hex2bin("12345678")); + $input = new CodedInputStream(hex2bin("12345678")); GPBWire::readFixed32($input, $value); $this->assertSame(0x78563412, $value); } @@ -141,7 +141,7 @@ class ImplementationTest extends TestBase public function testReadFixed64() { $value = null; - $input = new InputStream(hex2bin("1234567812345678")); + $input = new CodedInputStream(hex2bin("1234567812345678")); GPBWire::readFixed64($input, $value); if (PHP_INT_SIZE == 4) { $this->assertSame("8671175386481439762", $value); @@ -153,7 +153,7 @@ class ImplementationTest extends TestBase public function testReadSfixed32() { $value = null; - $input = new InputStream(hex2bin("12345678")); + $input = new CodedInputStream(hex2bin("12345678")); GPBWire::readSfixed32($input, $value); $this->assertSame(0x78563412, $value); } @@ -161,7 +161,7 @@ class ImplementationTest extends TestBase public function testReadFloat() { $value = null; - $input = new InputStream(hex2bin("0000803F")); + $input = new CodedInputStream(hex2bin("0000803F")); GPBWire::readFloat($input, $value); $this->assertSame(1.0, $value); } @@ -170,11 +170,11 @@ class ImplementationTest extends TestBase { $value = null; - $input = new InputStream(hex2bin("00")); + $input = new CodedInputStream(hex2bin("00")); GPBWire::readBool($input, $value); $this->assertSame(false, $value); - $input = new InputStream(hex2bin("01")); + $input = new CodedInputStream(hex2bin("01")); GPBWire::readBool($input, $value); $this->assertSame(true, $value); } @@ -182,7 +182,7 @@ class ImplementationTest extends TestBase public function testReadDouble() { $value = null; - $input = new InputStream(hex2bin("000000000000F03F")); + $input = new CodedInputStream(hex2bin("000000000000F03F")); GPBWire::readDouble($input, $value); $this->assertSame(1.0, $value); } @@ -190,7 +190,7 @@ class ImplementationTest extends TestBase public function testReadSfixed64() { $value = null; - $input = new InputStream(hex2bin("1234567812345678")); + $input = new CodedInputStream(hex2bin("1234567812345678")); GPBWire::readSfixed64($input, $value); if (PHP_INT_SIZE == 4) { $this->assertSame("8671175386481439762", $value); @@ -207,8 +207,7 @@ class ImplementationTest extends TestBase $this->assertSame(3, GPBWire::zigZagEncode32(-2)); $this->assertSame(0x7FFFFFFE, GPBWire::zigZagEncode32(0x3FFFFFFF)); $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(0xC0000000)); - $this->assertSame(-2, GPBWire::zigZagEncode32(0x7FFFFFFF)); - $this->assertSame(-1, GPBWire::zigZagEncode32(0x80000000)); + $this->assertSame(0x7FFFFFFF, GPBWire::zigZagEncode32(-1073741824)); $this->assertSame(0, GPBWire::zigZagDecode32(0)); $this->assertSame(-1, GPBWire::zigZagDecode32(1)); @@ -220,6 +219,8 @@ class ImplementationTest extends TestBase $this->assertSame((int)-2147483648,GPBWire::zigZagDecode32(0xFFFFFFFF)); if (PHP_INT_SIZE == 4) { + $this->assertSame(-2, GPBWire::zigZagEncode32(0x7FFFFFFF)); + $this->assertSame(-1, GPBWire::zigZagEncode32(0x80000000)); $this->assertSame('0', GPBWire::zigZagEncode64(0)); $this->assertSame('1', GPBWire::zigZagEncode64(-1)); $this->assertSame('2', GPBWire::zigZagEncode64(1)); @@ -250,6 +251,8 @@ class ImplementationTest extends TestBase $this->assertSame('1', GPBWire::zigZagDecode64(2)); $this->assertSame('-2', GPBWire::zigZagDecode64(3)); } else { + $this->assertSame(4294967294, GPBWire::zigZagEncode32(0x7FFFFFFF)); + $this->assertSame(4294967295, GPBWire::zigZagEncode32(0x80000000)); $this->assertSame(0, GPBWire::zigZagEncode64(0)); $this->assertSame(1, GPBWire::zigZagEncode64(-1)); $this->assertSame(2, GPBWire::zigZagEncode64(1)); @@ -330,19 +333,19 @@ class ImplementationTest extends TestBase $var = 0; // Empty buffer. - $input = new InputStream(hex2bin('')); + $input = new CodedInputStream(hex2bin('')); $this->assertFalse($input->readVarint64($var)); // The largest varint is 10 bytes long. - $input = new InputStream(hex2bin('8080808080808080808001')); + $input = new CodedInputStream(hex2bin('8080808080808080808001')); $this->assertFalse($input->readVarint64($var)); // Corrupted varint. - $input = new InputStream(hex2bin('808080')); + $input = new CodedInputStream(hex2bin('808080')); $this->assertFalse($input->readVarint64($var)); // Normal case. - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $this->assertTrue($input->readVarint64($var)); if (PHP_INT_SIZE == 4) { $this->assertSame('16384', $var); @@ -352,7 +355,7 @@ class ImplementationTest extends TestBase $this->assertFalse($input->readVarint64($var)); // Read two varint. - $input = new InputStream(hex2bin('808001808002')); + $input = new CodedInputStream(hex2bin('808001808002')); $this->assertTrue($input->readVarint64($var)); if (PHP_INT_SIZE == 4) { $this->assertSame('16384', $var); @@ -390,7 +393,7 @@ class ImplementationTest extends TestBase ); foreach ($testVals as $original => $encoded) { - $input = new InputStream(hex2bin($encoded)); + $input = new CodedInputStream(hex2bin($encoded)); $this->assertTrue($input->readVarint64($var)); $this->assertEquals($original, $var); } @@ -401,25 +404,25 @@ class ImplementationTest extends TestBase $var = 0; // Empty buffer. - $input = new InputStream(hex2bin('')); + $input = new CodedInputStream(hex2bin('')); $this->assertFalse($input->readVarint32($var)); // The largest varint is 10 bytes long. - $input = new InputStream(hex2bin('8080808080808080808001')); + $input = new CodedInputStream(hex2bin('8080808080808080808001')); $this->assertFalse($input->readVarint32($var)); // Corrupted varint. - $input = new InputStream(hex2bin('808080')); + $input = new CodedInputStream(hex2bin('808080')); $this->assertFalse($input->readVarint32($var)); // Normal case. - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertFalse($input->readVarint32($var)); // Read two varint. - $input = new InputStream(hex2bin('808001808002')); + $input = new CodedInputStream(hex2bin('808001808002')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertTrue($input->readVarint32($var)); @@ -427,7 +430,7 @@ class ImplementationTest extends TestBase $this->assertFalse($input->readVarint32($var)); // Read a 64-bit integer. High-order bits should be discarded. - $input = new InputStream(hex2bin('808081808001')); + $input = new CodedInputStream(hex2bin('808081808001')); $this->assertTrue($input->readVarint32($var)); $this->assertSame(16384, $var); $this->assertFalse($input->readVarint32($var)); @@ -435,7 +438,7 @@ class ImplementationTest extends TestBase public function testReadTag() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $tag = $input->readTag(); $this->assertSame(16384, $tag); $tag = $input->readTag(); @@ -444,7 +447,7 @@ class ImplementationTest extends TestBase public function testPushPopLimit() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $old_limit = $input->pushLimit(0); $tag = $input->readTag(); $this->assertSame(0, $tag); @@ -455,7 +458,7 @@ class ImplementationTest extends TestBase public function testReadRaw() { - $input = new InputStream(hex2bin('808001')); + $input = new CodedInputStream(hex2bin('808001')); $buffer = null; $this->assertTrue($input->readRaw(3, $buffer)); @@ -466,33 +469,33 @@ class ImplementationTest extends TestBase public function testWriteVarint32() { - $output = new OutputStream(3); - $output->writeVarint32(16384); + $output = new CodedOutputStream(3); + $output->writeVarint32(16384, true); $this->assertSame(hex2bin('808001'), $output->getData()); // Negative numbers are padded to be compatible with int64. - $output = new OutputStream(10); - $output->writeVarint32(-43); + $output = new CodedOutputStream(10); + $output->writeVarint32(-43, false); $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); } public function testWriteVarint64() { - $output = new OutputStream(10); + $output = new CodedOutputStream(10); $output->writeVarint64(-43); $this->assertSame(hex2bin('D5FFFFFFFFFFFFFFFF01'), $output->getData()); } public function testWriteLittleEndian32() { - $output = new OutputStream(4); + $output = new CodedOutputStream(4); $output->writeLittleEndian32(46); $this->assertSame(hex2bin('2E000000'), $output->getData()); } public function testWriteLittleEndian64() { - $output = new OutputStream(8); + $output = new CodedOutputStream(8); $output->writeLittleEndian64(47); $this->assertSame(hex2bin('2F00000000000000'), $output->getData()); } diff --git a/php/tests/test_base.php b/php/tests/test_base.php index 67048f4c..dc5e73f5 100644 --- a/php/tests/test_base.php +++ b/php/tests/test_base.php @@ -19,6 +19,8 @@ class TestBase extends PHPUnit_Framework_TestCase public function expectFields(TestMessage $m) { + $this->assertSame(-42, $m->getOptionalInt32()); + $this->assertSame(42, $m->getOptionalUint32()); $this->assertSame(-44, $m->getOptionalSint32()); $this->assertSame(46, $m->getOptionalFixed32()); $this->assertSame(-46, $m->getOptionalSfixed32()); @@ -27,6 +29,7 @@ class TestBase extends PHPUnit_Framework_TestCase $this->assertSame(true, $m->getOptionalBool()); $this->assertSame('a', $m->getOptionalString()); $this->assertSame('b', $m->getOptionalBytes()); + $this->assertSame(TestEnum::ONE, $m->getOptionalEnum()); $this->assertSame(33, $m->getOptionalMessage()->getA()); if (PHP_INT_SIZE == 4) { $this->assertSame('-43', $m->getOptionalInt64()); diff --git a/php/tests/undefined_test.php b/php/tests/undefined_test.php new file mode 100644 index 00000000..dc6b7086 --- /dev/null +++ b/php/tests/undefined_test.php @@ -0,0 +1,920 @@ +assertSame(3, count($arr)); + + unset($arr[1]); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRemoveEmptyFail() + { + $arr = new RepeatedField(GPBType::INT32); + + unset($arr[0]); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[] = 0; + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[] = 0; + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testSetNonExistedOffsetFail() + { + $arr = new RepeatedField(GPBType::INT32); + $arr[0] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalInt32(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalInt32('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalUint32(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalUint32('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalInt64(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalInt64('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64FieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalUint64(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64FieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalUint64('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testFloatFieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalFloat(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testFloatFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalFloat('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleFieldInvalidTypeFail() + { + $m = new TestMessage(); + $m->setOptionalDouble(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalDouble('abc'); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolFieldInvalidStringFail() + { + $m = new TestMessage(); + $m->setOptionalBool(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringFieldInvalidUTF8Fail() + { + $m = new TestMessage(); + $hex = hex2bin("ff"); + $m->setOptionalString($hex); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setOptionalMessage($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageFieldWrongClassFail() + { + $m = new TestMessage(); + $m->setOptionalMessage(new TestMessage()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setRepeatedInt32($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongObjectFail() + { + $m = new TestMessage(); + $m->setRepeatedInt32($m); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongRepeatedTypeFail() + { + $m = new TestMessage(); + + $repeated_int32 = new RepeatedField(GPBType::UINT32); + $m->setRepeatedInt32($repeated_int32); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testRepeatedFieldWrongRepeatedMessageClassFail() + { + $m = new TestMessage(); + + $repeated_message = new RepeatedField(GPBType::MESSAGE, + TestMessage::class); + $m->setRepeatedMessage($repeated_message); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongTypeFail() + { + $m = new TestMessage(); + $a = 1; + $m->setMapInt32Int32($a); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongObjectFail() + { + $m = new TestMessage(); + $m->setMapInt32Int32($m); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongRepeatedTypeFail() + { + $m = new TestMessage(); + + $map_uint32_uint32 = new MapField(GPBType::UINT32, GPBType::UINT32); + $m->setMapInt32Int32($map_uint32_uint32); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMapFieldWrongRepeatedMessageClassFail() + { + $m = new TestMessage(); + + $map_int32_message = new MapField(GPBType::INT32, + GPBType::MESSAGE, + TestMessage::class); + $m->setMapInt32Message($map_int32_message); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageMergeFromInvalidTypeFail() + { + $m = new TestMessage(); + $n = new TestMessage_Sub(); + $m->mergeFrom($n); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetStringKeyFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetStringValueFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetMessageKeyFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt32SetMessageValueFail() + { + $arr = new MapField(GPBType::INT32, GPBType::INT32); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetStringKeyFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetStringValueFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetMessageKeyFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint32SetMessageValueFail() + { + $arr = new MapField(GPBType::UINT32, GPBType::UINT32); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetStringKeyFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetStringValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetMessageKeyFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInt64SetMessageValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::INT64); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetStringKeyFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr['abc'] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetStringValueFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetMessageKeyFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[new TestMessage_Sub()] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testUint64SetMessageValueFail() + { + $arr = new MapField(GPBType::UINT64, GPBType::UINT64); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleSetStringValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testDoubleSetMessageValueFail() + { + $arr = new MapField(GPBType::INT64, GPBType::DOUBLE); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolSetMessageKeyFail() + { + $arr = new MapField(GPBType::BOOL, GPBType::BOOL); + $arr[new TestMessage_Sub()] = true; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testBoolSetMessageValueFail() + { + $arr = new MapField(GPBType::BOOL, GPBType::BOOL); + $arr[true] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetInvalidUTF8KeyFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr[hex2bin("ff")] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetInvalidUTF8ValueFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr['abc'] = hex2bin("ff"); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetMessageKeyFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr[new TestMessage_Sub()] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testStringSetMessageValueFail() + { + $arr = new MapField(GPBType::STRING, GPBType::STRING); + $arr['abc'] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetIntValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = 0; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetStringValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = 'abc'; + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetOtherMessageValueFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $arr[0] = new TestMessage_Sub(); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testMessageSetNullFail() + { + $arr = + new MapField(GPBType::INT32, GPBType::MESSAGE, TestMessage::class); + $null = NULL; + $arr[0] = $null; + } + +} diff --git a/tests.sh b/tests.sh index 5d11c857..b40f0c5d 100755 --- a/tests.sh +++ b/tests.sh @@ -397,27 +397,30 @@ build_php5.5() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } build_php5.5_c() { use_php 5.5 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit - cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c + pushd php/tests + /bin/bash ./test.sh popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_c + # popd } build_php5.5_zts_c() { use_php_zts 5.5 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_zts_c + # popd } build_php5.6() { @@ -429,8 +432,7 @@ build_php5.6() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } @@ -438,18 +440,20 @@ build_php5.6_c() { use_php 5.6 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php5.6_zts_c() { use_php_zts 5.6 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back + # pushd conformance + # make test_php_zts_c + # popd } build_php5.6_mac() { @@ -471,9 +475,10 @@ build_php5.6_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php7.0() { @@ -485,8 +490,7 @@ build_php7.0() { phpunit popd pushd conformance - # TODO(teboring): Add it back - # make test_php + make test_php popd } @@ -494,18 +498,20 @@ build_php7.0_c() { use_php 7.0 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php7.0_zts_c() { use_php_zts 7.0 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance - # make test_php_c - popd + # TODO(teboring): Add it back. + # pushd conformance + # make test_php_zts_c + # popd } build_php7.0_mac() { @@ -527,9 +533,10 @@ build_php7.0_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - pushd conformance + # TODO(teboring): Add it back + # pushd conformance # make test_php_c - popd + # popd } build_php_compatibility() { -- cgit v1.2.3 From 3a0382e9076bdbb7c764080c92f3c2324d852be7 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 13 Jul 2017 11:21:03 -0700 Subject: Add map iterator for c extension (#3350) --- php/ext/google/protobuf/map.c | 93 ++++++++++++++++++++++- php/ext/google/protobuf/protobuf.c | 2 + php/ext/google/protobuf/protobuf.h | 15 +++- php/ext/google/protobuf/storage.c | 13 ++++ php/src/Google/Protobuf/Internal/MapFieldIter.php | 5 +- php/tests/map_field_test.php | 34 +++++++++ 6 files changed, 157 insertions(+), 5 deletions(-) (limited to 'php/src/Google/Protobuf') diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c index a5d48446..4a524864 100644 --- a/php/ext/google/protobuf/map.c +++ b/php/ext/google/protobuf/map.c @@ -143,6 +143,7 @@ static zend_function_entry map_field_methods[] = { PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC) PHP_ME(MapField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(MapField, count, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(MapField, getIterator, arginfo_void, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -156,7 +157,10 @@ static void map_field_write_dimension(zval *object, zval *key, // ----------------------------------------------------------------------------- zend_class_entry* map_field_type; +zend_class_entry* map_field_iter_type; + zend_object_handlers* map_field_handlers; +zend_object_handlers* map_field_iter_handlers; static void map_begin_internal(Map *map, MapIter *iter) { iter->self = map; @@ -231,8 +235,8 @@ PHP_PROTO_OBJECT_CREATE_END(Map, map_field) // Init class entry. PHP_PROTO_INIT_CLASS_START("Google\\Protobuf\\Internal\\MapField", Map, map_field) -zend_class_implements(map_field_type TSRMLS_CC, 2, spl_ce_ArrayAccess, - spl_ce_Countable); +zend_class_implements(map_field_type TSRMLS_CC, 3, spl_ce_ArrayAccess, + zend_ce_aggregate, spl_ce_Countable); map_field_handlers->write_dimension = map_field_write_dimension; map_field_handlers->get_gc = map_field_get_gc; PHP_PROTO_INIT_CLASS_END @@ -444,6 +448,15 @@ PHP_METHOD(MapField, count) { RETURN_LONG(upb_strtable_count(&intern->table)); } +PHP_METHOD(MapField, getIterator) { + CREATE_OBJ_ON_ALLOCATED_ZVAL_PTR(return_value, + map_field_iter_type); + + Map *intern = UNBOX(Map, getThis()); + MapIter *iter = UNBOX(MapIter, return_value); + map_begin(getThis(), iter TSRMLS_CC); +} + // ----------------------------------------------------------------------------- // Map Iterator // ----------------------------------------------------------------------------- @@ -470,3 +483,79 @@ upb_value map_iter_value(MapIter *iter, int *len) { *len = native_slot_size(iter->self->value_type); return upb_strtable_iter_value(&iter->it); } + +// ----------------------------------------------------------------------------- +// MapFieldIter methods +// ----------------------------------------------------------------------------- +static zend_function_entry map_field_iter_methods[] = { + PHP_ME(MapFieldIter, rewind, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(MapFieldIter, current, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(MapFieldIter, key, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(MapFieldIter, next, arginfo_void, ZEND_ACC_PUBLIC) + PHP_ME(MapFieldIter, valid, arginfo_void, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +// ----------------------------------------------------------------------------- +// MapFieldIter creation/desctruction +// ----------------------------------------------------------------------------- + +// Define object free method. +PHP_PROTO_OBJECT_FREE_START(MapIter, map_field_iter) +PHP_PROTO_OBJECT_FREE_END + +PHP_PROTO_OBJECT_DTOR_START(MapIter, map_field_iter) +PHP_PROTO_OBJECT_DTOR_END + +// Define object create method. +PHP_PROTO_OBJECT_CREATE_START(MapIter, map_field_iter) +intern->self = NULL; +PHP_PROTO_OBJECT_CREATE_END(MapIter, map_field_iter) + +// Init class entry. +PHP_PROTO_INIT_CLASS_START("Google\\Protobuf\\Internal\\MapFieldIter", + MapIter, map_field_iter) +zend_class_implements(map_field_iter_type TSRMLS_CC, 1, zend_ce_iterator); +PHP_PROTO_INIT_CLASS_END + +// ----------------------------------------------------------------------------- +// PHP MapFieldIter Methods +// ----------------------------------------------------------------------------- + +PHP_METHOD(MapFieldIter, rewind) { + MapIter *intern = UNBOX(MapIter, getThis()); + map_begin_internal(intern->self, intern); +} + +PHP_METHOD(MapFieldIter, current) { + MapIter *intern = UNBOX(MapIter, getThis()); + Map *map_field = intern->self; + + int value_length = 0; + upb_value value = map_iter_value(intern, &value_length); + + void* mem = upb_value_memory(&value); + native_slot_get_by_array(map_field->value_type, mem, + ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC); +} + +PHP_METHOD(MapFieldIter, key) { + MapIter *intern = UNBOX(MapIter, getThis()); + Map *map_field = intern->self; + + int key_length = 0; + const char* key = map_iter_key(intern, &key_length); + + native_slot_get_by_map_key(map_field->key_type, key, key_length, + ZVAL_PTR_TO_CACHED_PTR(return_value) TSRMLS_CC); +} + +PHP_METHOD(MapFieldIter, next) { + MapIter *intern = UNBOX(MapIter, getThis()); + map_next(intern); +} + +PHP_METHOD(MapFieldIter, valid) { + MapIter *intern = UNBOX(MapIter, getThis()); + RETURN_BOOL(!map_done(intern)); +} diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 6a848b27..5de9cfe9 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -189,6 +189,7 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) { static PHP_MINIT_FUNCTION(protobuf) { map_field_init(TSRMLS_C); + map_field_iter_init(TSRMLS_C); repeated_field_init(TSRMLS_C); repeated_field_iter_init(TSRMLS_C); gpb_type_init(TSRMLS_C); @@ -206,6 +207,7 @@ static PHP_MSHUTDOWN_FUNCTION(protobuf) { PEFREE(repeated_field_handlers); PEFREE(repeated_field_iter_handlers); PEFREE(map_field_handlers); + PEFREE(map_field_iter_handlers); return 0; } diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 406a09a5..684a9c50 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -373,6 +373,7 @@ struct MessageLayout; struct RepeatedField; struct RepeatedFieldIter; struct Map; +struct MapIter; struct Oneof; typedef struct DescriptorPool DescriptorPool; @@ -385,6 +386,7 @@ typedef struct MessageLayout MessageLayout; typedef struct RepeatedField RepeatedField; typedef struct RepeatedFieldIter RepeatedFieldIter; typedef struct Map Map; +typedef struct MapIter MapIter; typedef struct Oneof Oneof; // ----------------------------------------------------------------------------- @@ -400,6 +402,7 @@ void enum_descriptor_init(TSRMLS_D); void descriptor_pool_init(TSRMLS_D); void gpb_type_init(TSRMLS_D); void map_field_init(TSRMLS_D); +void map_field_iter_init(TSRMLS_D); void repeated_field_init(TSRMLS_D); void repeated_field_iter_init(TSRMLS_D); void util_init(TSRMLS_D); @@ -659,6 +662,7 @@ void native_slot_get_default(upb_fieldtype_t type, // ----------------------------------------------------------------------------- extern zend_object_handlers* map_field_handlers; +extern zend_object_handlers* map_field_iter_handlers; PHP_PROTO_WRAP_OBJECT_START(Map) upb_fieldtype_t key_type; @@ -667,10 +671,10 @@ PHP_PROTO_WRAP_OBJECT_START(Map) upb_strtable table; PHP_PROTO_WRAP_OBJECT_END -typedef struct { +PHP_PROTO_WRAP_OBJECT_START(MapIter) Map* self; upb_strtable_iter it; -} MapIter; +PHP_PROTO_WRAP_OBJECT_END void map_begin(zval* self, MapIter* iter TSRMLS_DC); void map_next(MapIter* iter); @@ -709,6 +713,13 @@ PHP_METHOD(MapField, offsetGet); PHP_METHOD(MapField, offsetSet); PHP_METHOD(MapField, offsetUnset); PHP_METHOD(MapField, count); +PHP_METHOD(MapField, getIterator); + +PHP_METHOD(MapFieldIter, rewind); +PHP_METHOD(MapFieldIter, current); +PHP_METHOD(MapFieldIter, key); +PHP_METHOD(MapFieldIter, next); +PHP_METHOD(MapFieldIter, valid); // ----------------------------------------------------------------------------- // Repeated Field. diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 6318f88c..29a3db86 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -355,6 +355,19 @@ void native_slot_get_by_array(upb_fieldtype_t type, const void* memory, } } +void native_slot_get_by_map_key(upb_fieldtype_t type, const void* memory, + int length, CACHED_VALUE* cache TSRMLS_DC) { + switch (type) { + case UPB_TYPE_STRING: + case UPB_TYPE_BYTES: { + PHP_PROTO_ZVAL_STRINGL(CACHED_PTR_TO_ZVAL_PTR(cache), memory, length, 1); + return; + } + default: + native_slot_get(type, memory, cache TSRMLS_CC); + } +} + void native_slot_get_default(upb_fieldtype_t type, CACHED_VALUE* cache TSRMLS_DC) { switch (type) { diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php index cb707955..88e6c8b2 100644 --- a/php/src/Google/Protobuf/Internal/MapFieldIter.php +++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php @@ -91,9 +91,12 @@ class MapFieldIter implements \Iterator public function key() { $key = key($this->container); - // PHP associative array stores bool as integer for key. if ($this->key_type === GPBType::BOOL) { + // PHP associative array stores bool as integer for key. return boolval($key); + } elseif ($this->key_type === GPBType::STRING) { + // PHP associative array stores int string as int for key. + return strval($key); } else { return $key; } diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php index c5d21264..120b1bde 100644 --- a/php/tests/map_field_test.php +++ b/php/tests/map_field_test.php @@ -56,6 +56,23 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { unset($arr['3.1']); unset($arr[MAX_INT32_STRING]); $this->assertEquals(0, count($arr)); + + // Test foreach. + $arr = new MapField(GPBType::INT32, GPBType::INT32); + for ($i = 0; $i < 3; $i++) { + $arr[$i] = $i; + } + $i = 0; + $arr_test = []; + foreach ($arr as $key => $val) { + $this->assertSame($key, $val); + $arr_test[] = $key; + $i++; + } + $this->assertTrue(isset($arr_test[0])); + $this->assertTrue(isset($arr_test[1])); + $this->assertTrue(isset($arr_test[2])); + $this->assertSame(3, $i); } ######################################################### @@ -366,6 +383,23 @@ class MapFieldTest extends PHPUnit_Framework_TestCase { $this->assertEquals(1, count($arr)); unset($arr[True]); $this->assertEquals(0, count($arr)); + + // Test foreach. + $arr = new MapField(GPBType::STRING, GPBType::STRING); + for ($i = 0; $i < 3; $i++) { + $arr[$i] = $i; + } + $i = 0; + $arr_test = []; + foreach ($arr as $key => $val) { + $this->assertSame($key, $val); + $arr_test[] = $key; + $i++; + } + $this->assertTrue(isset($arr_test['0'])); + $this->assertTrue(isset($arr_test['1'])); + $this->assertTrue(isset($arr_test['2'])); + $this->assertSame(3, $i); } ######################################################### -- cgit v1.2.3 From 324b20a49170cb38d15ef243bc044026adb54ae1 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 17 Jul 2017 09:14:46 -0700 Subject: remove pass by reference for php setters (#3344) * remove pass by reference for php setters * comments out memory leak test --- .../Google/Protobuf/Internal/DescriptorProto.php | 18 +++++------ .../Protobuf/Internal/EnumDescriptorProto.php | 4 +-- php/src/Google/Protobuf/Internal/EnumOptions.php | 2 +- .../Protobuf/Internal/EnumValueDescriptorProto.php | 2 +- .../Google/Protobuf/Internal/EnumValueOptions.php | 2 +- .../Protobuf/Internal/FieldDescriptorProto.php | 2 +- php/src/Google/Protobuf/Internal/FieldOptions.php | 2 +- .../Protobuf/Internal/FileDescriptorProto.php | 18 +++++------ .../Google/Protobuf/Internal/FileDescriptorSet.php | 2 +- php/src/Google/Protobuf/Internal/FileOptions.php | 2 +- .../Google/Protobuf/Internal/GeneratedCodeInfo.php | 2 +- .../Internal/GeneratedCodeInfo_Annotation.php | 2 +- .../Google/Protobuf/Internal/MessageOptions.php | 2 +- .../Protobuf/Internal/MethodDescriptorProto.php | 2 +- php/src/Google/Protobuf/Internal/MethodOptions.php | 2 +- .../Protobuf/Internal/OneofDescriptorProto.php | 2 +- php/src/Google/Protobuf/Internal/OneofOptions.php | 2 +- .../Protobuf/Internal/ServiceDescriptorProto.php | 4 +-- .../Google/Protobuf/Internal/ServiceOptions.php | 2 +- .../Google/Protobuf/Internal/SourceCodeInfo.php | 2 +- .../Protobuf/Internal/SourceCodeInfo_Location.php | 6 ++-- .../Protobuf/Internal/UninterpretedOption.php | 2 +- php/tests/array_test.php | 36 ++++++++++++---------- src/google/protobuf/compiler/php/php_generator.cc | 7 ++--- 24 files changed, 63 insertions(+), 64 deletions(-) (limited to 'php/src/Google/Protobuf') diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index 0fdaecfc..3f975b8a 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -119,7 +119,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setField(&$var) + public function setField($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->field = $arr; @@ -147,7 +147,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setExtension(&$var) + public function setExtension($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $arr; @@ -175,7 +175,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setNestedType(&$var) + public function setNestedType($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->nested_type = $arr; @@ -203,7 +203,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setEnumType(&$var) + public function setEnumType($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $arr; @@ -231,7 +231,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\DescriptorProto_ExtensionRange[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setExtensionRange(&$var) + public function setExtensionRange($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class); $this->extension_range = $arr; @@ -259,7 +259,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\OneofDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setOneofDecl(&$var) + public function setOneofDecl($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); $this->oneof_decl = $arr; @@ -287,7 +287,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\MessageOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); $this->options = $var; @@ -315,7 +315,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\DescriptorProto_ReservedRange[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setReservedRange(&$var) + public function setReservedRange($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class); $this->reserved_range = $arr; @@ -349,7 +349,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message * @param string[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setReservedName(&$var) + public function setReservedName($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->reserved_name = $arr; diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index 6cdaf2df..adc21fc6 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -81,7 +81,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\EnumValueDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setValue(&$var) + public function setValue($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); $this->value = $arr; @@ -109,7 +109,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\EnumOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index 3c3a9e22..6067d5a0 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -137,7 +137,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 89d6707f..b761fbcf 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -109,7 +109,7 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\EnumValueOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index 3b5c58e4..b7bcd237 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -95,7 +95,7 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index ae61be47..fbe4e1bf 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -418,7 +418,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FieldOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 157c0f82..593536ff 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -404,7 +404,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index 3b1567d1..c61cf917 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -187,7 +187,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param string[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setDependency(&$var) + public function setDependency($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->dependency = $arr; @@ -219,7 +219,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setPublicDependency(&$var) + public function setPublicDependency($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->public_dependency = $arr; @@ -253,7 +253,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setWeakDependency(&$var) + public function setWeakDependency($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->weak_dependency = $arr; @@ -285,7 +285,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\DescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setMessageType(&$var) + public function setMessageType($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); $this->message_type = $arr; @@ -313,7 +313,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\EnumDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setEnumType(&$var) + public function setEnumType($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); $this->enum_type = $arr; @@ -341,7 +341,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\ServiceDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setService(&$var) + public function setService($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); $this->service = $arr; @@ -369,7 +369,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FieldDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setExtension(&$var) + public function setExtension($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); $this->extension = $arr; @@ -397,7 +397,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FileOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); $this->options = $var; @@ -435,7 +435,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\SourceCodeInfo $var * @return $this */ - public function setSourceCodeInfo(&$var) + public function setSourceCodeInfo($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); $this->source_code_info = $var; diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php index 591e2a81..2b6ed0ab 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -44,7 +44,7 @@ class FileDescriptorSet extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\FileDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setFile(&$var) + public function setFile($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); $this->file = $arr; diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 2202102b..200ee9de 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -812,7 +812,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php index 35b47526..a69bef85 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php @@ -54,7 +54,7 @@ class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setAnnotation(&$var) + public function setAnnotation($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class); $this->annotation = $arr; diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php index c2e22e89..86c9f629 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php @@ -74,7 +74,7 @@ class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setPath(&$var) + public function setPath($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->path = $arr; diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index 3677ca38..0a0bfb2d 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -311,7 +311,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index 69c25b69..95b614f3 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -165,7 +165,7 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\MethodOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index 5b2db776..17a8b453 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -128,7 +128,7 @@ class MethodOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index 0d4f3bdc..255ff572 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -76,7 +76,7 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\OneofOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php index aa8c934c..fb8c3bfa 100644 --- a/php/src/Google/Protobuf/Internal/OneofOptions.php +++ b/php/src/Google/Protobuf/Internal/OneofOptions.php @@ -47,7 +47,7 @@ class OneofOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index 963cd650..e10bd533 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -81,7 +81,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\MethodDescriptorProto[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setMethod(&$var) + public function setMethod($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class); $this->method = $arr; @@ -109,7 +109,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\ServiceOptions $var * @return $this */ - public function setOptions(&$var) + public function setOptions($var) { GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class); $this->options = $var; diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php index ea649865..a2319170 100644 --- a/php/src/Google/Protobuf/Internal/ServiceOptions.php +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -95,7 +95,7 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setUninterpretedOption(&$var) + public function setUninterpretedOption($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); $this->uninterpreted_option = $arr; diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php index 65530586..d21fe8eb 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php @@ -170,7 +170,7 @@ class SourceCodeInfo extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\SourceCodeInfo_Location[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setLocation(&$var) + public function setLocation($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class); $this->location = $arr; diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php index b33013b8..210bf073 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php @@ -170,7 +170,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setPath(&$var) + public function setPath($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->path = $arr; @@ -210,7 +210,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message * @param int[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setSpan(&$var) + public function setSpan($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); $this->span = $arr; @@ -368,7 +368,7 @@ class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message * @param string[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setLeadingDetachedComments(&$var) + public function setLeadingDetachedComments($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->leading_detached_comments = $arr; diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php index a4fab343..daa730d0 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -81,7 +81,7 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message * @param \Google\Protobuf\Internal\UninterpretedOption_NamePart[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setName(&$var) + public function setName($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class); $this->name = $arr; diff --git a/php/tests/array_test.php b/php/tests/array_test.php index 271389ba..e57f0a7e 100644 --- a/php/tests/array_test.php +++ b/php/tests/array_test.php @@ -521,21 +521,23 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase # Test memory leak ######################################################### - public function testCycleLeak() - { - $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); - $arr[] = new TestMessage; - $arr[0]->SetRepeatedRecursive($arr); - - // Clean up memory before test. - gc_collect_cycles(); - $start = memory_get_usage(); - unset($arr); - - // Explicitly trigger garbage collection. - gc_collect_cycles(); - - $end = memory_get_usage(); - $this->assertLessThan($start, $end); - } + // COMMENTED OUT BY @bshaffer + // @see https://github.com/google/protobuf/pull/3344#issuecomment-315162761 + // public function testCycleLeak() + // { + // $arr = new RepeatedField(GPBType::MESSAGE, TestMessage::class); + // $arr[] = new TestMessage; + // $arr[0]->SetRepeatedRecursive($arr); + + // // Clean up memory before test. + // gc_collect_cycles(); + // $start = memory_get_usage(); + // unset($arr); + + // // Explicitly trigger garbage collection. + // gc_collect_cycles(); + + // $end = memory_get_usage(); + // $this->assertLessThan($start, $end); + // } } diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index e20b89ae..17d8ebad 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -534,12 +534,9 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, // Generate setter. GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter); printer->Print( - "public function set^camel_name^(^var^)\n" + "public function set^camel_name^($var)\n" "{\n", - "camel_name", UnderscoresToCamelCase(field->name(), true), - "var", (field->is_repeated() || - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - "&$var": "$var"); + "camel_name", UnderscoresToCamelCase(field->name(), true)); Indent(printer); -- cgit v1.2.3 From 9e745f771b2a0cde271b8283753c19014124ac95 Mon Sep 17 00:00:00 2001 From: Matt A Date: Tue, 18 Jul 2017 10:45:18 -0400 Subject: Support PHP generic services (#3269) * Add php_generic_services option * Generate PHP generic services * Respect namespaces for generated PHP services * Test PHP generated services * Rename PHP generator service method doc comment function * Correct phpdoc service method case * Test namespaced PHP generic services * Always use the FQCN for PHP generic service input/output * Add generated_service_test to php test.sh * Add php service test protos to CI * Add php service files to php_EXTRA_DIST * Use Interface suffix for php generic services --- Makefile.am | 3 + .../src/Google.Protobuf/Reflection/Descriptor.cs | 149 ++++++----- php/phpunit.xml | 1 + .../Google/Protobuf/Internal/Descriptor.php | 1 + php/src/Google/Protobuf/Internal/FileOptions.php | 33 +++ php/tests/generated_service_test.php | 110 ++++++++ php/tests/proto/test_service.proto | 18 ++ php/tests/proto/test_service_namespace.proto | 13 + php/tests/test.sh | 2 +- src/google/protobuf/compiler/php/php_generator.cc | 140 +++++++++- src/google/protobuf/descriptor.pb.cc | 289 +++++++++++++-------- src/google/protobuf/descriptor.pb.h | 52 +++- src/google/protobuf/descriptor.proto | 1 + tests.sh | 2 +- 14 files changed, 623 insertions(+), 191 deletions(-) create mode 100644 php/tests/generated_service_test.php create mode 100644 php/tests/proto/test_service.proto create mode 100644 php/tests/proto/test_service_namespace.proto (limited to 'php/src/Google/Protobuf') diff --git a/Makefile.am b/Makefile.am index f613c0f8..7ffb202e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -662,6 +662,7 @@ php_EXTRA_DIST= \ php/tests/gdb_test.sh \ php/tests/generated_class_test.php \ php/tests/generated_phpdoc_test.php \ + php/tests/generated_service_test.php \ php/tests/map_field_test.php \ php/tests/memory_leak_test.php \ php/tests/php_implementation_test.php \ @@ -672,6 +673,8 @@ php_EXTRA_DIST= \ php/tests/proto/test_no_namespace.proto \ php/tests/proto/test_php_namespace.proto \ php/tests/proto/test_prefix.proto \ + php/tests/proto/test_service.proto \ + php/tests/proto/test_service_namespace.proto \ php/tests/test.sh \ php/tests/test_base.php \ php/tests/test_util.php \ diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index c3517802..6c605f3c 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection { "ASgJEhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5n", "b29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFt", "aW5nGAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVm", - "YWxzZSLLBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", + "YWxzZSLwBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", "FGphdmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVf", "ZmlsZXMYCiABKAg6BWZhbHNlEikKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2Fu", "ZF9oYXNoGBQgASgIQgIYARIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg", @@ -88,65 +88,66 @@ namespace Google.Protobuf.Reflection { "dG9idWYuRmlsZU9wdGlvbnMuT3B0aW1pemVNb2RlOgVTUEVFRBISCgpnb19w", "YWNrYWdlGAsgASgJEiIKE2NjX2dlbmVyaWNfc2VydmljZXMYECABKAg6BWZh", "bHNlEiQKFWphdmFfZ2VuZXJpY19zZXJ2aWNlcxgRIAEoCDoFZmFsc2USIgoT", - "cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl", - "ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs", - "c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz", - "cGFjZRglIAEoCRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSGAoQcGhwX2NsYXNz", - "X3ByZWZpeBgoIAEoCRIVCg1waHBfbmFtZXNwYWNlGCkgASgJEkMKFHVuaW50", - "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", - "dGVycHJldGVkT3B0aW9uIjoKDE9wdGltaXplTW9kZRIJCgVTUEVFRBABEg0K", - "CUNPREVfU0laRRACEhAKDExJVEVfUlVOVElNRRADKgkI6AcQgICAgAJKBAgm", - "ECci8gEKDk1lc3NhZ2VPcHRpb25zEiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9y", - "bWF0GAEgASgIOgVmYWxzZRIuCh9ub19zdGFuZGFyZF9kZXNjcmlwdG9yX2Fj", - "Y2Vzc29yGAIgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz", - "ZRIRCgltYXBfZW50cnkYByABKAgSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y", - "5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24q", - "CQjoBxCAgICAAkoECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0", - "eXBlGAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlw", - "ZToGU1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5n", - "b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFM", - "EhMKBGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh", - "bHNlEhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0", - "aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0", - "aW9uIi8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdf", - "UElFQ0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5H", - "EAESDQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9w", - "dGlvbnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xl", - "LnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoL", - "RW51bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRl", - "ZBgDIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL", - "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCA", - "gICAAkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQY", - "ASABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIk", + "cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USIwoUcGhwX2dlbmVy", + "aWNfc2VydmljZXMYEyABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYFyABKAg6", + "BWZhbHNlEh8KEGNjX2VuYWJsZV9hcmVuYXMYHyABKAg6BWZhbHNlEhkKEW9i", + "amNfY2xhc3NfcHJlZml4GCQgASgJEhgKEGNzaGFycF9uYW1lc3BhY2UYJSAB", + "KAkSFAoMc3dpZnRfcHJlZml4GCcgASgJEhgKEHBocF9jbGFzc19wcmVmaXgY", + "KCABKAkSFQoNcGhwX25hbWVzcGFjZRgpIAEoCRJDChR1bmludGVycHJldGVk", + "X29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRl", + "ZE9wdGlvbiI6CgxPcHRpbWl6ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJ", + "WkUQAhIQCgxMSVRFX1JVTlRJTUUQAyoJCOgHEICAgIACSgQIJhAnIvIBCg5N", + "ZXNzYWdlT3B0aW9ucxImChdtZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEo", + "CDoFZmFsc2USLgofbm9fc3RhbmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgC", + "IAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFw", + "X2VudHJ5GAcgASgIEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIk", "Lmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICA", - "gAIiewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFs", - "c2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy", - "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0", - "aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVt", - "cG90ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RP", - "cHRpb25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04S", - "QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv", - "YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIX", - "ChNJREVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAES", - "DgoKSURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRP", - "cHRpb24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy", - "cHJldGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyAB", - "KAkSGgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2lu", - "dF92YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5n", - "X3ZhbHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1l", - "UGFydBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigI", - "ItUBCg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2ds", - "ZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRp", - "b24SEAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVh", - "ZGluZ19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEo", - "CRIhChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5l", - "cmF0ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnBy", - "b3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3Rh", - "dGlvbhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRIN", - "CgViZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCjAEKE2NvbS5nb29nbGUucHJv", - "dG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVo+Z2l0aHViLmNvbS9nb2xhbmcv", - "cHJvdG9idWYvcHJvdG9jLWdlbi1nby9kZXNjcmlwdG9yO2Rlc2NyaXB0b3Ki", - "AgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg==")); + "gAJKBAgIEAlKBAgJEAoingMKDEZpZWxkT3B0aW9ucxI6CgVjdHlwZRgBIAEo", + "DjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuQ1R5cGU6BlNUUklO", + "RxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYgASgOMiQuZ29vZ2xlLnBy", + "b3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpTX05PUk1BTBITCgRsYXp5", + "GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRITCgR3", + "ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByAD", + "KAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiIvCgVD", + "VHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoMU1RSSU5HX1BJRUNFEAIi", + "NQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpTX1NUUklORxABEg0KCUpT", + "X05VTUJFUhACKgkI6AcQgICAgAJKBAgEEAUiXgoMT25lb2ZPcHRpb25zEkMK", + "FHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1", + "Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIikwEKC0VudW1PcHRp", + "b25zEhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyABKAg6", + "BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2ds", + "ZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAJKBAgF", + "EAYifQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVm", + "YWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUu", + "cHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNl", + "cnZpY2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVu", + "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V", + "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIirQIKDU1ldGhvZE9wdGlv", + "bnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFsc2USXwoRaWRlbXBvdGVuY3lf", + "bGV2ZWwYIiABKA4yLy5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucy5J", + "ZGVtcG90ZW5jeUxldmVsOhNJREVNUE9URU5DWV9VTktOT1dOEkMKFHVuaW50", + "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", + "dGVycHJldGVkT3B0aW9uIlAKEElkZW1wb3RlbmN5TGV2ZWwSFwoTSURFTVBP", + "VEVOQ1lfVU5LTk9XThAAEhMKD05PX1NJREVfRUZGRUNUUxABEg4KCklERU1Q", + "T1RFTlQQAioJCOgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsK", + "BG5hbWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w", + "dGlvbi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBv", + "c2l0aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUY", + "BSABKAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgH", + "IAEoDBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJ", + "bmFtZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291", + "cmNlQ29kZUluZm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9i", + "dWYuU291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBh", + "dGgYASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29t", + "bWVudHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVh", + "ZGluZ19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29k", + "ZUluZm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5H", + "ZW5lcmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoE", + "cGF0aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4Y", + "AyABKAUSCwoDZW5kGAQgASgFQowBChNjb20uZ29vZ2xlLnByb3RvYnVmQhBE", + "ZXNjcmlwdG9yUHJvdG9zSAFaPmdpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVm", + "L3Byb3RvYy1nZW4tZ28vZGVzY3JpcHRvcjtkZXNjcmlwdG9yogIDR1BCqgIa", + "R29vZ2xlLlByb3RvYnVmLlJlZmxlY3Rpb24=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -160,7 +161,7 @@ namespace Google.Protobuf.Reflection { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null), @@ -2804,6 +2805,7 @@ namespace Google.Protobuf.Reflection { ccGenericServices_ = other.ccGenericServices_; javaGenericServices_ = other.javaGenericServices_; pyGenericServices_ = other.pyGenericServices_; + phpGenericServices_ = other.phpGenericServices_; deprecated_ = other.deprecated_; ccEnableArenas_ = other.ccEnableArenas_; objcClassPrefix_ = other.objcClassPrefix_; @@ -2981,6 +2983,17 @@ namespace Google.Protobuf.Reflection { } } + /// Field number for the "php_generic_services" field. + public const int PhpGenericServicesFieldNumber = 19; + private bool phpGenericServices_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool PhpGenericServices { + get { return phpGenericServices_; } + set { + phpGenericServices_ = value; + } + } + /// Field number for the "deprecated" field. public const int DeprecatedFieldNumber = 23; private bool deprecated_; @@ -3126,6 +3139,7 @@ namespace Google.Protobuf.Reflection { if (CcGenericServices != other.CcGenericServices) return false; if (JavaGenericServices != other.JavaGenericServices) return false; if (PyGenericServices != other.PyGenericServices) return false; + if (PhpGenericServices != other.PhpGenericServices) return false; if (Deprecated != other.Deprecated) return false; if (CcEnableArenas != other.CcEnableArenas) return false; if (ObjcClassPrefix != other.ObjcClassPrefix) return false; @@ -3150,6 +3164,7 @@ namespace Google.Protobuf.Reflection { if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode(); + if (PhpGenericServices != false) hash ^= PhpGenericServices.GetHashCode(); if (Deprecated != false) hash ^= Deprecated.GetHashCode(); if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); @@ -3200,6 +3215,10 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(144, 1); output.WriteBool(PyGenericServices); } + if (PhpGenericServices != false) { + output.WriteRawTag(152, 1); + output.WriteBool(PhpGenericServices); + } if (JavaGenerateEqualsAndHash != false) { output.WriteRawTag(160, 1); output.WriteBool(JavaGenerateEqualsAndHash); @@ -3272,6 +3291,9 @@ namespace Google.Protobuf.Reflection { if (PyGenericServices != false) { size += 2 + 1; } + if (PhpGenericServices != false) { + size += 2 + 1; + } if (Deprecated != false) { size += 2 + 1; } @@ -3332,6 +3354,9 @@ namespace Google.Protobuf.Reflection { if (other.PyGenericServices != false) { PyGenericServices = other.PyGenericServices; } + if (other.PhpGenericServices != false) { + PhpGenericServices = other.PhpGenericServices; + } if (other.Deprecated != false) { Deprecated = other.Deprecated; } @@ -3396,6 +3421,10 @@ namespace Google.Protobuf.Reflection { PyGenericServices = input.ReadBool(); break; } + case 152: { + PhpGenericServices = input.ReadBool(); + break; + } case 160: { JavaGenerateEqualsAndHash = input.ReadBool(); break; diff --git a/php/phpunit.xml b/php/phpunit.xml index 7cb1e2a3..637467be 100644 --- a/php/phpunit.xml +++ b/php/phpunit.xml @@ -10,6 +10,7 @@ tests/generated_phpdoc_test.php tests/map_field_test.php tests/well_known_test.php + tests/generated_service_test.php diff --git a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php index 636a0ad4..1e3c745e 100644 --- a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php +++ b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php @@ -139,6 +139,7 @@ class Descriptor ->optional('cc_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 16) ->optional('java_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 17) ->optional('py_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 18) + ->optional('php_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 19) ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 23) ->optional('cc_enable_arenas', \Google\Protobuf\Internal\GPBType::BOOL, 31) ->optional('objc_class_prefix', \Google\Protobuf\Internal\GPBType::STRING, 36) diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 200ee9de..c7972ca7 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -109,6 +109,11 @@ class FileOptions extends \Google\Protobuf\Internal\Message */ private $py_generic_services = false; private $has_py_generic_services = false; + /** + * Generated from protobuf field optional bool php_generic_services = 19 [default = false]; + */ + private $php_generic_services = false; + private $has_php_generic_services = false; /** * Is this file deprecated? * Depending on the target platform, this can emit Deprecated annotations @@ -548,6 +553,34 @@ class FileOptions extends \Google\Protobuf\Internal\Message return $this->has_py_generic_services; } + /** + * Generated from protobuf field optional bool php_generic_services = 19 [default = false]; + * @return bool + */ + public function getPhpGenericServices() + { + return $this->php_generic_services; + } + + /** + * Generated from protobuf field optional bool php_generic_services = 19 [default = false]; + * @param bool $var + * @return $this + */ + public function setPhpGenericServices($var) + { + GPBUtil::checkBool($var); + $this->php_generic_services = $var; + $this->has_php_generic_services = true; + + return $this; + } + + public function hasPhpGenericServices() + { + return $this->has_php_generic_services; + } + /** * Is this file deprecated? * Depending on the target platform, this can emit Deprecated annotations diff --git a/php/tests/generated_service_test.php b/php/tests/generated_service_test.php new file mode 100644 index 00000000..5407db9a --- /dev/null +++ b/php/tests/generated_service_test.php @@ -0,0 +1,110 @@ +serviceClass = new ReflectionClass('Foo\GreeterInterface'); + + $this->namespacedServiceClass = new ReflectionClass('Bar\OtherGreeterInterface'); + } + + public function testIsInterface() + { + $this->assertTrue($this->serviceClass->isInterface()); + } + + public function testPhpDocForClass() + { + $this->assertContains('foo.Greeter', $this->serviceClass->getDocComment()); + } + + public function testPhpDocForNamespacedClass() + { + $this->assertContains('foo.OtherGreeter', $this->namespacedServiceClass->getDocComment()); + } + + public function testServiceMethodsAreGenerated() + { + $this->assertCount(count($this->methodNames), $this->serviceClass->getMethods()); + foreach ($this->methodNames as $methodName) { + $this->assertTrue($this->serviceClass->hasMethod($methodName)); + } + } + + public function testPhpDocForServiceMethod() + { + foreach ($this->methodNames as $methodName) { + $docComment = $this->serviceClass->getMethod($methodName)->getDocComment(); + $this->assertContains($methodName, $docComment); + $this->assertContains('@param \Foo\HelloRequest $request', $docComment); + $this->assertContains('@return \Foo\HelloReply', $docComment); + } + } + + public function testPhpDocForServiceMethodInNamespacedClass() + { + foreach ($this->methodNames as $methodName) { + $docComment = $this->namespacedServiceClass->getMethod($methodName)->getDocComment(); + $this->assertContains($methodName, $docComment); + $this->assertContains('@param \Foo\HelloRequest $request', $docComment); + $this->assertContains('@return \Foo\HelloReply', $docComment); + } + } + + public function testParamForServiceMethod() + { + foreach ($this->methodNames as $methodName) { + $method = $this->serviceClass->getMethod($methodName); + $this->assertCount(1, $method->getParameters()); + $param = $method->getParameters()[0]; + $this->assertFalse($param->isOptional()); + $this->assertSame('request', $param->getName()); + // ReflectionParameter::getType only exists in PHP 7+, so get the type from __toString + $this->assertContains('Foo\HelloRequest $request', (string) $param); + } + } + + public function testParamForServiceMethodInNamespacedClass() + { + foreach ($this->methodNames as $methodName) { + $method = $this->serviceClass->getMethod($methodName); + $this->assertCount(1, $method->getParameters()); + $param = $method->getParameters()[0]; + $this->assertFalse($param->isOptional()); + $this->assertSame('request', $param->getName()); + // ReflectionParameter::getType only exists in PHP 7+, so get the type from __toString + $this->assertContains('Foo\HelloRequest $request', (string) $param); + } + } +} diff --git a/php/tests/proto/test_service.proto b/php/tests/proto/test_service.proto new file mode 100644 index 00000000..a03dbc46 --- /dev/null +++ b/php/tests/proto/test_service.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package foo; + +option php_generic_services = true; + +service Greeter { + rpc SayHello (HelloRequest) returns (HelloReply) {} + rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} diff --git a/php/tests/proto/test_service_namespace.proto b/php/tests/proto/test_service_namespace.proto new file mode 100644 index 00000000..719aa484 --- /dev/null +++ b/php/tests/proto/test_service_namespace.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +import "proto/test_service.proto"; + +package foo; + +option php_generic_services = true; +option php_namespace = "Bar"; + +service OtherGreeter { + rpc SayHello (HelloRequest) returns (HelloReply) {} + rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} +} diff --git a/php/tests/test.sh b/php/tests/test.sh index 6c6edd56..b640c143 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -8,7 +8,7 @@ set -e phpize && ./configure CFLAGS='-g -O0' && make popd -tests=( array_test.php encode_decode_test.php generated_class_test.php generated_phpdoc_test.php map_field_test.php well_known_test.php ) +tests=( array_test.php encode_decode_test.php generated_class_test.php generated_phpdoc_test.php map_field_test.php well_known_test.php generated_service_test.php ) for t in "${tests[@]}" do diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 17d8ebad..60e6fce9 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -82,6 +82,10 @@ void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_, int is_descriptor); void GenerateEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); +void GenerateServiceDocComment(io::Printer* printer, + const ServiceDescriptor* service); +void GenerateServiceMethodDocComment(io::Printer* printer, + const MethodDescriptor* method); std::string RenameEmpty(const std::string& name) { if (name == "Empty") { @@ -139,17 +143,9 @@ std::string ClassNamePrefix(const string& classname, return ""; } - template -std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { - string classname = desc->name(); - const Descriptor* containing = desc->containing_type(); - while (containing != NULL) { - classname = containing->name() + '_' + classname; - containing = containing->containing_type(); - } - classname = ClassNamePrefix(classname, desc) + classname; - +std::string NamespacedName(const string& classname, + const DescriptorType* desc, bool is_descriptor) { if (desc->file()->options().has_php_namespace()) { const string& php_namespace = desc->file()->options().php_namespace(); if (php_namespace != "") { @@ -167,6 +163,24 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { } } +template +std::string FullClassName(const DescriptorType* desc, bool is_descriptor) { + string classname = desc->name(); + const Descriptor* containing = desc->containing_type(); + while (containing != NULL) { + classname = containing->name() + '_' + classname; + containing = containing->containing_type(); + } + classname = ClassNamePrefix(classname, desc) + classname; + return NamespacedName(classname, desc, is_descriptor); +} + +std::string FullClassName(const ServiceDescriptor* desc, bool is_descriptor) { + string classname = desc->name(); + classname = ClassNamePrefix(classname, desc) + classname; + return NamespacedName(classname, desc, is_descriptor); +} + std::string PhpName(const std::string& full_name, bool is_descriptor) { if (is_descriptor) { return kDescriptorPackageName; @@ -272,6 +286,17 @@ std::string GeneratedEnumFileName(const EnumDescriptor* en, return result + ".php"; } +std::string GeneratedServiceFileName(const ServiceDescriptor* service, + bool is_descriptor) { + std::string result = FullClassName(service, is_descriptor) + "Interface"; + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } + } + return result + ".php"; +} + std::string IntToString(int32 value) { std::ostringstream os; os << value; @@ -660,6 +685,16 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) { Outdent(printer); } +void GenerateServiceMethod(const MethodDescriptor* method, + io::Printer* printer) { + printer->Print( + "public function ^camel_name^(\\^request_name^ $request);\n\n", + "camel_name", UnderscoresToCamelCase(method->name(), false), + "request_name", FullClassName( + method->input_type(), false) + ); +} + void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, io::Printer* printer) { // Don't generate MapEntry messages -- we use the PHP extension's native @@ -1061,6 +1096,58 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, } } +void GenerateServiceFile(const FileDescriptor* file, + const ServiceDescriptor* service, bool is_descriptor, + GeneratorContext* generator_context) { + std::string filename = GeneratedServiceFileName(service, is_descriptor); + scoped_ptr output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + if (file->options().has_php_namespace()) { + const string& php_namespace = file->options().php_namespace(); + if (!php_namespace.empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", php_namespace); + } + } else if (!file->package().empty()) { + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + } + + GenerateServiceDocComment(&printer, service); + + if (lastindex != string::npos) { + printer.Print( + "interface ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "interface ^name^\n" + "{\n", + "name", fullname); + } + + Indent(&printer); + + for (int i = 0; i < service->method_count(); i++) { + const MethodDescriptor* method = service->method(i); + GenerateServiceMethodDocComment(&printer, method); + GenerateServiceMethod(method, &printer); + } + + Outdent(&printer); + printer.Print("}\n\n"); +} + void GenerateFile(const FileDescriptor* file, bool is_descriptor, GeneratorContext* generator_context) { GenerateMetadataFile(file, is_descriptor, generator_context); @@ -1072,6 +1159,12 @@ void GenerateFile(const FileDescriptor* file, bool is_descriptor, GenerateEnumFile(file, file->enum_type(i), is_descriptor, generator_context); } + if (file->options().php_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + GenerateServiceFile(file, file->service(i), is_descriptor, + generator_context); + } + } } static string EscapePhpdoc(const string& input) { @@ -1180,6 +1273,16 @@ void GenerateMessageDocComment(io::Printer* printer, "messagename", EscapePhpdoc(message->full_name())); } +void GenerateServiceDocComment(io::Printer* printer, + const ServiceDescriptor* service) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, service); + printer->Print( + " * Protobuf type ^fullname^\n" + " */\n", + "fullname", EscapePhpdoc(service->full_name())); +} + void GenerateFieldDocComment(io::Printer* printer, const FieldDescriptor* field, int is_descriptor, int function_type) { // In theory we should have slightly different comments for setters, getters, @@ -1226,6 +1329,23 @@ void GenerateEnumValueDocComment(io::Printer* printer, "def", EscapePhpdoc(FirstLineOf(value->DebugString()))); } +void GenerateServiceMethodDocComment(io::Printer* printer, + const MethodDescriptor* method) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, method); + printer->Print( + " * Method ^method_name^\n" + " *\n", + "method_name", EscapePhpdoc(UnderscoresToCamelCase(method->name(), false))); + printer->Print( + " * @param \\^input_type^ $request\n", + "input_type", EscapePhpdoc(FullClassName(method->input_type(), false))); + printer->Print( + " * @return \\^return_type^\n" + " */\n", + "return_type", EscapePhpdoc(FullClassName(method->output_type(), false))); +} + bool Generator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 48a256dd..1a2c2ed3 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -297,6 +297,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, php_generic_services_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), @@ -310,13 +311,14 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { 8, 9, 10, - 16, + 17, 2, 11, 12, 13, 14, 15, + 16, 3, 4, 5, @@ -488,20 +490,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = { { 124, 132, sizeof(EnumValueDescriptorProto)}, { 135, 143, sizeof(ServiceDescriptorProto)}, { 146, 157, sizeof(MethodDescriptorProto)}, - { 163, 186, sizeof(FileOptions)}, - { 204, 214, sizeof(MessageOptions)}, - { 219, 231, sizeof(FieldOptions)}, - { 238, 244, sizeof(OneofOptions)}, - { 245, 253, sizeof(EnumOptions)}, - { 256, 263, sizeof(EnumValueOptions)}, - { 265, 272, sizeof(ServiceOptions)}, - { 274, 282, sizeof(MethodOptions)}, - { 285, 292, sizeof(UninterpretedOption_NamePart)}, - { 294, 306, sizeof(UninterpretedOption)}, - { 313, 323, sizeof(SourceCodeInfo_Location)}, - { 328, 334, sizeof(SourceCodeInfo)}, - { 335, 344, sizeof(GeneratedCodeInfo_Annotation)}, - { 348, 354, sizeof(GeneratedCodeInfo)}, + { 163, 187, sizeof(FileOptions)}, + { 206, 216, sizeof(MessageOptions)}, + { 221, 233, sizeof(FieldOptions)}, + { 240, 246, sizeof(OneofOptions)}, + { 247, 255, sizeof(EnumOptions)}, + { 258, 265, sizeof(EnumValueOptions)}, + { 267, 274, sizeof(ServiceOptions)}, + { 276, 284, sizeof(MethodOptions)}, + { 287, 294, sizeof(UninterpretedOption_NamePart)}, + { 296, 308, sizeof(UninterpretedOption)}, + { 315, 325, sizeof(SourceCodeInfo_Location)}, + { 330, 336, sizeof(SourceCodeInfo)}, + { 337, 346, sizeof(GeneratedCodeInfo_Annotation)}, + { 350, 356, sizeof(GeneratedCodeInfo)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { @@ -729,7 +731,7 @@ void AddDescriptorsImpl() { "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" "oogle.protobuf.MethodOptions\022\037\n\020client_s" "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\313\005\n\013FileOptions\022\024\n\014java_p" + "g\030\006 \001(\010:\005false\"\360\005\n\013FileOptions\022\024\n\014java_p" "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)" "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030" @@ -739,75 +741,76 @@ void AddDescriptorsImpl() { "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(" "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:" "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal" - "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" - "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" - "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s" - "wift_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( " - "\001(\t\022\025\n\rphp_namespace\030) \001(\t\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption\":\n\014OptimizeMode\022\t\n\005SPEED" - "\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007" - "\020\200\200\200\200\002J\004\010&\020\'\"\362\001\n\016MessageOptions\022&\n\027messa" - "ge_set_wire_format\030\001 \001(\010:\005false\022.\n\037no_st" - "andard_descriptor_accessor\030\002 \001(\010:\005false\022" - "\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030" - "\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.g" - "oogle.protobuf.UninterpretedOption*\t\010\350\007\020" - "\200\200\200\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ct" - "ype\030\001 \001(\0162#.google.protobuf.FieldOptions" - ".CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype" - "\030\006 \001(\0162$.google.protobuf.FieldOptions.JS" - "Type:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\n" - "deprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005f" - "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption\"/\n\005CTy" - "pe\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE" - "\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING" - "\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014On" - "eofOptions\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alia" - "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un" - "interpreted_option\030\347\007 \003(\0132$.google.proto" - "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006" - "\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010" - ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$" + "se\022#\n\024php_generic_services\030\023 \001(\010:\005false\022" + "\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_" + "arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix" + "\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swif" + "t_prefix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t" + "\022\025\n\rphp_namespace\030) \001(\t\022C\n\024uninterpreted" + "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" + "pretedOption\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022" + "\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200" + "\200\200\002J\004\010&\020\'\"\362\001\n\016MessageOptions\022&\n\027message_" + "set_wire_format\030\001 \001(\010:\005false\022.\n\037no_stand" + "ard_descriptor_accessor\030\002 \001(\010:\005false\022\031\n\n" + "deprecated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001" + "(\010\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.goog" + "le.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200" + "\200\002J\004\010\010\020\tJ\004\010\t\020\n\"\236\003\n\014FieldOptions\022:\n\005ctype" + "\030\001 \001(\0162#.google.protobuf.FieldOptions.CT" + "ype:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 " + "\001(\0162$.google.protobuf.FieldOptions.JSTyp" + "e:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndep" + "recated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fals" + "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption\"/\n\005CType\022" + "\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"" + "5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022" + "\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014Oneof" + "Options\022C\n\024uninterpreted_option\030\347\007 \003(\0132$" ".google.protobuf.UninterpretedOption*\t\010\350" - "\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030" - "! \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " - "\003(\0132$.google.protobuf.UninterpretedOptio" - "n*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprec" - "ated\030! \001(\010:\005false\022_\n\021idempotency_level\030\"" - " \001(\0162/.google.protobuf.MethodOptions.Ide" - "mpotencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024un" - "interpreted_option\030\347\007 \003(\0132$.google.proto" - "buf.UninterpretedOption\"P\n\020IdempotencyLe" - "vel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_" - "EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n" - "\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-.goo" - "gle.protobuf.UninterpretedOption.NamePar" - "t\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_" - "int_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 " - "\001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_valu" - "e\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010Name" - "Part\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030" - "\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003" - "(\0132(.google.protobuf.SourceCodeInfo.Loca" - "tion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004s" - "pan\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022" - "\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_de" - "tached_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeI" - "nfo\022A\n\nannotation\030\001 \003(\0132-.google.protobu" - "f.GeneratedCodeInfo.Annotation\032O\n\nAnnota" - "tion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 " - "\001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\214\001\n\023com." - "google.protobufB\020DescriptorProtosH\001Z>git" - "hub.com/golang/protobuf/protoc-gen-go/de" - "scriptor;descriptor\242\002\003GPB\252\002\032Google.Proto" - "buf.Reflection" + "\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow_alias\030\002" + " \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n" + "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005f" + "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" + "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" + "\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001" + "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" + "2$.google.protobuf.UninterpretedOption*\t" + "\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\ndeprecate" + "d\030! \001(\010:\005false\022_\n\021idempotency_level\030\" \001(" + "\0162/.google.protobuf.MethodOptions.Idempo" + "tencyLevel:\023IDEMPOTENCY_UNKNOWN\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption\"P\n\020IdempotencyLevel" + "\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_SIDE_EFF" + "ECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Un" + "interpretedOption\022;\n\004name\030\002 \003(\0132-.google" + ".protobuf.UninterpretedOption.NamePart\022\030" + "\n\020identifier_value\030\003 \001(\t\022\032\n\022positive_int" + "_value\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001(\003" + "\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_value\030\007" + " \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NamePar" + "t\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002" + "(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(\0132" + "(.google.protobuf.SourceCodeInfo.Locatio" + "n\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span" + "\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021" + "trailing_comments\030\004 \001(\t\022!\n\031leading_detac" + "hed_comments\030\006 \003(\t\"\247\001\n\021GeneratedCodeInfo" + "\022A\n\nannotation\030\001 \003(\0132-.google.protobuf.G" + "eneratedCodeInfo.Annotation\032O\n\nAnnotatio" + "n\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_file\030\002 \001(\t" + "\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005B\214\001\n\023com.goo" + "gle.protobufB\020DescriptorProtosH\001Z>github" + ".com/golang/protobuf/protoc-gen-go/descr" + "iptor;descriptor\242\002\003GPB\252\002\032Google.Protobuf" + ".Reflection" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 5614); + descriptor, 5651); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); @@ -8292,6 +8295,7 @@ const int FileOptions::kGoPackageFieldNumber; const int FileOptions::kCcGenericServicesFieldNumber; const int FileOptions::kJavaGenericServicesFieldNumber; const int FileOptions::kPyGenericServicesFieldNumber; +const int FileOptions::kPhpGenericServicesFieldNumber; const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; @@ -8451,10 +8455,13 @@ void FileOptions::Clear() { } if (_has_bits_[8 / 32] & 65280u) { ::memset(&java_multiple_files_, 0, static_cast( - reinterpret_cast(&cc_enable_arenas_) - - reinterpret_cast(&java_multiple_files_)) + sizeof(cc_enable_arenas_)); + reinterpret_cast(&deprecated_) - + reinterpret_cast(&java_multiple_files_)) + sizeof(deprecated_)); + } + if (_has_bits_[16 / 32] & 196608u) { + cc_enable_arenas_ = false; + optimize_for_ = 1; } - optimize_for_ = 1; _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -8593,6 +8600,20 @@ bool FileOptions::MergePartialFromCodedStream( break; } + // optional bool php_generic_services = 19 [default = false]; + case 19: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(152u)) { + set_has_php_generic_services(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &php_generic_services_))); + } else { + goto handle_unusual; + } + break; + } + // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { if (static_cast< ::google::protobuf::uint8>(tag) == @@ -8796,7 +8817,7 @@ void FileOptions::SerializeWithCachedSizes( } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (cached_has_bits & 0x00010000u) { + if (cached_has_bits & 0x00020000u) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 9, this->optimize_for(), output); } @@ -8831,13 +8852,18 @@ void FileOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output); } + // optional bool php_generic_services = 19 [default = false]; + if (cached_has_bits & 0x00004000u) { + ::google::protobuf::internal::WireFormatLite::WriteBool(19, this->php_generic_services(), output); + } + // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; if (cached_has_bits & 0x00000200u) { ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output); } // optional bool deprecated = 23 [default = false]; - if (cached_has_bits & 0x00004000u) { + if (cached_has_bits & 0x00008000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output); } @@ -8847,7 +8873,7 @@ void FileOptions::SerializeWithCachedSizes( } // optional bool cc_enable_arenas = 31 [default = false]; - if (cached_has_bits & 0x00008000u) { + if (cached_has_bits & 0x00010000u) { ::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output); } @@ -8949,7 +8975,7 @@ void FileOptions::SerializeWithCachedSizes( } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (cached_has_bits & 0x00010000u) { + if (cached_has_bits & 0x00020000u) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 9, this->optimize_for(), target); } @@ -8985,13 +9011,18 @@ void FileOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target); } + // optional bool php_generic_services = 19 [default = false]; + if (cached_has_bits & 0x00004000u) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(19, this->php_generic_services(), target); + } + // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; if (cached_has_bits & 0x00000200u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target); } // optional bool deprecated = 23 [default = false]; - if (cached_has_bits & 0x00004000u) { + if (cached_has_bits & 0x00008000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target); } @@ -9001,7 +9032,7 @@ void FileOptions::SerializeWithCachedSizes( } // optional bool cc_enable_arenas = 31 [default = false]; - if (cached_has_bits & 0x00008000u) { + if (cached_has_bits & 0x00010000u) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target); } @@ -9191,23 +9222,30 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } + // optional bool php_generic_services = 19 [default = false]; + if (has_php_generic_services()) { + total_size += 2 + 1; + } + // optional bool deprecated = 23 [default = false]; if (has_deprecated()) { total_size += 2 + 1; } + } + if (_has_bits_[16 / 32] & 196608u) { // optional bool cc_enable_arenas = 31 [default = false]; if (has_cc_enable_arenas()) { total_size += 2 + 1; } - } - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); - } + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + if (has_optimize_for()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -9294,15 +9332,21 @@ void FileOptions::MergeFrom(const FileOptions& from) { py_generic_services_ = from.py_generic_services_; } if (cached_has_bits & 0x00004000u) { - deprecated_ = from.deprecated_; + php_generic_services_ = from.php_generic_services_; } if (cached_has_bits & 0x00008000u) { - cc_enable_arenas_ = from.cc_enable_arenas_; + deprecated_ = from.deprecated_; } _has_bits_[0] |= cached_has_bits; } - if (cached_has_bits & 0x00010000u) { - set_optimize_for(from.optimize_for()); + if (cached_has_bits & 196608u) { + if (cached_has_bits & 0x00010000u) { + cc_enable_arenas_ = from.cc_enable_arenas_; + } + if (cached_has_bits & 0x00020000u) { + optimize_for_ = from.optimize_for_; + } + _has_bits_[0] |= cached_has_bits; } } @@ -9349,6 +9393,7 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(cc_generic_services_, other->cc_generic_services_); std::swap(java_generic_services_, other->java_generic_services_); std::swap(py_generic_services_, other->py_generic_services_); + std::swap(php_generic_services_, other->php_generic_services_); std::swap(deprecated_, other->deprecated_); std::swap(cc_enable_arenas_, other->cc_enable_arenas_); std::swap(optimize_for_, other->optimize_for_); @@ -9566,13 +9611,13 @@ void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00010000u) != 0; + return (_has_bits_[0] & 0x00020000u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00010000u; + _has_bits_[0] |= 0x00020000u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00010000u; + _has_bits_[0] &= ~0x00020000u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -9724,15 +9769,39 @@ void FileOptions::set_py_generic_services(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) } +// optional bool php_generic_services = 19 [default = false]; +bool FileOptions::has_php_generic_services() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void FileOptions::set_has_php_generic_services() { + _has_bits_[0] |= 0x00004000u; +} +void FileOptions::clear_has_php_generic_services() { + _has_bits_[0] &= ~0x00004000u; +} +void FileOptions::clear_php_generic_services() { + php_generic_services_ = false; + clear_has_php_generic_services(); +} +bool FileOptions::php_generic_services() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_generic_services) + return php_generic_services_; +} +void FileOptions::set_php_generic_services(bool value) { + set_has_php_generic_services(); + php_generic_services_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_generic_services) +} + // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00004000u) != 0; + return (_has_bits_[0] & 0x00008000u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00004000u; + _has_bits_[0] |= 0x00008000u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00004000u; + _has_bits_[0] &= ~0x00008000u; } void FileOptions::clear_deprecated() { deprecated_ = false; @@ -9750,13 +9819,13 @@ void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00008000u) != 0; + return (_has_bits_[0] & 0x00010000u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00008000u; + _has_bits_[0] |= 0x00010000u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00008000u; + _has_bits_[0] &= ~0x00010000u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index f64a339c..6dd82d12 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -2290,6 +2290,13 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool py_generic_services() const; void set_py_generic_services(bool value); + // optional bool php_generic_services = 19 [default = false]; + bool has_php_generic_services() const; + void clear_php_generic_services(); + static const int kPhpGenericServicesFieldNumber = 19; + bool php_generic_services() const; + void set_php_generic_services(bool value); + // optional bool deprecated = 23 [default = false]; bool has_deprecated() const; void clear_deprecated(); @@ -2334,6 +2341,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p void clear_has_java_generic_services(); void set_has_py_generic_services(); void clear_has_py_generic_services(); + void set_has_php_generic_services(); + void clear_has_php_generic_services(); void set_has_deprecated(); void clear_has_deprecated(); void set_has_cc_enable_arenas(); @@ -2369,6 +2378,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p bool cc_generic_services_; bool java_generic_services_; bool py_generic_services_; + bool php_generic_services_; bool deprecated_; bool cc_enable_arenas_; int optimize_for_; @@ -6644,13 +6654,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00010000u) != 0; + return (_has_bits_[0] & 0x00020000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00010000u; + _has_bits_[0] |= 0x00020000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00010000u; + _has_bits_[0] &= ~0x00020000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6802,15 +6812,39 @@ inline void FileOptions::set_py_generic_services(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services) } +// optional bool php_generic_services = 19 [default = false]; +inline bool FileOptions::has_php_generic_services() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +inline void FileOptions::set_has_php_generic_services() { + _has_bits_[0] |= 0x00004000u; +} +inline void FileOptions::clear_has_php_generic_services() { + _has_bits_[0] &= ~0x00004000u; +} +inline void FileOptions::clear_php_generic_services() { + php_generic_services_ = false; + clear_has_php_generic_services(); +} +inline bool FileOptions::php_generic_services() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_generic_services) + return php_generic_services_; +} +inline void FileOptions::set_php_generic_services(bool value) { + set_has_php_generic_services(); + php_generic_services_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_generic_services) +} + // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00004000u) != 0; + return (_has_bits_[0] & 0x00008000u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00004000u; + _has_bits_[0] |= 0x00008000u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00004000u; + _has_bits_[0] &= ~0x00008000u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6828,13 +6862,13 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; inline bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00008000u) != 0; + return (_has_bits_[0] & 0x00010000u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00008000u; + _has_bits_[0] |= 0x00010000u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00008000u; + _has_bits_[0] &= ~0x00010000u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index c7fbaaf6..70b82a4d 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -351,6 +351,7 @@ message FileOptions { optional bool cc_generic_services = 16 [default=false]; optional bool java_generic_services = 17 [default=false]; optional bool py_generic_services = 18 [default=false]; + optional bool php_generic_services = 19 [default=false]; // Is this file deprecated? // Depending on the target platform, this can emit Deprecated annotations diff --git a/tests.sh b/tests.sh index b40f0c5d..c458584a 100755 --- a/tests.sh +++ b/tests.sh @@ -346,7 +346,7 @@ generate_php_test_proto() { # Generate test file rm -rf generated mkdir generated - ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto proto/test_prefix.proto proto/test_php_namespace.proto proto/test_empty_php_namespace.proto + ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto proto/test_prefix.proto proto/test_php_namespace.proto proto/test_empty_php_namespace.proto proto/test_service.proto proto/test_service_namespace.proto pushd ../../src ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto ./protoc --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto -- cgit v1.2.3