Skip to content

Commit b234b84

Browse files
committed
fix cs
1 parent 8bf200c commit b234b84

8 files changed

Lines changed: 26 additions & 28 deletions

File tree

src/Collection.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Patchlevel\Rango;
66

7+
use function assert;
8+
use function is_int;
9+
710
final class Collection
811
{
912
public function __construct(
@@ -19,8 +22,8 @@ public function __construct(
1922
*/
2023
public function countDocuments(array $filter = [], array $options = []): int
2124
{
22-
/** @var int $count */
2325
$count = $this->client->run(new Operation\Count($this->databaseName, $this->collectionName, $filter, $options));
26+
assert(is_int($count));
2427

2528
return $count;
2629
}
@@ -31,8 +34,8 @@ public function countDocuments(array $filter = [], array $options = []): int
3134
*/
3235
public function deleteMany(array $filter, array $options = []): DeleteResult
3336
{
34-
/** @var DeleteResult $result */
3537
$result = $this->client->run(new Operation\Delete($this->databaseName, $this->collectionName, $filter, true));
38+
assert($result instanceof DeleteResult);
3639

3740
return $result;
3841
}
@@ -43,8 +46,8 @@ public function deleteMany(array $filter, array $options = []): DeleteResult
4346
*/
4447
public function deleteOne(array $filter, array $options = []): DeleteResult
4548
{
46-
/** @var DeleteResult $result */
4749
$result = $this->client->run(new Operation\Delete($this->databaseName, $this->collectionName, $filter, false));
50+
assert($result instanceof DeleteResult);
4851

4952
return $result;
5053
}
@@ -57,13 +60,11 @@ public function drop(): void
5760
/**
5861
* @param array<string, mixed> $filter
5962
* @param array<string, mixed> $options
60-
*
61-
* @return Cursor
6263
*/
6364
public function find(array $filter = [], array $options = []): Cursor
6465
{
65-
/** @var Cursor $cursor */
6666
$cursor = $this->client->run(new Operation\Find($this->databaseName, $this->collectionName, $filter, $options));
67+
assert($cursor instanceof Cursor);
6768

6869
return $cursor;
6970
}
@@ -76,8 +77,8 @@ public function find(array $filter = [], array $options = []): Cursor
7677
*/
7778
public function findOne(array $filter = [], array $options = []): array|null
7879
{
79-
/** @var Cursor|null $result */
8080
$result = $this->client->run(new Operation\FindOne($this->databaseName, $this->collectionName, $filter, $options));
81+
assert($result instanceof Cursor || $result === null);
8182

8283
if (!$result instanceof Cursor) {
8384
return null;
@@ -94,8 +95,8 @@ public function findOne(array $filter = [], array $options = []): array|null
9495
*/
9596
public function insertMany(array $documents, array $options = []): InsertManyResult
9697
{
97-
/** @var InsertManyResult $result */
9898
$result = $this->client->run(new Operation\InsertMany($this->databaseName, $this->collectionName, $documents, $options));
99+
assert($result instanceof InsertManyResult);
99100

100101
return $result;
101102
}
@@ -106,8 +107,8 @@ public function insertMany(array $documents, array $options = []): InsertManyRes
106107
*/
107108
public function insertOne(array $document, array $options = []): InsertOneResult
108109
{
109-
/** @var InsertOneResult $result */
110110
$result = $this->client->run(new Operation\InsertOne($this->databaseName, $this->collectionName, $document, $options));
111+
assert($result instanceof InsertOneResult);
111112

112113
return $result;
113114
}
@@ -119,8 +120,8 @@ public function insertOne(array $document, array $options = []): InsertOneResult
119120
*/
120121
public function replaceOne(array $filter, array $replacement, array $options = []): UpdateResult
121122
{
122-
/** @var UpdateResult $result */
123123
$result = $this->client->run(new Operation\ReplaceOne($this->databaseName, $this->collectionName, $filter, $replacement, $options));
124+
assert($result instanceof UpdateResult);
124125

125126
return $result;
126127
}
@@ -132,8 +133,8 @@ public function replaceOne(array $filter, array $replacement, array $options = [
132133
*/
133134
public function updateMany(array $filter, array $update, array $options = []): UpdateResult
134135
{
135-
/** @var UpdateResult $result */
136136
$result = $this->client->run(new Operation\Update($this->databaseName, $this->collectionName, $filter, $update, $options, true));
137+
assert($result instanceof UpdateResult);
137138

138139
return $result;
139140
}
@@ -145,22 +146,20 @@ public function updateMany(array $filter, array $update, array $options = []): U
145146
*/
146147
public function updateOne(array $filter, array $update, array $options = []): UpdateResult
147148
{
148-
/** @var UpdateResult $result */
149149
$result = $this->client->run(new Operation\Update($this->databaseName, $this->collectionName, $filter, $update, $options, false));
150+
assert($result instanceof UpdateResult);
150151

151152
return $result;
152153
}
153154

154155
/**
155156
* @param list<array<string, mixed>> $pipeline
156157
* @param array<string, mixed> $options
157-
*
158-
* @return Cursor
159158
*/
160159
public function aggregate(array $pipeline, array $options = []): Cursor
161160
{
162-
/** @var Cursor $cursor */
163161
$cursor = $this->client->run(new Operation\Aggregate($this->databaseName, $this->collectionName, $pipeline, $options));
162+
assert($cursor instanceof Cursor);
164163

165164
return $cursor;
166165
}
@@ -187,8 +186,8 @@ public function distinct(string $fieldName, array $filter = [], array $options =
187186
*/
188187
public function findOneAndDelete(array $filter, array $options = []): array|null
189188
{
190-
/** @var Cursor|null $result */
191189
$result = $this->client->run(new Operation\FindOneAndDelete($this->databaseName, $this->collectionName, $filter, $options));
190+
assert($result instanceof Cursor || $result === null);
192191

193192
if (!$result instanceof Cursor) {
194193
return null;
@@ -208,8 +207,8 @@ public function findOneAndDelete(array $filter, array $options = []): array|null
208207
*/
209208
public function findOneAndReplace(array $filter, array $replacement, array $options = []): array|null
210209
{
211-
/** @var Cursor|null $result */
212210
$result = $this->client->run(new Operation\FindOneAndReplace($this->databaseName, $this->collectionName, $filter, $replacement, $options));
211+
assert($result instanceof Cursor || $result === null);
213212

214213
if (!$result instanceof Cursor) {
215214
return null;
@@ -229,8 +228,8 @@ public function findOneAndReplace(array $filter, array $replacement, array $opti
229228
*/
230229
public function findOneAndUpdate(array $filter, array $update, array $options = []): array|null
231230
{
232-
/** @var Cursor|null $result */
233231
$result = $this->client->run(new Operation\FindOneAndUpdate($this->databaseName, $this->collectionName, $filter, $update, $options));
232+
assert($result instanceof Cursor || $result === null);
234233

235234
if (!$result instanceof Cursor) {
236235
return null;
@@ -243,12 +242,12 @@ public function findOneAndUpdate(array $filter, array $update, array $options =
243242

244243
/**
245244
* @param list<array<string, list<array<string, mixed>>>> $operations
246-
* @param array<string, mixed> $options
245+
* @param array<string, mixed> $options
247246
*/
248247
public function bulkWrite(array $operations, array $options = []): BulkWriteResult
249248
{
250-
/** @var BulkWriteResult $result */
251249
$result = $this->client->run(new Operation\BulkWrite($this->databaseName, $this->collectionName, $operations, $options));
250+
assert($result instanceof BulkWriteResult);
252251

253252
return $result;
254253
}

src/Cursor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getIterator(): Traversable
3535
break;
3636
}
3737

38-
yield $this->decode((string) $item);
38+
yield $this->decode((string)$item);
3939
}
4040

4141
return;

src/Database.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ public function __construct(
1212
) {
1313
}
1414

15-
/** @return Collection */
1615
public function getCollection(string $collectionName): Collection
1716
{
1817
return new Collection($this->client, $this->databaseName, $collectionName);
1918
}
2019

21-
/** @return Collection */
2220
public function selectCollection(string $collectionName): Collection
2321
{
2422
return $this->getCollection($collectionName);

src/Operation/Aggregate.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public function __construct(
2222
) {
2323
}
2424

25-
/** @return Cursor */
2625
public function execute(PDO $pdo, QueryBuilder $queryBuilder): Cursor
2726
{
2827
$sql = $queryBuilder->createAggregate($this->database, $this->collection, $this->pipeline, $this->options);

src/Operation/BulkWrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class BulkWrite implements Operation
1616
{
1717
/**
1818
* @param list<array<string, list<array<string, mixed>>>> $operations
19-
* @param array<string, mixed> $options
19+
* @param array<string, mixed> $options
2020
*/
2121
public function __construct(
2222
public readonly string $database,

src/Operation/Count.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function execute(PDO $pdo, QueryBuilder $queryBuilder): int
3131
return 0;
3232
}
3333

34-
return (int) $statement->fetchColumn();
34+
return (int)$statement->fetchColumn();
3535
}
3636
}

tests/MongoIntegrationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use MongoDB\Client;
88
use MongoDB\Collection;
99
use MongoDB\Database;
10+
use RuntimeException;
1011

1112
use function class_exists;
1213
use function getenv;
@@ -18,7 +19,7 @@ private function requireMongoUri(): string
1819
$uri = getenv('MONGODB_URI');
1920

2021
if ($uri === false) {
21-
throw new \RuntimeException('MONGODB_URI is not set');
22+
throw new RuntimeException('MONGODB_URI is not set');
2223
}
2324

2425
return $uri;

tests/PostgresIntegrationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Patchlevel\Rango\Client;
88
use Patchlevel\Rango\Collection;
99
use Patchlevel\Rango\Database;
10+
use RuntimeException;
1011

1112
use function getenv;
1213

@@ -17,7 +18,7 @@ private function requirePostgresUri(): string
1718
$uri = getenv('POSTGRES_URI');
1819

1920
if ($uri === false) {
20-
throw new \RuntimeException('POSTGRES_URI is not set');
21+
throw new RuntimeException('POSTGRES_URI is not set');
2122
}
2223

2324
return $uri;

0 commit comments

Comments
 (0)