Skip to content

Commit 0548d90

Browse files
committed
Remove redundant type casts
1 parent 2d5fb74 commit 0548d90

32 files changed

+62
-62
lines changed

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function __construct(string $uri = 'mongodb://127.0.0.1/', array $uriOpti
116116

117117
$driverOptions['driver'] = $this->mergeDriverInfo($driverOptions['driver'] ?? []);
118118

119-
$this->uri = (string) $uri;
119+
$this->uri = $uri;
120120
$this->typeMap = $driverOptions['typeMap'] ?? null;
121121

122122
unset($driverOptions['typeMap']);

src/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ class Collection
128128
*/
129129
public function __construct(Manager $manager, string $databaseName, string $collectionName, array $options = [])
130130
{
131-
if (strlen((string) $databaseName) < 1) {
131+
if (strlen($databaseName) < 1) {
132132
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
133133
}
134134

135-
if (strlen((string) $collectionName) < 1) {
135+
if (strlen($collectionName) < 1) {
136136
throw new InvalidArgumentException('$collectionName is invalid: ' . $collectionName);
137137
}
138138

@@ -153,8 +153,8 @@ public function __construct(Manager $manager, string $databaseName, string $coll
153153
}
154154

155155
$this->manager = $manager;
156-
$this->databaseName = (string) $databaseName;
157-
$this->collectionName = (string) $collectionName;
156+
$this->databaseName = $databaseName;
157+
$this->collectionName = $collectionName;
158158
$this->readConcern = $options['readConcern'] ?? $this->manager->getReadConcern();
159159
$this->readPreference = $options['readPreference'] ?? $this->manager->getReadPreference();
160160
$this->typeMap = $options['typeMap'] ?? self::$defaultTypeMap;

src/Command/ListCollections.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct(string $databaseName, array $options = [])
9595
throw InvalidArgumentException::invalidType('"session" option', $options['session'], Session::class);
9696
}
9797

98-
$this->databaseName = (string) $databaseName;
98+
$this->databaseName = $databaseName;
9999
$this->options = $options;
100100
}
101101

src/Database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Database
106106
*/
107107
public function __construct(Manager $manager, string $databaseName, array $options = [])
108108
{
109-
if (strlen((string) $databaseName) < 1) {
109+
if (strlen($databaseName) < 1) {
110110
throw new InvalidArgumentException('$databaseName is invalid: ' . $databaseName);
111111
}
112112

@@ -127,7 +127,7 @@ public function __construct(Manager $manager, string $databaseName, array $optio
127127
}
128128

129129
$this->manager = $manager;
130-
$this->databaseName = (string) $databaseName;
130+
$this->databaseName = $databaseName;
131131
$this->readConcern = $options['readConcern'] ?? $this->manager->getReadConcern();
132132
$this->readPreference = $options['readPreference'] ?? $this->manager->getReadPreference();
133133
$this->typeMap = $options['typeMap'] ?? self::$defaultTypeMap;

src/GridFS/Bucket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function __construct(Manager $manager, string $databaseName, array $optio
178178
}
179179

180180
$this->manager = $manager;
181-
$this->databaseName = (string) $databaseName;
181+
$this->databaseName = $databaseName;
182182
$this->bucketName = $options['bucketName'];
183183
$this->chunkSizeBytes = $options['chunkSizeBytes'];
184184
$this->disableMD5 = $options['disableMD5'];

src/GridFS/CollectionWrapper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class CollectionWrapper
6666
*/
6767
public function __construct(Manager $manager, string $databaseName, string $bucketName, array $collectionOptions = [])
6868
{
69-
$this->databaseName = (string) $databaseName;
70-
$this->bucketName = (string) $bucketName;
69+
$this->databaseName = $databaseName;
70+
$this->bucketName = $bucketName;
7171

7272
$this->filesCollection = new Collection($manager, $databaseName, sprintf('%s.files', $bucketName), $collectionOptions);
7373
$this->chunksCollection = new Collection($manager, $databaseName, sprintf('%s.chunks', $bucketName), $collectionOptions);
@@ -142,8 +142,8 @@ public function findChunksByFileId($id, int $fromChunk = 0)
142142
*/
143143
public function findFileByFilenameAndRevision(string $filename, int $revision)
144144
{
145-
$filename = (string) $filename;
146-
$revision = (integer) $revision;
145+
$filename = $filename;
146+
$revision = $revision;
147147

148148
if ($revision < 0) {
149149
$skip = abs($revision) - 1;
@@ -282,7 +282,7 @@ public function updateFilenameForId($id, string $filename)
282282
{
283283
return $this->filesCollection->updateOne(
284284
['_id' => $id],
285-
['$set' => ['filename' => (string) $filename]]
285+
['$set' => ['filename' => $filename]]
286286
);
287287
}
288288

src/GridFS/ReadableStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function __construct(CollectionWrapper $collectionWrapper, stdClass $file
8989
}
9090

9191
$this->file = $file;
92-
$this->chunkSize = (integer) $file->chunkSize;
93-
$this->length = (integer) $file->length;
92+
$this->chunkSize = $file->chunkSize;
93+
$this->length = $file->length;
9494

9595
$this->collectionWrapper = $collectionWrapper;
9696

src/GridFS/WritableStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function __construct(CollectionWrapper $collectionWrapper, string $filena
146146
$this->file = [
147147
'_id' => $options['_id'],
148148
'chunkSize' => $this->chunkSize,
149-
'filename' => (string) $filename,
149+
'filename' => $filename,
150150
] + array_intersect_key($options, ['aliases' => 1, 'contentType' => 1, 'metadata' => 1]);
151151
}
152152

src/MapReduceResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getCounts()
7979
*/
8080
public function getExecutionTimeMS()
8181
{
82-
return (integer) $this->executionTimeMS;
82+
return $this->executionTimeMS;
8383
}
8484

8585
/**

src/Operation/Aggregate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ public function __construct(string $databaseName, ?string $collectionName, array
246246
unset($options['batchSize']);
247247
}
248248

249-
$this->databaseName = (string) $databaseName;
250-
$this->collectionName = isset($collectionName) ? (string) $collectionName : null;
249+
$this->databaseName = $databaseName;
250+
$this->collectionName = isset($collectionName) ? $collectionName : null;
251251
$this->pipeline = $pipeline;
252252
$this->options = $options;
253253
}

0 commit comments

Comments
 (0)