aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Yang <TeBoring@users.noreply.github.com>2017-05-29 15:30:47 -0700
committerBo Yang <teboring@google.com>2017-06-20 15:06:22 -0700
commitdba8928ff53ae372bba3d928a6145754a97238d5 (patch)
tree4177a3467bd1120fa99e5dfccb59c7b1f0c1b7ca
parentbf04c83267619b618e7112b242f424f8b3e785b6 (diff)
downloadprotobuf-dba8928ff53ae372bba3d928a6145754a97238d5.tar.gz
protobuf-dba8928ff53ae372bba3d928a6145754a97238d5.tar.bz2
protobuf-dba8928ff53ae372bba3d928a6145754a97238d5.zip
Add ARRAY for reserved name (#3150)
-rw-r--r--php/ext/google/protobuf/def.c4
-rw-r--r--php/src/Google/Protobuf/descriptor.php2
-rw-r--r--php/tests/generated_class_test.php1
-rw-r--r--php/tests/memory_leak_test.php1
-rw-r--r--php/tests/proto/test.proto4
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc4
6 files changed, 11 insertions, 5 deletions
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index 8e563a61..099ebd05 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -30,8 +30,8 @@
#include "protobuf.h"
-const char* const kReservedNames[] = {"Empty"};
-const int kReservedNamesSize = 1;
+const char* const kReservedNames[] = {"Empty", "ECHO", "ARRAY"};
+const int kReservedNamesSize = 3;
// Forward declare.
static void descriptor_init_c_instance(Descriptor* intern TSRMLS_DC);
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") {
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index 21ee8490..7289bbc5 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -876,5 +876,6 @@ class GeneratedClassTest extends TestBase
$m = new \Foo\TestMessage_Empty();
$m = new \Foo\PBEmpty();
$m = new \PrefixEmpty();
+ $m = new \Foo\PBARRAY();
}
}
diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php
index 361982b5..5eac56f0 100644
--- a/php/tests/memory_leak_test.php
+++ b/php/tests/memory_leak_test.php
@@ -8,6 +8,7 @@ require_once('generated/NoNamespaceMessage_NestedEnum.php');
require_once('generated/PrefixEmpty.php');
require_once('generated/PrefixTestPrefix.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/TestIncludePrefixMessage.php');
diff --git a/php/tests/proto/test.proto b/php/tests/proto/test.proto
index 39229254..583bf8e1 100644
--- a/php/tests/proto/test.proto
+++ b/php/tests/proto/test.proto
@@ -127,6 +127,10 @@ message Empty {
int32 a = 1;
}
+message ARRAY {
+ int32 a = 1;
+}
+
message TestPackedMessage {
repeated int32 repeated_int32 = 90 [packed = true];
repeated int64 repeated_int64 = 91 [packed = true];
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index ea850c0f..f8e7e5f0 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -49,8 +49,8 @@ const std::string kDescriptorMetadataFile =
"GPBMetadata/Google/Protobuf/Internal/Descriptor.php";
const std::string kDescriptorDirName = "Google/Protobuf/Internal";
const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal";
-const char* const kReservedNames[] = {"Empty", "ECHO"};
-const int kReservedNamesSize = 2;
+const char* const kReservedNames[] = {"ARRAY", "Empty", "ECHO"};
+const int kReservedNamesSize = 3;
namespace google {
namespace protobuf {