You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/02/07 01:16:11 UTC

git commit: THRIFT-2348 PHP Generator: add array typehint to functions Patch: Maurus Cuelenaere

Updated Branches:
  refs/heads/master 213ea258d -> 2a816c28a


THRIFT-2348 PHP Generator: add array typehint to functions
Patch: Maurus Cuelenaere


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2a816c28
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2a816c28
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2a816c28

Branch: refs/heads/master
Commit: 2a816c28ae166f267e3a681ba335b298d542b1f1
Parents: 213ea25
Author: Roger Meier <ro...@apache.org>
Authored: Fri Feb 7 01:15:23 2014 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Fri Feb 7 01:15:23 2014 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_php_generator.cc | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/2a816c28/compiler/cpp/src/generate/t_php_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 0f48758..124039b 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -205,7 +205,7 @@ class t_php_generator : public t_oop_generator {
   std::string php_includes();
   std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
   std::string function_signature(t_function* tfunction, std::string prefix="");
-  std::string argument_list(t_struct* tstruct, bool addStructSignature = true);
+  std::string argument_list(t_struct* tstruct, bool addTypeHints = true);
   std::string type_to_cast(t_type* ttype);
   std::string type_to_enum(t_type* ttype);
   std::string type_to_phpdoc(t_type* ttype);
@@ -2374,7 +2374,7 @@ string t_php_generator::function_signature(t_function* tfunction,
 /**
  * Renders a field list
  */
-string t_php_generator::argument_list(t_struct* tstruct, bool addStructSignature) {
+string t_php_generator::argument_list(t_struct* tstruct, bool addTypeHints) {
   string result = "";
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -2390,11 +2390,18 @@ string t_php_generator::argument_list(t_struct* tstruct, bool addStructSignature
     t_type* type = (*f_iter)->get_type();
 
     //Set type name
-    if(addStructSignature && type->is_struct())
+    if (addTypeHints)
     {
-      string className = php_namespace(type->get_program()) + php_namespace_directory("Definition", false) + classify(type->get_name());
+      if (type->is_struct())
+      {
+        string className = php_namespace(type->get_program()) + php_namespace_directory("Definition", false) + classify(type->get_name());
 
-      result += className + " ";
+        result += className + " ";
+      }
+      else if (type->is_container())
+      {
+        result += "array ";
+      }
     }
 
     result += "$" + (*f_iter)->get_name();