Skip to content

Commit 57040d2

Browse files
committed
Fix style issues
1 parent 9b0db83 commit 57040d2

13 files changed

Lines changed: 182 additions & 133 deletions

Datastore/src/DatastoreClient.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@
2121
use Google\ApiCore\ClientOptionsTrait;
2222
use Google\ApiCore\CredentialsWrapper;
2323
use Google\ApiCore\Options\ClientOptions;
24-
use Google\Auth\CredentialsLoader;
2524
use Google\Auth\FetchAuthTokenInterface;
2625
use Google\Cloud\Core\ApiHelperTrait;
27-
use Google\Cloud\Core\ArrayTrait;
28-
use Google\Cloud\Core\ClientTrait;
2926
use Google\Cloud\Core\DetectProjectIdTrait;
3027
use Google\Cloud\Core\EmulatorTrait;
3128
use Google\Cloud\Core\Int64;
@@ -37,8 +34,6 @@
3734
use Google\Cloud\Datastore\Query\QueryInterface;
3835
use Google\Cloud\Datastore\V1\Client\DatastoreClient as GapicDatastoreClient;
3936
use InvalidArgumentException;
40-
use Kreait\Firebase\Exception\Messaging\InvalidArgument;
41-
use Psr\Cache\CacheItemPoolInterface;
4237
use Psr\Http\Message\StreamInterface;
4338

4439
/**
@@ -989,7 +984,8 @@ public function deleteBatch(array $keys, array $options = [])
989984

990985
$mutations = [];
991986
foreach ($keys as $key) {
992-
$mutations[] = $this->operation->mutation('delete', $key, Key::class, $this->pluck('baseVersion', $options, false));
987+
$mutations[] = $this->operation
988+
->mutation('delete', $key, Key::class, $this->pluck('baseVersion', $options, false));
993989
}
994990

995991
return $this->operation->commit($mutations, $options);
@@ -1330,7 +1326,9 @@ private function parseSingleMutationResult(array $res)
13301326
private function getGapicClient(array $config): GapicDatastoreClient
13311327
{
13321328
if (isset($config['datastoreClient']) && (!$config['datastoreClient'] instanceof GapicDatastoreClient)) {
1333-
throw new InvalidArgumentException('The client configuration option must be an instance of ' . GapicDatastoreClient::class);
1329+
throw new InvalidArgumentException(
1330+
'The client configuration option must be an instance of ' . GapicDatastoreClient::class
1331+
);
13341332
}
13351333

13361334
return $config['datastoreClient'] ?? new GapicDatastoreClient($config);

Datastore/src/EntityMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function convertValue($type, $value, $className = Entity::class)
212212
// This code is taking that format to convert it into an Immutable date.
213213
$seconds = $value['seconds'];
214214
$nanos = $value['nanos'] ?? 0;
215-
$microseconds = (int)($nanos / 1000);
215+
$microseconds = (int) ($nanos / 1000);
216216
$result = \DateTimeImmutable::createFromFormat(
217217
'U.u',
218218
sprintf('%d.%06d', $seconds, $microseconds)

Datastore/src/Operation.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,20 @@
2929
use Google\Cloud\Datastore\Query\QueryInterface;
3030
use Google\Cloud\Datastore\V1\AllocateIdsRequest;
3131
use Google\Cloud\Datastore\V1\BeginTransactionRequest;
32-
use Google\Cloud\Datastore\V1\ExplainOptions;
33-
use Google\Cloud\Datastore\V1\QueryResultBatch\MoreResultsType;
3432
use Google\Cloud\Datastore\V1\Client\DatastoreClient;
3533
use Google\Cloud\Datastore\V1\CommitRequest;
3634
use Google\Cloud\Datastore\V1\CommitRequest\Mode;
3735
use Google\Cloud\Datastore\V1\EntityResult;
36+
use Google\Cloud\Datastore\V1\ExplainOptions;
3837
use Google\Cloud\Datastore\V1\Key as ProtobufKey;
3938
use Google\Cloud\Datastore\V1\LookupRequest;
4039
use Google\Cloud\Datastore\V1\Mutation;
40+
use Google\Cloud\Datastore\V1\QueryResultBatch\MoreResultsType;
4141
use Google\Cloud\Datastore\V1\ReadOptions;
42-
use Google\Cloud\Datastore\V1\ReadOptions_ReadConsistency;
4342
use Google\Cloud\Datastore\V1\RollbackRequest;
4443
use Google\Cloud\Datastore\V1\RunAggregationQueryRequest;
4544
use Google\Cloud\Datastore\V1\RunQueryRequest;
4645
use Google\Cloud\Datastore\V1\TransactionOptions;
47-
use Google\Protobuf\RepeatedField;
4846
use Google\Protobuf\Timestamp as ProtobufTimestamp;
4947
use InvalidArgumentException;
5048

@@ -128,7 +126,7 @@ public function __construct(
128126
'cursor' => function ($v) {
129127
return base64_encode($v);
130128
}
131-
],[
129+
], [
132130
'google.protobuf.Duration' => function ($v) {
133131
return $this->formatDurationFromApi($v);
134132
}
@@ -403,7 +401,6 @@ public function allocateIds(array $keys, array $options = [])
403401
foreach ($allocateIdsResponse->getKeys() as $index => $responseKey) {
404402
$path = $responseKey->getPath();
405403

406-
// @phpstan-ignore argument.type
407404
$lastPathElement = count($path) - 1;
408405

409406
$id = $path[$lastPathElement]->getId();
@@ -498,10 +495,11 @@ public function lookup(array $keys, array $options = [])
498495
'deferred' => [],
499496
];
500497

501-
/** @var protoEntity $found */
498+
/** @var EntityResult $found */
502499
foreach ($lookupResponse->getFound() as $found) {
503500
$result['found'][] = $this->mapEntityResult(
504-
$this->serializer->encodeMessage($found), $className
501+
$this->serializer->encodeMessage($found),
502+
$className
505503
);
506504
}
507505

@@ -747,7 +745,8 @@ public function runAggregationQuery(AggregationQuery $runQueryObj, array $option
747745
$runAggregationQueryRequest->setReadOptions($readOptions);
748746
}
749747

750-
$runAggregationQueryResponse = $this->gapicClient->runAggregationQuery($runAggregationQueryRequest, $callOptions);
748+
$runAggregationQueryResponse = $this->gapicClient
749+
->runAggregationQuery($runAggregationQueryRequest, $callOptions);
751750

752751
$res = $this->serializer->encodeMessage($runAggregationQueryResponse);
753752

@@ -1049,7 +1048,9 @@ private function createReadOptions(array $options)
10491048
}
10501049

10511050
if ($totalSet > 1) {
1052-
throw new InvalidArgumentException('Only one of `readConsistency`, `transaction` or `readTime` may be set.');
1051+
throw new InvalidArgumentException(
1052+
'Only one of `readConsistency`, `transaction` or `readTime` may be set.'
1053+
);
10531054
}
10541055

10551056
return $readOptions;

Datastore/tests/Snippet/DatastoreClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function testAllocateId()
342342
]
343343
]
344344
]
345-
));
345+
));
346346

347347
$res = $snippet->invoke('keyWithAllocatedId');
348348

Datastore/tests/Snippet/DatastoreSessionHandlerTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,18 @@ public function testClass()
9494
$this->gapicClient->commit(Argument::that(function (CommitRequest $request) {
9595
$value = 'name|'.serialize('Bob');
9696

97-
$this->assertEquals('sessions', $request->getMutations()[0]->getUpsert()->getKey()->getPartitionId()->getNamespaceId());
98-
$this->assertEquals('PHPSESSID', $request->getMutations()[0]->getUpsert()->getKey()->getPath()[0]->getKind());
99-
$this->assertEquals($value, $request->getMutations()[0]->getUpsert()->getProperties()['data']->getStringValue());
97+
$this->assertEquals(
98+
'sessions',
99+
$request->getMutations()[0]->getUpsert()->getKey()->getPartitionId()->getNamespaceId()
100+
);
101+
$this->assertEquals(
102+
'PHPSESSID',
103+
$request->getMutations()[0]->getUpsert()->getKey()->getPath()[0]->getKind()
104+
);
105+
$this->assertEquals(
106+
$value,
107+
$request->getMutations()[0]->getUpsert()->getProperties()['data']->getStringValue()
108+
);
100109
$this->assertNotEmpty($request->getMutations()[0]->getUpsert()->getProperties()['t']);
101110
return true;
102111
}), Argument::any())

Datastore/tests/Snippet/EntityTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public function testClassEntityType()
8282
->willReturn(self::generateProto(CommitResponse::class, [
8383
'mutationResults' => [['version' => 1]]
8484
]));
85-
$gapicClient->lookup(Argument::any(), Argument::any()
86-
)->shouldBeCalled()
85+
$gapicClient->lookup(Argument::any(), Argument::any())->shouldBeCalled()
8786
->willReturn(self::generateProto(LookupResponse::class, [
8887
'found' => [
8988
[

Datastore/tests/Snippet/ReadOnlyTransactionTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public function testLookup()
116116
{
117117
$this->gapicClient->beginTransaction(Argument::any(), Argument::any())
118118
->shouldBeCalled()
119-
->willReturn(self::generateProto(BeginTransactionResponse::class, ['transaction' => base64_encode(self::TRANSACTION)]));
119+
->willReturn(self::generateProto(BeginTransactionResponse::class, [
120+
'transaction' => base64_encode(self::TRANSACTION)
121+
]));
120122

121123
$snippet = $this->snippetFromMethod(ReadOnlyTransaction::class, 'lookup');
122124
$snippet->addLocal('datastore', $this->client);
@@ -154,7 +156,9 @@ public function testLookupBatch()
154156
{
155157
$this->gapicClient->beginTransaction(Argument::any(), Argument::any())
156158
->shouldBeCalled()
157-
->willReturn(self::generateProto(BeginTransactionResponse::class, ['transaction' => base64_encode(self::TRANSACTION)]));
159+
->willReturn(self::generateProto(BeginTransactionResponse::class, [
160+
'transaction' => base64_encode(self::TRANSACTION)
161+
]));
158162

159163
$snippet = $this->snippetFromMethod(ReadOnlyTransaction::class, 'lookupBatch');
160164
$snippet->addLocal('datastore', $this->client);
@@ -207,7 +211,9 @@ public function testRunQuery()
207211
{
208212
$this->gapicClient->beginTransaction(Argument::any(), Argument::any())
209213
->shouldBeCalled()
210-
->willReturn(self::generateProto(BeginTransactionResponse::class, ['transaction' => base64_encode(self::TRANSACTION)]));
214+
->willReturn(self::generateProto(BeginTransactionResponse::class, [
215+
'transaction' => base64_encode(self::TRANSACTION)
216+
]));
211217

212218
$snippet = $this->snippetFromMethod(ReadOnlyTransaction::class, 'runQuery');
213219
$snippet->addLocal('datastore', $this->client);
@@ -253,7 +259,9 @@ public function testRollback()
253259
{
254260
$this->gapicClient->beginTransaction(Argument::any(), Argument::any())
255261
->shouldBeCalled()
256-
->willReturn(self::generateProto(BeginTransactionResponse::class, ['transaction' => base64_encode(self::TRANSACTION)]));
262+
->willReturn(self::generateProto(BeginTransactionResponse::class, [
263+
'transaction' => base64_encode(self::TRANSACTION)
264+
]));
257265

258266
$snippet = $this->snippetFromMethod(ReadOnlyTransaction::class, 'rollback');
259267
$snippet->addLocal('transaction', $this->client->readOnlyTransaction());

Datastore/tests/Snippet/TransactionTest.php

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function setUp(): void
6868

6969
$this->gapicClient->beginTransaction(Argument::any(), Argument::any())
7070
->shouldBeCalled()
71-
->willReturn(self::generateProto(BeginTransactionResponse::class, ['transaction' => base64_encode(self::TRANSACTION)]));
71+
->willReturn(self::generateProto(BeginTransactionResponse::class, [
72+
'transaction' => base64_encode(self::TRANSACTION)
73+
]));
7274

7375
$this->client = new DatastoreClient([
7476
'datastoreClient' => $this->gapicClient->reveal()
@@ -209,13 +211,13 @@ public function testUpsert()
209211
]));
210212

211213
$this->gapicClient->commit(
212-
Argument::that(function (CommitRequest $request) {
214+
Argument::that(function (CommitRequest $request) {
213215
$this->assertEquals(self::TRANSACTION, $request->getTransaction());
214216
$this->assertEquals('upsert', $request->getMutations()[0]->getOperation());
215217
return true;
216-
}),
217-
Argument::any()
218-
)
218+
}),
219+
Argument::any()
220+
)
219221
->shouldBeCalled()
220222
->willReturn(self::generateProto(CommitResponse::class, [
221223
'mutationResults' => [
@@ -237,13 +239,13 @@ public function testUpsertBatch()
237239
]);
238240

239241
$this->gapicClient->commit(
240-
Argument::that(function (CommitRequest $request) {
242+
Argument::that(function (CommitRequest $request) {
241243
$this->assertEquals(self::TRANSACTION, $request->getTransaction());
242244
$this->assertEquals('upsert', $request->getMutations()[0]->getOperation());
243245
return true;
244-
}),
245-
Argument::any()
246-
)
246+
}),
247+
Argument::any()
248+
)
247249
->shouldBeCalled()
248250
->willReturn(self::generateProto(CommitResponse::class, [
249251
'mutationResults' => [
@@ -261,13 +263,13 @@ public function testDelete()
261263
$snippet->addLocal('transaction', $this->transaction);
262264

263265
$this->gapicClient->commit(
264-
Argument::that(function (CommitRequest $request) {
266+
Argument::that(function (CommitRequest $request) {
265267
$this->assertEquals(self::TRANSACTION, $request->getTransaction());
266268
$this->assertEquals('delete', $request->getMutations()[0]->getOperation());
267269
return true;
268-
}),
269-
Argument::any()
270-
)
270+
}),
271+
Argument::any()
272+
)
271273
->shouldBeCalled()
272274
->willReturn(self::generateProto(CommitResponse::class, [
273275
'mutationResults' => [
@@ -285,13 +287,13 @@ public function testDeleteBatch()
285287
$snippet->addLocal('transaction', $this->transaction);
286288

287289
$this->gapicClient->commit(
288-
Argument::that(function (CommitRequest $request) {
290+
Argument::that(function (CommitRequest $request) {
289291
$this->assertEquals(self::TRANSACTION, $request->getTransaction());
290292
$this->assertEquals('delete', $request->getMutations()[0]->getOperation());
291293
return true;
292-
}),
293-
Argument::any()
294-
)
294+
}),
295+
Argument::any()
296+
)
295297
->shouldBeCalled()
296298
->willReturn(self::generateProto(CommitResponse::class, [
297299
'mutationResults' => [
@@ -310,12 +312,12 @@ public function testLookup()
310312
$snippet->addLocal('transaction', $this->transaction);
311313

312314
$this->gapicClient->lookup(
313-
Argument::that(function (LookupRequest $request) {
315+
Argument::that(function (LookupRequest $request) {
314316
$this->assertEquals(self::TRANSACTION, $request->getReadOptions()->getTransaction());
315317
return true;
316-
}),
317-
Argument::any()
318-
)
318+
}),
319+
Argument::any()
320+
)
319321
->shouldBeCalled()
320322
->willReturn(self::generateProto(LookupResponse::class, [
321323
'found' => [
@@ -347,12 +349,12 @@ public function testLookupBatch()
347349
$snippet->addLocal('transaction', $this->transaction);
348350

349351
$this->gapicClient->lookup(
350-
Argument::that(function (LookupRequest $request) {
352+
Argument::that(function (LookupRequest $request) {
351353
$this->assertEquals(self::TRANSACTION, $request->getReadOptions()->getTransaction());
352354
return true;
353-
}),
354-
Argument::any()
355-
)
355+
}),
356+
Argument::any()
357+
)
356358
->shouldBeCalled()
357359
->willReturn(self::generateProto(LookupResponse::class, [
358360
'found' => [
@@ -405,12 +407,12 @@ public function testRunQuery()
405407
$snippet->addLocal('query', $query->reveal());
406408

407409
$this->gapicClient->runQuery(
408-
Argument::that(function (RunQueryRequest $request) {
410+
Argument::that(function (RunQueryRequest $request) {
409411
$this->assertEquals(self::TRANSACTION, $request->getReadOptions()->getTransaction());
410412
return true;
411-
}),
412-
Argument::any()
413-
)
413+
}),
414+
Argument::any()
415+
)
414416
->shouldBeCalled()
415417
->willReturn(self::generateProto(RunQueryResponse::class, [
416418
'batch' => [
@@ -448,12 +450,12 @@ public function testRunAggregationQuery()
448450
$snippet->addLocal('query', $query->reveal());
449451

450452
$this->gapicClient->runAggregationQuery(
451-
Argument::that(function (RunAggregationQueryRequest $request) {
453+
Argument::that(function (RunAggregationQueryRequest $request) {
452454
$this->assertEquals(self::TRANSACTION, $request->getReadOptions()->getTransaction());
453455
return true;
454-
}),
455-
Argument::any()
456-
)
456+
}),
457+
Argument::any()
458+
)
457459
->shouldBeCalled()
458460
->willReturn(self::generateProto(RunAggregationQueryResponse::class, [
459461
'batch' => [
@@ -479,18 +481,18 @@ public function testCommit()
479481
$keys = [
480482
$this->client->key('Person', 'Bob'),
481483
$this->client->key('Person', 'John')
482-
];
484+
];
483485

484-
$this->transaction->deleteBatch($keys);
486+
$this->transaction->deleteBatch($keys);
485487

486-
$snippet = $this->snippetFromMethod(Transaction::class, 'commit');
487-
$snippet->addLocal('transaction', $this->transaction);
488+
$snippet = $this->snippetFromMethod(Transaction::class, 'commit');
489+
$snippet->addLocal('transaction', $this->transaction);
488490

489-
$this->gapicClient->commit(Argument::any(), Argument::any())
491+
$this->gapicClient->commit(Argument::any(), Argument::any())
490492
->shouldBeCalled()
491493
->willReturn(self::generateProto(CommitResponse::class, []));
492494

493-
$snippet->invoke();
495+
$snippet->invoke();
494496
}
495497

496498
public function testRollback()

Datastore/tests/System/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
TestHelpers::requireKeyfile('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
88
TestHelpers::systemTestShutdown(function () {
99
DatastoreTestCase::tearDownFixtures();
10-
});
10+
});

0 commit comments

Comments
 (0)