THRIFT-660. php: Use the accelerator to write return values from servers

Previously, we only used the acclerator module for clients to
write calls and read returns.  Now PHP servers will use it for
writing returns.  We cannot use it to read calls on the server side
(without modifications), because the module requires that
the structure type be known before reading the message header.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@920663 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index 38a63fa..3532eb0 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -1134,6 +1134,21 @@
     return;
   }
 
+  f_service_ <<
+    indent() << "$bin_accel = ($output instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');" << endl;
+
+  f_service_ <<
+    indent() << "if ($bin_accel)" << endl;
+  scope_up(f_service_);
+
+  f_service_ <<
+    indent() << "thrift_protocol_write_binary($output, '" << tfunction->get_name() << "', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());" << endl;
+
+  scope_down(f_service_);
+  f_service_ <<
+    indent() << "else" << endl;
+  scope_up(f_service_);
+
   // Serialize the request header
   if (binary_inline_) {
     f_service_ <<
@@ -1151,6 +1166,8 @@
       indent() << "$output->getTransport()->flush();" << endl;
   }
 
+  scope_down(f_service_);
+
   // Close function
   indent_down();
   f_service_ <<