summaryrefslogtreecommitdiff
path: root/compiler/cpp/src/thrift/generate/t_php_generator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/cpp/src/thrift/generate/t_php_generator.cc')
-rw-r--r--compiler/cpp/src/thrift/generate/t_php_generator.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc
index c6e60c82a..5e02b9b69 100644
--- a/compiler/cpp/src/thrift/generate/t_php_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc
@@ -99,6 +99,7 @@ public:
throw "oop and inlined are mutually exclusive.";
}
+ update_keywords_for_validation();
out_dir_base_ = (binary_inline_ ? "gen-phpi" : "gen-php");
escape_['$'] = "\\$";
}
@@ -115,6 +116,7 @@ public:
void init_generator() override;
void close_generator() override;
+ std::string display_name() const override;
/**
* Program-level generation functions
@@ -128,6 +130,7 @@ public:
void generate_service(t_service* tservice) override;
std::string render_const_value(t_type* type, t_const_value* value);
+ std::set<std::string> lang_keywords_for_validation() const override;
/**
* Structs!
@@ -418,6 +421,22 @@ private:
bool getters_setters_;
};
+std::set<std::string> t_php_generator::lang_keywords_for_validation() const {
+ std::string keywords[] = { "BEGIN", "END", "__CLASS__", "__DIR__", "__FILE__", "__FUNCTION__",
+ "__LINE__", "__METHOD__", "__NAMESPACE__", "abstract", "alias", "and", "args", "as",
+ "assert", "begin", "break", "case", "catch", "class", "clone", "continue", "declare",
+ "def", "default", "del", "delete", "do", "dynamic", "elif", "else", "elseif", "elsif",
+ "end", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "ensure",
+ "except", "exec", "finally", "float", "for", "foreach", "from", "function", "global",
+ "goto", "if", "implements", "import", "in", "inline", "instanceof", "interface", "is",
+ "lambda", "module", "native", "new", "next", "nil", "not", "or", "package", "pass",
+ "public", "print", "private", "protected", "raise", "redo", "rescue", "retry", "register",
+ "return", "self", "sizeof", "static", "super", "switch", "synchronized", "then", "this",
+ "throw", "transient", "try", "undef", "unless", "unsigned", "until", "use", "var",
+ "virtual", "volatile", "when", "while", "with", "xor", "yield" };
+ return std::set<std::string>(keywords, keywords + sizeof(keywords)/sizeof(keywords[0]) );
+}
+
bool t_php_generator::is_valid_namespace(const std::string& sub_namespace) {
return sub_namespace == "path";
}
@@ -2871,6 +2890,11 @@ string t_php_generator::type_to_phpdoc(t_type* type) {
throw "INVALID TYPE IN type_to_enum: " + type->get_name();
}
+std::string t_php_generator::display_name() const {
+ return "PHP";
+}
+
+
THRIFT_REGISTER_GENERATOR(
php,
"PHP",