Github user glennpratt commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1292#discussion_r122743894
--- Diff: compiler/cpp/src/thrift/generate/t_php_generator.cc ---
@@ -545,30 +553,41 @@ void
t_php_generator::generate_consts(vector<t_const*> consts) {
f_consts << "final class Constant extends \\Thrift\\Type\\TConstant {"
<< endl;
indent_up();
+ if (php56_) {
+ // Create const property
+ for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
+ string name = (*c_iter)->get_name();
+
+ indent(f_consts) << "public CONST $" << name << " = ";
+ generate_php_doc(f_consts, *c_iter);
+ f_consts << render_const_value((*c_iter)->get_type(),
(*c_iter)->get_value());
+ f_consts << ";" << endl;
+ }
+ } else {
+ // Create static property
--- End diff --
Is it worth maintaining the static property for backwards compatibility.
(5.6+ users could opt into the const without having to update all callers).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---