From e5d000cbb7bcf8fadddfbdb544070e31ce36fa26 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Fri, 8 Sep 2017 15:11:49 -0700 Subject: Add prefix to php reserved keywords. --- php/src/Google/Protobuf/Internal/GPBUtil.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'php/src') 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 { -- cgit v1.2.3