aboutsummaryrefslogtreecommitdiffhomepage
path: root/php/src
diff options
context:
space:
mode:
authorGravatar Bo Yang <teboring@google.com>2017-09-08 15:11:49 -0700
committerGravatar Bo Yang <teboring@google.com>2017-09-08 15:17:36 -0700
commite5d000cbb7bcf8fadddfbdb544070e31ce36fa26 (patch)
treea2ee22257bb80c1c213913959b4f24e7cd80acd6 /php/src
parent6a4ffb2f90ef7bbd3f20f2a1db4948630ad37dc8 (diff)
Add prefix to php reserved keywords.
Diffstat (limited to 'php/src')
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 84e8ecf0..659a4ee3 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -252,9 +252,23 @@ class GPBUtil
return $prefix;
}
- $reserved_words = array("Empty", "ECHO", "ARRAY");
+ $reserved_words = array(
+ "abstract", "and", "array", "as", "break", "callable", "case",
+ "catch", "class", "clone", "const", "continue", "declare",
+ "default", "die", "do", "echo", "else", "elseif", "empty",
+ "enddeclare", "endfor", "endforeach", "endif", "endswitch",
+ "endwhile", "eval", "exit", "extends", "final", "for", "foreach",
+ "function", "global", "goto", "if", "implements", "include",
+ "include_once", "instanceof", "insteadof", "interface", "isset",
+ "list", "namespace", "new", "or", "print", "private", "protected",
+ "public", "require", "require_once", "return", "static", "switch",
+ "throw", "trait", "try", "unset", "use", "var", "while", "xor",
+ "int", "float", "bool", "string", "true", "false", "null", "void",
+ "iterable"
+
+ );
foreach ($reserved_words as $reserved_word) {
- if ($classname === $reserved_word) {
+ if (strtolower($classname) === $reserved_word) {
if ($file_proto->getPackage() === "google.protobuf") {
return "GPB";
} else {