diff --git a/dev/src/DocGenerator/Parser/CodeParser.php b/dev/src/DocGenerator/Parser/CodeParser.php index cf0ca18865a2..6de9a1c842d5 100644 --- a/dev/src/DocGenerator/Parser/CodeParser.php +++ b/dev/src/DocGenerator/Parser/CodeParser.php @@ -610,11 +610,7 @@ private function hasNestedParams($description) return false; } - if ($description[0] === '{') { - return true; - } - - return false; + return $description[0] === '{'; } private function buildExceptions($exceptions) @@ -727,11 +723,7 @@ private function hasExternalType($type) return (strpos($type, $external['name']) !== false); }); - if (count($types) === 0) { - return false; - } - - return true; + return count($types) !== 0; } private function buildExternalType($type) diff --git a/src/Core/ArrayTrait.php b/src/Core/ArrayTrait.php index be8f58a1ba6b..7e9e2c557c56 100644 --- a/src/Core/ArrayTrait.php +++ b/src/Core/ArrayTrait.php @@ -88,11 +88,7 @@ private function isAssoc(array $arr) private function arrayFilterRemoveNull(array $arr) { return array_filter($arr, function ($element) { - if (!is_null($element)) { - return true; - } - - return false; + return !is_null($element); }); } diff --git a/src/Core/Exception/AbortedException.php b/src/Core/Exception/AbortedException.php index 842088b1fb00..208c4303f3ec 100644 --- a/src/Core/Exception/AbortedException.php +++ b/src/Core/Exception/AbortedException.php @@ -30,11 +30,7 @@ class AbortedException extends ServiceException public function getRetryDelay() { $metadata = array_filter($this->metadata, function ($metadataItem) { - if (array_key_exists('retryDelay', $metadataItem)) { - return true; - } - - return false; + return array_key_exists('retryDelay', $metadataItem); }); if (count($metadata) === 0) { diff --git a/src/Core/GrpcRequestWrapper.php b/src/Core/GrpcRequestWrapper.php index 2cd1f7db8611..f7a7ca49c3e8 100644 --- a/src/Core/GrpcRequestWrapper.php +++ b/src/Core/GrpcRequestWrapper.php @@ -123,11 +123,7 @@ public function send(callable $request, array $args, array $options = []) $backoff = new ExponentialBackoff($retries, function (\Exception $ex) { $statusCode = $ex->getCode(); - if (in_array($statusCode, $this->grpcRetryCodes)) { - return true; - } - - return false; + return in_array($statusCode, $this->grpcRetryCodes); }); if (!isset($grpcOptions['retrySettings'])) { diff --git a/src/Datastore/EntityMapper.php b/src/Datastore/EntityMapper.php index c4e38cc59ce7..0324778c815d 100644 --- a/src/Datastore/EntityMapper.php +++ b/src/Datastore/EntityMapper.php @@ -481,11 +481,7 @@ private function isEncoded($value) } // Encode the string again - if (base64_encode($decoded) != $value) { - return false; - } - - return true; + return base64_encode($decoded) == $value; } /** diff --git a/src/Storage/Bucket.php b/src/Storage/Bucket.php index 410b0140450d..3274fe1717fc 100644 --- a/src/Storage/Bucket.php +++ b/src/Storage/Bucket.php @@ -1032,11 +1032,7 @@ public function iam() */ private function isObjectNameRequired($data) { - if (is_string($data) || is_null($data)) { - return true; - } - - return false; + return is_string($data) || is_null($data); } /** diff --git a/src/Vision/Annotation/LikelihoodTrait.php b/src/Vision/Annotation/LikelihoodTrait.php index e73fec63ebfa..fd627be35795 100644 --- a/src/Vision/Annotation/LikelihoodTrait.php +++ b/src/Vision/Annotation/LikelihoodTrait.php @@ -58,10 +58,6 @@ private function likelihood($value, $strength) $levels = $this->likelihoodLevels[$strength]; - if (in_array($value, $levels)) { - return true; - } - - return false; + return in_array($value, $levels); } } diff --git a/tests/snippets/Datastore/DatastoreClientTest.php b/tests/snippets/Datastore/DatastoreClientTest.php index a7f560aecf38..2e0fff54592a 100644 --- a/tests/snippets/Datastore/DatastoreClientTest.php +++ b/tests/snippets/Datastore/DatastoreClientTest.php @@ -305,8 +305,7 @@ public function testInsert() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'insert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'insert'; })) ->shouldBeCalled() ->willReturn([ @@ -328,8 +327,7 @@ public function testInsertBatch() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'insert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'insert'; })) ->shouldBeCalled(); @@ -351,8 +349,7 @@ public function testUpdate() ])); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'update') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'update'; })) ->shouldBeCalled() ->willReturn([ @@ -376,8 +373,7 @@ public function testUpdateBatch() ]); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'update') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'update'; })) ->shouldBeCalled(); @@ -390,8 +386,7 @@ public function testUpsert() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'upsert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'upsert'; })) ->shouldBeCalled() ->willReturn([ @@ -411,8 +406,7 @@ public function testUpsertBatch() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'upsert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'upsert'; })) ->shouldBeCalled(); @@ -425,8 +419,7 @@ public function testDelete() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'delete') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'delete'; })) ->shouldBeCalled() ->willReturn([ @@ -446,8 +439,7 @@ public function testDeleteBatch() $snippet->addLocal('datastore', $this->client); $this->connection->commit(Argument::that(function ($args) { - if (array_keys($args['mutations'][0])[0] !== 'delete') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'delete'; })) ->shouldBeCalled(); diff --git a/tests/snippets/Datastore/TransactionTest.php b/tests/snippets/Datastore/TransactionTest.php index a6f701677d79..8f8177b5e69e 100644 --- a/tests/snippets/Datastore/TransactionTest.php +++ b/tests/snippets/Datastore/TransactionTest.php @@ -91,8 +91,7 @@ public function testInsert() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'insert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'insert'; })) ->shouldBeCalled() ->willReturn([ @@ -114,8 +113,7 @@ public function testInsertBatch() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'insert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'insert'; })) ->shouldBeCalled() ->willReturn([ @@ -142,8 +140,7 @@ public function testUpdate() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'update') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'update'; })) ->shouldBeCalled() ->willReturn([ @@ -169,8 +166,7 @@ public function testUpdateBatch() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'update') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'update'; })) ->shouldBeCalled(); @@ -188,8 +184,7 @@ public function testUpsert() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'upsert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'upsert'; })) ->shouldBeCalled() ->willReturn([ @@ -215,8 +210,7 @@ public function testUpsertBatch() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'upsert') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'upsert'; })) ->shouldBeCalled(); @@ -231,8 +225,7 @@ public function testDelete() $this->connection->commit(Argument::that(function ($args) { if ($args['transaction'] !== $this->transactionId) return false; - if (array_keys($args['mutations'][0])[0] !== 'delete') return false; - return true; + return array_keys($args['mutations'][0])[0] === 'delete'; })) ->shouldBeCalled() ->willReturn([ diff --git a/tests/unit/Datastore/TransactionTest.php b/tests/unit/Datastore/TransactionTest.php index 942a7db38cee..683309bd73c6 100644 --- a/tests/unit/Datastore/TransactionTest.php +++ b/tests/unit/Datastore/TransactionTest.php @@ -167,9 +167,7 @@ public function testDeleteBatch() public function testLookup() { $this->operation->lookup(Argument::type('array'), Argument::that(function ($arg) { - if ($arg['transaction'] !== $this->transactionId) return false; - - return true; + return $arg['transaction'] === $this->transactionId; }))->willReturn(['found' => ['foo']]); $this->transaction->setOperation($this->operation->reveal()); @@ -184,9 +182,7 @@ public function testLookup() public function testLookupBatch() { $this->operation->lookup(Argument::type('array'), Argument::that(function ($arg) { - if ($arg['transaction'] !== $this->transactionId) return false; - - return true; + return $arg['transaction'] === $this->transactionId; }))->willReturn([]); $this->transaction->setOperation($this->operation->reveal()); @@ -199,9 +195,7 @@ public function testLookupBatch() public function testRunQuery() { $this->operation->runQuery(Argument::type(QueryInterface::class), Argument::that(function ($arg) { - if ($arg['transaction'] !== $this->transactionId) return false; - - return true; + return $arg['transaction'] === $this->transactionId; }))->willReturn('test'); $this->transaction->setOperation($this->operation->reveal()); diff --git a/tests/unit/Firestore/CollectionReferenceTest.php b/tests/unit/Firestore/CollectionReferenceTest.php index 0e6a05474a4f..89dcc7f9fb5f 100644 --- a/tests/unit/Firestore/CollectionReferenceTest.php +++ b/tests/unit/Firestore/CollectionReferenceTest.php @@ -104,9 +104,8 @@ public function testAdd() ]; unset($args['writes'][0]['update']['name']); - if ($args !== $expected) return false; - - return true; + + return $args === $expected; }))->shouldBeCalled()->willReturn([[]]); $this->collection->___setProperty('connection', $this->connection->reveal()); diff --git a/tests/unit/Spanner/SpannerClientTest.php b/tests/unit/Spanner/SpannerClientTest.php index 571604982eb6..3764658fa3df 100644 --- a/tests/unit/Spanner/SpannerClientTest.php +++ b/tests/unit/Spanner/SpannerClientTest.php @@ -150,9 +150,7 @@ public function testCreateInstance() { $this->connection->createInstance(Argument::that(function ($arg) { if ($arg['name'] !== InstanceAdminClient::instanceName(self::PROJECT, self::INSTANCE)) return false; - if ($arg['config'] !== InstanceAdminClient::instanceConfigName(self::PROJECT, self::CONFIG)) return false; - - return true; + return $arg['config'] === InstanceAdminClient::instanceConfigName(self::PROJECT, self::CONFIG); })) ->shouldBeCalled() ->willReturn([ diff --git a/tests/unit/Spanner/TransactionTest.php b/tests/unit/Spanner/TransactionTest.php index 7d47103d8d93..fe868cebcefb 100644 --- a/tests/unit/Spanner/TransactionTest.php +++ b/tests/unit/Spanner/TransactionTest.php @@ -190,9 +190,7 @@ public function testExecute() $this->connection->executeStreamingSql(Argument::that(function ($arg) use ($sql) { if ($arg['transaction']['id'] !== self::TRANSACTION) return false; - if ($arg['sql'] !== $sql) return false; - - return true; + return $arg['sql'] === $sql; }))->shouldBeCalled()->willReturn($this->resultGenerator()); $this->refreshOperation(); @@ -212,9 +210,7 @@ public function testRead() if ($arg['transaction']['id'] !== self::TRANSACTION) return false; if ($arg['table'] !== $table) return false; if ($arg['keySet']['all'] !== true) return false; - if ($arg['columns'] !== ['ID']) return false; - - return true; + return $arg['columns'] === ['ID']; }))->shouldBeCalled()->willReturn($this->resultGenerator()); $this->refreshOperation(); diff --git a/tests/unit/Translate/TranslateClientTest.php b/tests/unit/Translate/TranslateClientTest.php index bd321cf0feab..ff4d64a365ce 100644 --- a/tests/unit/Translate/TranslateClientTest.php +++ b/tests/unit/Translate/TranslateClientTest.php @@ -42,11 +42,7 @@ public function testWithNoKey() $client = new TranslateTestClient(); $this->connection->listTranslations(Argument::that(function($args) { - if (isset($args['key'])) { - return false; - } - - return true; + return !isset($args['key']); }))->shouldBeCalled()->willReturn([]); $client->setConnection($this->connection->reveal());