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
Channel $channel,
$method,
$deserialize,
$options = []
array $options = []
) {
if (array_key_exists('timeout', $options) &&
is_numeric($timeout = $options['timeout'])
......@@ -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()
{
......@@ -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()
{
......@@ -105,7 +105,7 @@ abstract class AbstractCall
}
/**
* @return string The URI of the endpoint.
* @return string The URI of the endpoint
*/
public function getPeer()
{
......@@ -167,8 +167,7 @@ abstract class AbstractCall
/**
* Set the CallCredentials for the underlying Call.
*
* @param CallCredentials $call_credentials The CallCredentials
* object
* @param CallCredentials $call_credentials The CallCredentials object
*/
public function setCallCredentials($call_credentials)
{
......
......@@ -48,14 +48,14 @@ class BaseStub
private $update_metadata;
/**
* @param $hostname string
* @param $opts array
* @param string $hostname
* @param array $opts
* - 'update_metadata': (optional) a callback function which takes in a
* metadata array, and returns an updated metadata array
* - '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(
dirname(__FILE__).'/../../../../etc/roots.pem');
......@@ -98,7 +98,7 @@ class BaseStub
}
/**
* @return string The URI of the endpoint.
* @return string The URI of the endpoint
*/
public function getTarget()
{
......@@ -106,7 +106,7 @@ class BaseStub
}
/**
* @param $try_to_connect bool
* @param bool $try_to_connect (optional)
*
* @return int The grpc connectivity state
*/
......@@ -145,6 +145,12 @@ class BaseStub
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)
{
if ($new_state == \Grpc\CHANNEL_READY) {
......@@ -167,6 +173,10 @@ class BaseStub
/**
* 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)
{
......@@ -191,7 +201,7 @@ class BaseStub
*
* @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
*/
private function _validate_and_normalize_metadata($metadata)
......@@ -220,14 +230,16 @@ class BaseStub
* @param mixed $argument The argument to the method
* @param callable $deserialize A function that deserializes the response
* @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
*/
public function _simpleRequest($method,
$argument,
$deserialize,
$metadata = [],
$options = [])
array $metadata = [],
array $options = [])
{
$call = new UnaryCall($this->channel,
$method,
......@@ -251,17 +263,17 @@ class BaseStub
* output.
*
* @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 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
*/
public function _clientStreamRequest($method,
callable $deserialize,
$metadata = [],
$options = [])
array $metadata = [],
array $options = [])
{
$call = new ClientStreamingCall($this->channel,
$method,
......@@ -281,21 +293,23 @@ class BaseStub
}
/**
* Call a remote method that takes a single argument and returns a stream of
* responses.
* Call a remote method that takes a single argument and returns a stream
* of responses.
*
* @param string $method The name of the method to call
* @param mixed $argument The argument to the method
* @param callable $deserialize A function that deserializes the responses
* @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
*/
public function _serverStreamRequest($method,
$argument,
callable $deserialize,
$metadata = [],
$options = [])
array $metadata = [],
array $options = [])
{
$call = new ServerStreamingCall($this->channel,
$method,
......@@ -320,13 +334,15 @@ class BaseStub
* @param string $method The name of the method to call
* @param callable $deserialize A function that deserializes the responses
* @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
*/
public function _bidiRequest($method,
callable $deserialize,
$metadata = [],
$options = [])
array $metadata = [],
array $options = [])
{
$call = new BidiStreamingCall($this->channel,
$method,
......
......@@ -35,8 +35,8 @@
namespace Grpc;
/**
* Represents an active call that allows for sending and recieving messages in
* streams in any order.
* Represents an active call that allows for sending and recieving messages
* in streams in any order.
*/
class BidiStreamingCall extends AbstractCall
{
......@@ -44,6 +44,7 @@ class BidiStreamingCall extends AbstractCall
* Start the call.
*
* @param array $metadata Metadata to send with the call, if applicable
* (optional)
*/
public function start(array $metadata = [])
{
......@@ -76,10 +77,10 @@ class BidiStreamingCall extends AbstractCall
* writesDone is called.
*
* @param ByteBuffer $data The data to write
* @param array $options an array of options, possible keys:
* 'flags' => a number
* @param array $options An array of options, possible keys:
* 'flags' => a number (optional)
*/
public function write($data, $options = [])
public function write($data, array $options = [])
{
$message_array = ['message' => $this->serializeMessage($data)];
if (array_key_exists('flags', $options)) {
......@@ -103,8 +104,8 @@ class BidiStreamingCall extends AbstractCall
/**
* Wait for the server to send the status, and return it.
*
* @return \stdClass The status object, with integer $code, string $details,
* and array $metadata members
* @return \stdClass The status object, with integer $code, string
* $details, and array $metadata members
*/
public function getStatus()
{
......
......@@ -35,8 +35,8 @@
namespace Grpc;
/**
* Represents an active call that sends a stream of messages and then gets a
* single response.
* Represents an active call that sends a stream of messages and then gets
* a single response.
*/
class ClientStreamingCall extends AbstractCall
{
......@@ -44,8 +44,9 @@ class ClientStreamingCall extends AbstractCall
* Start the call.
*
* @param array $metadata Metadata to send with the call, if applicable
* (optional)
*/
public function start($metadata = [])
public function start(array $metadata = [])
{
$this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata,
......@@ -57,8 +58,8 @@ class ClientStreamingCall extends AbstractCall
* wait is called.
*
* @param ByteBuffer $data The data to write
* @param array $options an array of options, possible keys:
* 'flags' => a number
* @param array $options An array of options, possible keys:
* 'flags' => a number (optional)
*/
public function write($data, array $options = [])
{
......
......@@ -35,8 +35,8 @@
namespace Grpc;
/**
* Represents an active call that sends a single message and then gets a stream
* of responses.
* Represents an active call that sends a single message and then gets a
* stream of responses.
*/
class ServerStreamingCall extends AbstractCall
{
......@@ -45,10 +45,11 @@ class ServerStreamingCall extends AbstractCall
*
* @param mixed $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
* @param array $options an array of options, possible keys:
* 'flags' => a number
* (optional)
* @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)];
if (array_key_exists('flags', $options)) {
......@@ -82,8 +83,8 @@ class ServerStreamingCall extends AbstractCall
/**
* Wait for the server to send the status, and return it.
*
* @return \stdClass The status object, with integer $code, string $details,
* and array $metadata members
* @return \stdClass The status object, with integer $code, string
* $details, and array $metadata members
*/
public function getStatus()
{
......
......@@ -35,8 +35,8 @@
namespace Grpc;
/**
* Represents an active call that sends a single message and then gets a single
* response.
* Represents an active call that sends a single message and then gets a
* single response.
*/
class UnaryCall extends AbstractCall
{
......@@ -45,10 +45,11 @@ class UnaryCall extends AbstractCall
*
* @param mixed $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
* @param array $options an array of options, possible keys:
* 'flags' => a number
* (optional)
* @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)];
if (isset($options['flags'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment