From 25e5f67bb95f4c848c003f19272b8c1030efbfe5 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 2 Feb 2015 11:05:01 -0800 Subject: [PATCH] Removed all instances of == and != in PHP code --- .../lib/Grpc/AbstractSurfaceActiveCall.php | 2 +- src/php/lib/Grpc/ActiveCall.php | 7 +--- .../Grpc/ServerStreamingSurfaceActiveCall.php | 2 +- src/php/tests/interop/interop_client.php | 34 +++++++++---------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/php/lib/Grpc/AbstractSurfaceActiveCall.php b/src/php/lib/Grpc/AbstractSurfaceActiveCall.php index 53c7d4cd1a4..83e4719c9a8 100755 --- a/src/php/lib/Grpc/AbstractSurfaceActiveCall.php +++ b/src/php/lib/Grpc/AbstractSurfaceActiveCall.php @@ -44,7 +44,7 @@ abstract class AbstractSurfaceActiveCall { protected function _read() { $response = $this->active_call->read(); - if ($response == null) { + if ($response === null) { return null; } return call_user_func($this->deserialize, $response); diff --git a/src/php/lib/Grpc/ActiveCall.php b/src/php/lib/Grpc/ActiveCall.php index e0ea43ab085..847cfee1ec2 100755 --- a/src/php/lib/Grpc/ActiveCall.php +++ b/src/php/lib/Grpc/ActiveCall.php @@ -66,12 +66,7 @@ class ActiveCall { * @param ByteBuffer $data The data to write */ public function write($data) { - if($this->call->start_write($data, - WRITE_ACCEPTED, - $this->flags) != OP_OK) { - // TODO(mlumish): more useful error - throw new \Exception("Cannot call write after writesDone"); - } + $this->call->start_write($data, WRITE_ACCEPTED, $this->flags); $this->completion_queue->pluck(WRITE_ACCEPTED, Timeval::inf_future()); } diff --git a/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php b/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php index 082f995d8aa..f131d6bab5c 100755 --- a/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php +++ b/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php @@ -31,7 +31,7 @@ class ServerStreamingSurfaceActiveCall extends AbstractSurfaceActiveCall { * @return An iterator of response values */ public function responses() { - while(($response = $this->_read()) != null) { + while(($response = $this->_read()) !== null) { yield $response; } } diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php index 2ff2be7bca0..d1f994a84b6 100755 --- a/src/php/tests/interop/interop_client.php +++ b/src/php/tests/interop/interop_client.php @@ -26,8 +26,8 @@ function hardAssert($value, $error_message) { */ function emptyUnary($stub) { list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait(); - hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); - hardAssert($result != null, 'Call completed with a null response'); + hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssert($result !== null, 'Call completed with a null response'); } /** @@ -49,14 +49,14 @@ function largeUnary($stub) { $request->setPayload($payload); list($result, $status) = $stub->UnaryCall($request)->wait(); - hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); - hardAssert($result != null, 'Call returned a null response'); + hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssert($result !== null, 'Call returned a null response'); $payload = $result->getPayload(); - hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, + hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, 'Payload had the wrong type'); - hardAssert(strlen($payload->getBody()) == $response_len, + hardAssert(strlen($payload->getBody()) === $response_len, 'Payload had the wrong length'); - hardAssert($payload->getBody() == str_repeat("\0", $response_len), + hardAssert($payload->getBody() === str_repeat("\0", $response_len), 'Payload had the wrong content'); } @@ -78,8 +78,8 @@ function clientStreaming($stub) { }, $request_lengths); list($result, $status) = $stub->StreamingInputCall($requests)->wait(); - hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully'); - hardAssert($result->getAggregatedPayloadSize() == 74922, + hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully'); + hardAssert($result->getAggregatedPayloadSize() === 74922, 'aggregated_payload_size was incorrect'); } @@ -100,15 +100,15 @@ function serverStreaming($stub) { } $call = $stub->StreamingOutputCall($request); - hardAssert($call->getStatus()->code == Grpc\STATUS_OK, + hardAssert($call->getStatus()->code === Grpc\STATUS_OK, 'Call did not complete successfully'); $i = 0; foreach($call->responses() as $value) { hardAssert($i < 4, 'Too many responses'); $payload = $value->getPayload(); - hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, + hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, 'Payload ' . $i . ' had the wrong type'); - hardAssert(strlen($payload->getBody()) == $sizes[$i], + hardAssert(strlen($payload->getBody()) === $sizes[$i], 'Response ' . $i . ' had the wrong length'); } } @@ -136,16 +136,16 @@ function pingPong($stub) { $call->write($request); $response = $call->read(); - hardAssert($response != null, 'Server returned too few responses'); + hardAssert($response !== null, 'Server returned too few responses'); $payload = $response->getPayload(); - hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE, + hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE, 'Payload ' . $i . ' had the wrong type'); - hardAssert(strlen($payload->getBody()) == $response_lengths[$i], + hardAssert(strlen($payload->getBody()) === $response_lengths[$i], 'Payload ' . $i . ' had the wrong length'); } $call->writesDone(); - hardAssert($call->read() == null, 'Server returned too many responses'); - hardAssert($call->getStatus()->code == Grpc\STATUS_OK, + hardAssert($call->read() === null, 'Server returned too many responses'); + hardAssert($call->getStatus()->code === Grpc\STATUS_OK, 'Call did not complete successfully'); }