Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/compiler/php_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,36 @@ void PrintService(const ServiceDescriptor* service,
out->Print(GetPHPComments(service, " *").c_str());
out->Print(" */\n");
vars["name"] = GetPHPServiceClassname(service, class_suffix, is_server);
vars["extends"] = is_server ? "" : "extends \\Grpc\\BaseStub ";
vars["extends"] = is_server ? "" : "extends BaseStub ";
out->Print(vars, "class $name$ $extends${\n\n");
out->Indent();
out->Indent();

out->Print("public function getExpectedResponseMessages() {\n");
out->Indent();
out->Print("return [\n");
out->Indent();
map<grpc::string, grpc::string> response_vars;
for (int i = 0; i < service->method_count(); i++) {
const Descriptor* output_type = service->method(i)->output_type();
response_vars["method_name"] = grpc_generator::LowercaseFirstLetter(service->method(i)->name());
response_vars["output_type_id"] = MessageIdentifierName(GeneratedClassName(output_type), output_type->file());
out->Print(response_vars, "'$method_name$' => '\\$output_type_id$',\n");
}
out->Outdent();
out->Print("];\n");
out->Outdent();
out->Print("}\n\n");

// getServiceName() -> string - The name of the gRPC service
map<grpc::string, grpc::string> service_vars;
service_vars["service_name"] = service->full_name();
out->Print("public function getServiceName() {\n");
out->Indent();
out->Print(service_vars, "return '$service_name$';\n");
out->Outdent();
out->Print("}\n\n");

if (!is_server) {
out->Print(
"/**\n * @param string $$hostname hostname\n"
Expand Down Expand Up @@ -332,6 +358,8 @@ std::string GenerateFile(const FileDescriptor* file,
vars["package"] = php_namespace;
out.Print(vars, "namespace $package$;\n\n");

out.Print("use \\Grpc\\BaseStub;\n\n");

PrintService(service, class_suffix, is_server, &out);
}
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.16
FROM golang:1.20rc3

<%include file="../../go_path.include"/>
<%include file="../../run_tests_python_deps.include"/>
Expand Down