Skip to content
Snippets Groups Projects
Commit 0c3e8dbc authored by thinkerou's avatar thinkerou
Browse files

fix code style

parent 9addf903
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ abstract class AbstractCall ...@@ -62,7 +62,7 @@ abstract class AbstractCall
Channel $channel, Channel $channel,
$method, $method,
$deserialize, $deserialize,
$options = [] array $options = []
) { ) {
if (array_key_exists('timeout', $options) && if (array_key_exists('timeout', $options) &&
is_numeric($timeout = $options['timeout']) is_numeric($timeout = $options['timeout'])
...@@ -89,7 +89,7 @@ abstract class AbstractCall ...@@ -89,7 +89,7 @@ abstract class AbstractCall
} }
/** /**
* @return mixed The metadata sent by the server. * @return mixed The metadata sent by the server
*/ */
public function getMetadata() public function getMetadata()
{ {
...@@ -97,7 +97,7 @@ abstract class AbstractCall ...@@ -97,7 +97,7 @@ abstract class AbstractCall
} }
/** /**
* @return mixed The trailing metadata sent by the server. * @return mixed The trailing metadata sent by the server
*/ */
public function getTrailingMetadata() public function getTrailingMetadata()
{ {
...@@ -105,7 +105,7 @@ abstract class AbstractCall ...@@ -105,7 +105,7 @@ abstract class AbstractCall
} }
/** /**
* @return string The URI of the endpoint. * @return string The URI of the endpoint
*/ */
public function getPeer() public function getPeer()
{ {
...@@ -167,8 +167,7 @@ abstract class AbstractCall ...@@ -167,8 +167,7 @@ abstract class AbstractCall
/** /**
* Set the CallCredentials for the underlying Call. * Set the CallCredentials for the underlying Call.
* *
* @param CallCredentials $call_credentials The CallCredentials * @param CallCredentials $call_credentials The CallCredentials object
* object
*/ */
public function setCallCredentials($call_credentials) public function setCallCredentials($call_credentials)
{ {
......
...@@ -48,14 +48,14 @@ class BaseStub ...@@ -48,14 +48,14 @@ class BaseStub
private $update_metadata; private $update_metadata;
/** /**
* @param $hostname string * @param string $hostname
* @param $opts array * @param array $opts
* - 'update_metadata': (optional) a callback function which takes in a * - 'update_metadata': (optional) a callback function which takes in a
* metadata array, and returns an updated metadata array * metadata array, and returns an updated metadata array
* - 'grpc.primary_user_agent': (optional) a user-agent string * - 'grpc.primary_user_agent': (optional) a user-agent string
* @param $channel Channel An already created Channel object * @param Channel $channel An already created Channel object (optional)
*/ */
public function __construct($hostname, $opts, $channel = null) public function __construct($hostname, $opts, Channel $channel = null)
{ {
$ssl_roots = file_get_contents( $ssl_roots = file_get_contents(
dirname(__FILE__).'/../../../../etc/roots.pem'); dirname(__FILE__).'/../../../../etc/roots.pem');
...@@ -98,7 +98,7 @@ class BaseStub ...@@ -98,7 +98,7 @@ class BaseStub
} }
/** /**
* @return string The URI of the endpoint. * @return string The URI of the endpoint
*/ */
public function getTarget() public function getTarget()
{ {
...@@ -106,7 +106,7 @@ class BaseStub ...@@ -106,7 +106,7 @@ class BaseStub
} }
/** /**
* @param $try_to_connect bool * @param bool $try_to_connect (optional)
* *
* @return int The grpc connectivity state * @return int The grpc connectivity state
*/ */
...@@ -145,6 +145,12 @@ class BaseStub ...@@ -145,6 +145,12 @@ class BaseStub
return $this->_checkConnectivityState($new_state); return $this->_checkConnectivityState($new_state);
} }
/**
* @param $new_state Connect state
*
* @return bool true if state is CHANNEL_READY
* @throw Exception if state is CHANNEL_FATAL_FAILURE
*/
private function _checkConnectivityState($new_state) private function _checkConnectivityState($new_state)
{ {
if ($new_state == \Grpc\CHANNEL_READY) { if ($new_state == \Grpc\CHANNEL_READY) {
...@@ -167,6 +173,10 @@ class BaseStub ...@@ -167,6 +173,10 @@ class BaseStub
/** /**
* constructs the auth uri for the jwt. * constructs the auth uri for the jwt.
*
* @param string $method The method string
*
* @return string The URL string
*/ */
private function _get_jwt_aud_uri($method) private function _get_jwt_aud_uri($method)
{ {
...@@ -191,7 +201,7 @@ class BaseStub ...@@ -191,7 +201,7 @@ class BaseStub
* *
* @param array $metadata The metadata map * @param array $metadata The metadata map
* *
* @return $metadata Validated and key-normalized metadata map * @return array $metadata Validated and key-normalized metadata map
* @throw InvalidArgumentException if key contains invalid characters * @throw InvalidArgumentException if key contains invalid characters
*/ */
private function _validate_and_normalize_metadata($metadata) private function _validate_and_normalize_metadata($metadata)
...@@ -220,14 +230,16 @@ class BaseStub ...@@ -220,14 +230,16 @@ class BaseStub
* @param mixed $argument The argument to the method * @param mixed $argument The argument to the method
* @param callable $deserialize A function that deserializes the response * @param callable $deserialize A function that deserializes the response
* @param array $metadata A metadata map to send to the server * @param array $metadata A metadata map to send to the server
* (optional)
* @param array $options An array of options (optional)
* *
* @return SimpleSurfaceActiveCall The active call object * @return SimpleSurfaceActiveCall The active call object
*/ */
public function _simpleRequest($method, public function _simpleRequest($method,
$argument, $argument,
$deserialize, $deserialize,
$metadata = [], array $metadata = [],
$options = []) array $options = [])
{ {
$call = new UnaryCall($this->channel, $call = new UnaryCall($this->channel,
$method, $method,
...@@ -251,17 +263,17 @@ class BaseStub ...@@ -251,17 +263,17 @@ class BaseStub
* output. * output.
* *
* @param string $method The name of the method to call * @param string $method The name of the method to call
* @param array $arguments An array or Traversable of arguments to stream to the
* server
* @param callable $deserialize A function that deserializes the response * @param callable $deserialize A function that deserializes the response
* @param array $metadata A metadata map to send to the server * @param array $metadata A metadata map to send to the server
* (optional)
* @param array $options An array of options (optional)
* *
* @return ClientStreamingSurfaceActiveCall The active call object * @return ClientStreamingSurfaceActiveCall The active call object
*/ */
public function _clientStreamRequest($method, public function _clientStreamRequest($method,
callable $deserialize, callable $deserialize,
$metadata = [], array $metadata = [],
$options = []) array $options = [])
{ {
$call = new ClientStreamingCall($this->channel, $call = new ClientStreamingCall($this->channel,
$method, $method,
...@@ -281,21 +293,23 @@ class BaseStub ...@@ -281,21 +293,23 @@ class BaseStub
} }
/** /**
* Call a remote method that takes a single argument and returns a stream of * Call a remote method that takes a single argument and returns a stream
* responses. * of responses.
* *
* @param string $method The name of the method to call * @param string $method The name of the method to call
* @param mixed $argument The argument to the method * @param mixed $argument The argument to the method
* @param callable $deserialize A function that deserializes the responses * @param callable $deserialize A function that deserializes the responses
* @param array $metadata A metadata map to send to the server * @param array $metadata A metadata map to send to the server
* (optional)
* @param array $options An array of options (optional)
* *
* @return ServerStreamingSurfaceActiveCall The active call object * @return ServerStreamingSurfaceActiveCall The active call object
*/ */
public function _serverStreamRequest($method, public function _serverStreamRequest($method,
$argument, $argument,
callable $deserialize, callable $deserialize,
$metadata = [], array $metadata = [],
$options = []) array $options = [])
{ {
$call = new ServerStreamingCall($this->channel, $call = new ServerStreamingCall($this->channel,
$method, $method,
...@@ -320,13 +334,15 @@ class BaseStub ...@@ -320,13 +334,15 @@ class BaseStub
* @param string $method The name of the method to call * @param string $method The name of the method to call
* @param callable $deserialize A function that deserializes the responses * @param callable $deserialize A function that deserializes the responses
* @param array $metadata A metadata map to send to the server * @param array $metadata A metadata map to send to the server
* (optional)
* @param array $options An array of options (optional)
* *
* @return BidiStreamingSurfaceActiveCall The active call object * @return BidiStreamingSurfaceActiveCall The active call object
*/ */
public function _bidiRequest($method, public function _bidiRequest($method,
callable $deserialize, callable $deserialize,
$metadata = [], array $metadata = [],
$options = []) array $options = [])
{ {
$call = new BidiStreamingCall($this->channel, $call = new BidiStreamingCall($this->channel,
$method, $method,
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
namespace Grpc; namespace Grpc;
/** /**
* Represents an active call that allows for sending and recieving messages in * Represents an active call that allows for sending and recieving messages
* streams in any order. * in streams in any order.
*/ */
class BidiStreamingCall extends AbstractCall class BidiStreamingCall extends AbstractCall
{ {
...@@ -44,6 +44,7 @@ class BidiStreamingCall extends AbstractCall ...@@ -44,6 +44,7 @@ class BidiStreamingCall extends AbstractCall
* Start the call. * Start the call.
* *
* @param array $metadata Metadata to send with the call, if applicable * @param array $metadata Metadata to send with the call, if applicable
* (optional)
*/ */
public function start(array $metadata = []) public function start(array $metadata = [])
{ {
...@@ -76,10 +77,10 @@ class BidiStreamingCall extends AbstractCall ...@@ -76,10 +77,10 @@ class BidiStreamingCall extends AbstractCall
* writesDone is called. * writesDone is called.
* *
* @param ByteBuffer $data The data to write * @param ByteBuffer $data The data to write
* @param array $options an array of options, possible keys: * @param array $options An array of options, possible keys:
* 'flags' => a number * 'flags' => a number (optional)
*/ */
public function write($data, $options = []) public function write($data, array $options = [])
{ {
$message_array = ['message' => $this->serializeMessage($data)]; $message_array = ['message' => $this->serializeMessage($data)];
if (array_key_exists('flags', $options)) { if (array_key_exists('flags', $options)) {
...@@ -103,8 +104,8 @@ class BidiStreamingCall extends AbstractCall ...@@ -103,8 +104,8 @@ class BidiStreamingCall extends AbstractCall
/** /**
* Wait for the server to send the status, and return it. * Wait for the server to send the status, and return it.
* *
* @return \stdClass The status object, with integer $code, string $details, * @return \stdClass The status object, with integer $code, string
* and array $metadata members * $details, and array $metadata members
*/ */
public function getStatus() public function getStatus()
{ {
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
namespace Grpc; namespace Grpc;
/** /**
* Represents an active call that sends a stream of messages and then gets a * Represents an active call that sends a stream of messages and then gets
* single response. * a single response.
*/ */
class ClientStreamingCall extends AbstractCall class ClientStreamingCall extends AbstractCall
{ {
...@@ -44,8 +44,9 @@ class ClientStreamingCall extends AbstractCall ...@@ -44,8 +44,9 @@ class ClientStreamingCall extends AbstractCall
* Start the call. * Start the call.
* *
* @param array $metadata Metadata to send with the call, if applicable * @param array $metadata Metadata to send with the call, if applicable
* (optional)
*/ */
public function start($metadata = []) public function start(array $metadata = [])
{ {
$this->call->startBatch([ $this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata, OP_SEND_INITIAL_METADATA => $metadata,
...@@ -57,8 +58,8 @@ class ClientStreamingCall extends AbstractCall ...@@ -57,8 +58,8 @@ class ClientStreamingCall extends AbstractCall
* wait is called. * wait is called.
* *
* @param ByteBuffer $data The data to write * @param ByteBuffer $data The data to write
* @param array $options an array of options, possible keys: * @param array $options An array of options, possible keys:
* 'flags' => a number * 'flags' => a number (optional)
*/ */
public function write($data, array $options = []) public function write($data, array $options = [])
{ {
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
namespace Grpc; namespace Grpc;
/** /**
* Represents an active call that sends a single message and then gets a stream * Represents an active call that sends a single message and then gets a
* of responses. * stream of responses.
*/ */
class ServerStreamingCall extends AbstractCall class ServerStreamingCall extends AbstractCall
{ {
...@@ -45,10 +45,11 @@ class ServerStreamingCall extends AbstractCall ...@@ -45,10 +45,11 @@ class ServerStreamingCall extends AbstractCall
* *
* @param mixed $data The data to send * @param mixed $data The data to send
* @param array $metadata Metadata to send with the call, if applicable * @param array $metadata Metadata to send with the call, if applicable
* @param array $options an array of options, possible keys: * (optional)
* 'flags' => a number * @param array $options An array of options, possible keys:
* 'flags' => a number (optional)
*/ */
public function start($data, $metadata = [], $options = []) public function start($data, array $metadata = [], array $options = [])
{ {
$message_array = ['message' => $this->serializeMessage($data)]; $message_array = ['message' => $this->serializeMessage($data)];
if (array_key_exists('flags', $options)) { if (array_key_exists('flags', $options)) {
...@@ -82,8 +83,8 @@ class ServerStreamingCall extends AbstractCall ...@@ -82,8 +83,8 @@ class ServerStreamingCall extends AbstractCall
/** /**
* Wait for the server to send the status, and return it. * Wait for the server to send the status, and return it.
* *
* @return \stdClass The status object, with integer $code, string $details, * @return \stdClass The status object, with integer $code, string
* and array $metadata members * $details, and array $metadata members
*/ */
public function getStatus() public function getStatus()
{ {
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
namespace Grpc; namespace Grpc;
/** /**
* Represents an active call that sends a single message and then gets a single * Represents an active call that sends a single message and then gets a
* response. * single response.
*/ */
class UnaryCall extends AbstractCall class UnaryCall extends AbstractCall
{ {
...@@ -45,10 +45,11 @@ class UnaryCall extends AbstractCall ...@@ -45,10 +45,11 @@ class UnaryCall extends AbstractCall
* *
* @param mixed $data The data to send * @param mixed $data The data to send
* @param array $metadata Metadata to send with the call, if applicable * @param array $metadata Metadata to send with the call, if applicable
* @param array $options an array of options, possible keys: * (optional)
* 'flags' => a number * @param array $options An array of options, possible keys:
* 'flags' => a number (optional)
*/ */
public function start($data, $metadata = [], $options = []) public function start($data, array $metadata = [], array $options = [])
{ {
$message_array = ['message' => $this->serializeMessage($data)]; $message_array = ['message' => $this->serializeMessage($data)];
if (isset($options['flags'])) { if (isset($options['flags'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment