Skip to content
Snippets Groups Projects
Commit d58199b1 authored by Stanislav Pavlovichev's avatar Stanislav Pavlovichev
Browse files

code style

phpdoc fix
isset to array_key_exists
parent 0e43d676
Branches
Tags
No related merge requests found
...@@ -34,8 +34,15 @@ ...@@ -34,8 +34,15 @@
namespace Grpc; namespace Grpc;
/**
* Class AbstractCall
* @package Grpc
*/
abstract class AbstractCall abstract class AbstractCall
{ {
/**
* @var Call
*/
protected $call; protected $call;
protected $deserialize; protected $deserialize;
protected $metadata; protected $metadata;
...@@ -51,13 +58,15 @@ abstract class AbstractCall ...@@ -51,13 +58,15 @@ abstract class AbstractCall
* the response * the response
* @param array $options Call options (optional) * @param array $options Call options (optional)
*/ */
public function __construct(Channel $channel, public function __construct(
$method, Channel $channel,
$deserialize, $method,
$options = []) $deserialize,
{ $options = []
if (isset($options['timeout']) && ) {
is_numeric($timeout = $options['timeout'])) { if (array_key_exists('timeout', $options) &&
is_numeric($timeout = $options['timeout'])
) {
$now = Timeval::now(); $now = Timeval::now();
$delta = new Timeval($timeout); $delta = new Timeval($timeout);
$deadline = $now->add($delta); $deadline = $now->add($delta);
...@@ -68,17 +77,19 @@ abstract class AbstractCall ...@@ -68,17 +77,19 @@ abstract class AbstractCall
$this->deserialize = $deserialize; $this->deserialize = $deserialize;
$this->metadata = null; $this->metadata = null;
$this->trailing_metadata = null; $this->trailing_metadata = null;
if (isset($options['call_credentials_callback']) && if (array_key_exists('call_credentials_callback', $options) &&
is_callable($call_credentials_callback = is_callable($call_credentials_callback =
$options['call_credentials_callback'])) { $options['call_credentials_callback'])
) {
$call_credentials = CallCredentials::createFromPlugin( $call_credentials = CallCredentials::createFromPlugin(
$call_credentials_callback); $call_credentials_callback
);
$this->call->setCredentials($call_credentials); $this->call->setCredentials($call_credentials);
} }
} }
/** /**
* @return The metadata sent by the server. * @return mixed The metadata sent by the server.
*/ */
public function getMetadata() public function getMetadata()
{ {
...@@ -86,7 +97,7 @@ abstract class AbstractCall ...@@ -86,7 +97,7 @@ abstract class AbstractCall
} }
/** /**
* @return The trailing metadata sent by the server. * @return mixed The trailing metadata sent by the server.
*/ */
public function getTrailingMetadata() public function getTrailingMetadata()
{ {
...@@ -114,7 +125,7 @@ abstract class AbstractCall ...@@ -114,7 +125,7 @@ abstract class AbstractCall
* *
* @param string $value The binary value to deserialize * @param string $value The binary value to deserialize
* *
* @return The deserialized value * @return mixed The deserialized value
*/ */
protected function deserializeResponse($value) protected function deserializeResponse($value)
{ {
......
...@@ -45,7 +45,7 @@ class BidiStreamingCall extends AbstractCall ...@@ -45,7 +45,7 @@ class BidiStreamingCall extends AbstractCall
* *
* @param array $metadata Metadata to send with the call, if applicable * @param array $metadata Metadata to send with the call, if applicable
*/ */
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,
...@@ -55,7 +55,7 @@ class BidiStreamingCall extends AbstractCall ...@@ -55,7 +55,7 @@ class BidiStreamingCall extends AbstractCall
/** /**
* Reads the next value from the server. * Reads the next value from the server.
* *
* @return The next value from the server, or null if there is none * @return mixed The next value from the server, or null if there is none
*/ */
public function read() public function read()
{ {
...@@ -82,7 +82,7 @@ class BidiStreamingCall extends AbstractCall ...@@ -82,7 +82,7 @@ class BidiStreamingCall extends AbstractCall
public function write($data, $options = []) public function write($data, $options = [])
{ {
$message_array = ['message' => $data->serialize()]; $message_array = ['message' => $data->serialize()];
if (isset($options['flags'])) { if (array_key_exists('flags', $options)) {
$message_array['flags'] = $options['flags']; $message_array['flags'] = $options['flags'];
} }
$this->call->startBatch([ $this->call->startBatch([
...@@ -103,8 +103,8 @@ class BidiStreamingCall extends AbstractCall ...@@ -103,8 +103,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 object The status object, with integer $code, string $details, * @return \stdClass The status object, with integer $code, string $details,
* and array $metadata members * and array $metadata members
*/ */
public function getStatus() public function getStatus()
{ {
......
...@@ -60,10 +60,10 @@ class ClientStreamingCall extends AbstractCall ...@@ -60,10 +60,10 @@ class ClientStreamingCall extends AbstractCall
* @param array $options an array of options, possible keys: * @param array $options an array of options, possible keys:
* 'flags' => a number * 'flags' => a number
*/ */
public function write($data, $options = []) public function write($data, array $options = [])
{ {
$message_array = ['message' => $data->serialize()]; $message_array = ['message' => $data->serialize()];
if (isset($options['flags'])) { if (array_key_exists('flags', $options)) {
$message_array['flags'] = $options['flags']; $message_array['flags'] = $options['flags'];
} }
$this->call->startBatch([ $this->call->startBatch([
...@@ -74,7 +74,7 @@ class ClientStreamingCall extends AbstractCall ...@@ -74,7 +74,7 @@ class ClientStreamingCall extends AbstractCall
/** /**
* Wait for the server to respond with data and a status. * Wait for the server to respond with data and a status.
* *
* @return [response data, status] * @return array [response data, status]
*/ */
public function wait() public function wait()
{ {
......
...@@ -36,14 +36,14 @@ namespace Grpc; ...@@ -36,14 +36,14 @@ 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 stream
* of reponses. * of responses.
*/ */
class ServerStreamingCall extends AbstractCall class ServerStreamingCall extends AbstractCall
{ {
/** /**
* Start the call. * Start the call.
* *
* @param $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: * @param array $options an array of options, possible keys:
* 'flags' => a number * 'flags' => a number
...@@ -51,7 +51,7 @@ class ServerStreamingCall extends AbstractCall ...@@ -51,7 +51,7 @@ class ServerStreamingCall extends AbstractCall
public function start($data, $metadata = [], $options = []) public function start($data, $metadata = [], $options = [])
{ {
$message_array = ['message' => $data->serialize()]; $message_array = ['message' => $data->serialize()];
if (isset($options['flags'])) { if (array_key_exists('flags', $options)) {
$message_array['flags'] = $options['flags']; $message_array['flags'] = $options['flags'];
} }
$event = $this->call->startBatch([ $event = $this->call->startBatch([
...@@ -64,7 +64,7 @@ class ServerStreamingCall extends AbstractCall ...@@ -64,7 +64,7 @@ class ServerStreamingCall extends AbstractCall
} }
/** /**
* @return An iterator of response values * @return mixed An iterator of response values
*/ */
public function responses() public function responses()
{ {
...@@ -82,8 +82,8 @@ class ServerStreamingCall extends AbstractCall ...@@ -82,8 +82,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 object The status object, with integer $code, string $details, * @return \stdClass The status object, with integer $code, string $details,
* and array $metadata members * and array $metadata members
*/ */
public function getStatus() public function getStatus()
{ {
......
...@@ -43,7 +43,7 @@ class UnaryCall extends AbstractCall ...@@ -43,7 +43,7 @@ class UnaryCall extends AbstractCall
/** /**
* Start the call. * Start the call.
* *
* @param $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: * @param array $options an array of options, possible keys:
* 'flags' => a number * 'flags' => a number
...@@ -66,7 +66,7 @@ class UnaryCall extends AbstractCall ...@@ -66,7 +66,7 @@ class UnaryCall extends AbstractCall
/** /**
* Wait for the server to respond with data and a status. * Wait for the server to respond with data and a status.
* *
* @return [response data, status] * @return array [response data, status]
*/ */
public function wait() public function wait()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment