Make the PHP generator dynamic.

- Modify the PHP generator constructor to fit the new generic interface.
- Register the PHP genrator with the central registry.
- Deprecate the old way of invoking the PHP generator.
- main.cc no longer includes t_php_generator.h.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@745238 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 88d9bc4..0e31bd9 100644
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -37,7 +37,6 @@
 #include "parse/t_program.h"
 #include "parse/t_scope.h"
 #include "generate/t_generator.h"
-#include "generate/t_php_generator.h"
 
 #include "version.h"
 
@@ -603,17 +602,10 @@
   fprintf(stderr, "Usage: thrift [options] file\n");
   fprintf(stderr, "Options:\n");
   fprintf(stderr, "  -version    Print the compiler version\n");
-  fprintf(stderr, "  -php        Generate PHP output files\n");
-  fprintf(stderr, "  -phpi       Generate PHP inlined files\n");
-  fprintf(stderr, "  -phps       Generate PHP server stubs (with -php)\n");
-  fprintf(stderr, "  -phpl       Generate PHP-lite (with -php)\n");
-  fprintf(stderr, "  -phpa       Generate PHP with autoload (with -php)\n");
-  fprintf(stderr, "  -phpo       Generate PHP with object oriented subclasses (with -php)\n");
   fprintf(stderr, "  -o dir      Set the output directory for gen-* packages\n");
   fprintf(stderr, "               (default: current directory)\n");
   fprintf(stderr, "  -I dir      Add a directory to the list of directories\n");
   fprintf(stderr, "                searched for include directives\n");
-  fprintf(stderr, "  -rest       Generate PHP REST processors (with -php)\n");
   fprintf(stderr, "  -nowarn     Suppress all compiler warnings (BAD!)\n");
   fprintf(stderr, "  -strict     Strict compiler warnings on\n");
   fprintf(stderr, "  -v[erbose]  Verbose mode\n");
@@ -857,20 +849,6 @@
     // Compute fingerprints.
     generate_all_fingerprints(program);
 
-    if (gen_php) {
-      pverbose("Generating PHP\n");
-      t_php_generator* php = new t_php_generator(program, false, gen_rest, gen_phps, gen_phpa, gen_phpo);
-      php->generate_program();
-      delete php;
-    }
-
-    if (gen_phpi) {
-      pverbose("Generating PHP-inline\n");
-      t_php_generator* phpi = new t_php_generator(program, true, gen_rest);
-      phpi->generate_program();
-      delete phpi;
-    }
-
     if (dump_docs) {
       dump_docstrings(program);
     }
@@ -1089,6 +1067,22 @@
     pwarning(1, "-perl is deprecated.  Use --gen perl");
     generator_strings.push_back("perl");
   }
+  if (gen_php || gen_phpi) {
+    pwarning(1, "-php is deprecated.  Use --gen php");
+    string gen_string = "php:";
+    if (gen_phpi) {
+      gen_string.append("inlined,");
+    } else if(gen_phps) {
+      gen_string.append("server,");
+    } else if(gen_phpa) {
+      gen_string.append("autoload,");
+    } else if(gen_phpo) {
+      gen_string.append("oop,");
+    } else if(gen_rest) {
+      gen_string.append("rest,");
+    }
+    generator_strings.push_back(gen_string);
+  }
   if (gen_cocoa) {
     pwarning(1, "-cocoa is deprecated.  Use --gen cocoa");
     generator_strings.push_back("cocoa");
@@ -1115,7 +1109,7 @@
   }
 
   // You gotta generate something!
-  if (!gen_php && !gen_phpi && generator_strings.empty()) {
+  if (generator_strings.empty()) {
     fprintf(stderr, "!!! No output language(s) specified\n\n");
     usage();
   }