Skip to content
Closed
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
5 changes: 4 additions & 1 deletion compiler/cpp/src/generate/t_php_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ string t_php_generator::php_includes() {
"use Thrift\\Type\\TMessageType;\n"
"use Thrift\\Exception\\TException;\n"
"use Thrift\\Exception\\TProtocolException;\n"
"use Thrift\\Processor\\TProcessor;\n"
"use Thrift\\Protocol\\TProtocol;\n"
"use Thrift\\Protocol\\TBinaryProtocolAccelerated;\n"
"use Thrift\\Exception\\TApplicationException;\n";
Expand Down Expand Up @@ -1176,6 +1177,8 @@ void t_php_generator::generate_service_processor(t_service* tservice) {
extends = tservice->get_extends()->get_name();
extends_processor = " extends " + php_namespace(tservice->get_extends()->get_program())
+ extends + "Processor";
} else {
extends_processor = " implements TProcessor";
}

// Generate the header portion
Expand All @@ -1195,7 +1198,7 @@ void t_php_generator::generate_service_processor(t_service* tservice) {
f_service_ << indent() << "}" << endl << endl;

// Generate the server implementation
indent(f_service_) << "public function process($input, $output) {" << endl;
indent(f_service_) << "public function process(TProtocol $input, TProtocol $output) {" << endl;
indent_up();

f_service_ << indent() << "$rseqid = 0;" << endl << indent() << "$fname = null;" << endl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -16,11 +17,9 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package thrift.processor
*/

namespace Thrift;
namespace Thrift\Processor;

use Thrift\Exception\TException;
use Thrift\Protocol\TProtocol;
Expand Down Expand Up @@ -48,10 +47,15 @@
*
* $processor->process($protocol, $protocol);
* </code></blockquote>
*
* @package thrift.processor
*/

class TMultiplexedProcessor
class TMultiplexedProcessor implements TProcessor
{
/**
* @var TProcessor[]
*/
private $serviceProcessorMap_;

/**
Expand All @@ -64,7 +68,7 @@ class TMultiplexedProcessor
* @param processor Implementation of a service, usually referred to
* as "handlers", e.g. WeatherReportHandler implementing WeatherReport.Iface.
*/
public function registerProcessor($serviceName, $processor)
public function registerProcessor($serviceName, TProcessor $processor)
{
$this->serviceProcessorMap_[$serviceName] = $processor;
}
Expand Down
33 changes: 33 additions & 0 deletions lib/php/lib/Thrift/Processor/TProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

namespace Thrift\Processor;

use Thrift\Protocol\TProtocol;

/**
* Generic interface for a Thrift processor.
*
* @package thrift.server
*/
interface TProcessor
{
public function process(TProtocol $input, TProtocol $output);
}
7 changes: 4 additions & 3 deletions lib/php/lib/Thrift/Server/TServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Thrift\Server;

use Thrift\Factory\TTransportFactory;
use Thrift\Factory\TProtocolFactory;
use Thrift\Factory\TTransportFactory;
use Thrift\Processor\TProcessor;

/**
* Generic class for a Thrift server.
Expand Down Expand Up @@ -58,15 +59,15 @@ abstract class TServer
/**
* Sets up all the factories, etc
*
* @param object $processor
* @param TProcessor $processor
* @param TServerTransport $transport
* @param TTransportFactory $inputTransportFactory
* @param TTransportFactory $outputTransportFactory
* @param TProtocolFactory $inputProtocolFactory
* @param TProtocolFactory $outputProtocolFactory
* @return void
*/
public function __construct($processor,
public function __construct(TProcessor $processor,
TServerTransport $transport,
TTransportFactory $inputTransportFactory,
TTransportFactory $outputTransportFactory,
Expand Down