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
}

src/Operation/BulkWrite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ public function __construct(string $databaseName, string $collectionName, array
297297
unset($options['writeConcern']);
298298
}
299299

300-
$this->databaseName = (string) $databaseName;
301-
$this->collectionName = (string) $collectionName;
300+
$this->databaseName = $databaseName;
301+
$this->collectionName = $collectionName;
302302
$this->operations = $operations;
303303
$this->options = $options;
304304
}

src/Operation/Count.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public function __construct(string $databaseName, string $collectionName, $filte
132132
unset($options['readConcern']);
133133
}
134134

135-
$this->databaseName = (string) $databaseName;
136-
$this->collectionName = (string) $collectionName;
135+
$this->databaseName = $databaseName;
136+
$this->collectionName = $collectionName;
137137
$this->filter = $filter;
138138
$this->options = $options;
139139
}

src/Operation/CountDocuments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public function __construct(string $databaseName, string $collectionName, $filte
107107
throw InvalidArgumentException::invalidType('"skip" option', $options['skip'], 'integer');
108108
}
109109

110-
$this->databaseName = (string) $databaseName;
111-
$this->collectionName = (string) $collectionName;
110+
$this->databaseName = $databaseName;
111+
$this->collectionName = $collectionName;
112112
$this->filter = $filter;
113113

114114
$this->aggregateOptions = array_intersect_key($options, ['collation' => 1, 'comment' => 1, 'hint' => 1, 'maxTimeMS' => 1, 'readConcern' => 1, 'readPreference' => 1, 'session' => 1]);

src/Operation/CreateCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ public function __construct(string $databaseName, string $collectionName, array
256256
}
257257
}
258258

259-
$this->databaseName = (string) $databaseName;
260-
$this->collectionName = (string) $collectionName;
259+
$this->databaseName = $databaseName;
260+
$this->collectionName = $collectionName;
261261
$this->options = $options;
262262
}
263263

src/Operation/CreateIndexes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public function __construct(string $databaseName, string $collectionName, array
126126
unset($options['writeConcern']);
127127
}
128128

129-
$this->databaseName = (string) $databaseName;
130-
$this->collectionName = (string) $collectionName;
129+
$this->databaseName = $databaseName;
130+
$this->collectionName = $collectionName;
131131
$this->options = $options;
132132
}
133133

src/Operation/DatabaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct(string $databaseName, $command, array $options = [])
8383
throw InvalidArgumentException::invalidType('"typeMap" option', $options['typeMap'], 'array');
8484
}
8585

86-
$this->databaseName = (string) $databaseName;
86+
$this->databaseName = $databaseName;
8787
$this->command = $command instanceof Command ? $command : new Command($command);
8888
$this->options = $options;
8989
}

src/Operation/Delete.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function __construct(string $databaseName, string $collectionName, $filte
131131
unset($options['writeConcern']);
132132
}
133133

134-
$this->databaseName = (string) $databaseName;
135-
$this->collectionName = (string) $collectionName;
134+
$this->databaseName = $databaseName;
135+
$this->collectionName = $collectionName;
136136
$this->filter = $filter;
137137
$this->limit = $limit;
138138
$this->options = $options;

src/Operation/Distinct.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ public function __construct(string $databaseName, string $collectionName, string
120120
unset($options['readConcern']);
121121
}
122122

123-
$this->databaseName = (string) $databaseName;
124-
$this->collectionName = (string) $collectionName;
125-
$this->fieldName = (string) $fieldName;
123+
$this->databaseName = $databaseName;
124+
$this->collectionName = $collectionName;
125+
$this->fieldName = $fieldName;
126126
$this->filter = $filter;
127127
$this->options = $options;
128128
}

src/Operation/DropCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public function __construct(string $databaseName, string $collectionName, array
8989
unset($options['writeConcern']);
9090
}
9191

92-
$this->databaseName = (string) $databaseName;
93-
$this->collectionName = (string) $collectionName;
92+
$this->databaseName = $databaseName;
93+
$this->collectionName = $collectionName;
9494
$this->options = $options;
9595
}
9696

src/Operation/DropDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function __construct(string $databaseName, array $options = [])
8181
unset($options['writeConcern']);
8282
}
8383

84-
$this->databaseName = (string) $databaseName;
84+
$this->databaseName = $databaseName;
8585
$this->options = $options;
8686
}
8787

src/Operation/DropIndexes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class DropIndexes implements Executable
7777
*/
7878
public function __construct(string $databaseName, string $collectionName, string $indexName, array $options = [])
7979
{
80-
$indexName = (string) $indexName;
80+
$indexName = $indexName;
8181

8282
if ($indexName === '') {
8383
throw new InvalidArgumentException('$indexName cannot be empty');
@@ -103,8 +103,8 @@ public function __construct(string $databaseName, string $collectionName, string
103103
unset($options['writeConcern']);
104104
}
105105

106-
$this->databaseName = (string) $databaseName;
107-
$this->collectionName = (string) $collectionName;
106+
$this->databaseName = $databaseName;
107+
$this->collectionName = $collectionName;
108108
$this->indexName = $indexName;
109109
$this->options = $options;
110110
}

src/Operation/EstimatedDocumentCount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class EstimatedDocumentCount implements Executable, Explainable
7979
*/
8080
public function __construct(string $databaseName, string $collectionName, array $options = [])
8181
{
82-
$this->databaseName = (string) $databaseName;
83-
$this->collectionName = (string) $collectionName;
82+
$this->databaseName = $databaseName;
83+
$this->collectionName = $collectionName;
8484

8585
if (isset($options['maxTimeMS']) && ! is_integer($options['maxTimeMS'])) {
8686
throw InvalidArgumentException::invalidType('"maxTimeMS" option', $options['maxTimeMS'], 'integer');

src/Operation/Find.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ public function __construct(string $databaseName, string $collectionName, $filte
292292
trigger_error('The "maxScan" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
293293
}
294294

295-
$this->databaseName = (string) $databaseName;
296-
$this->collectionName = (string) $collectionName;
295+
$this->databaseName = $databaseName;
296+
$this->collectionName = $collectionName;
297297
$this->filter = $filter;
298298
$this->options = $options;
299299
}

src/Operation/FindAndModify.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ public function __construct(string $databaseName, string $collectionName, array
209209
unset($options['writeConcern']);
210210
}
211211

212-
$this->databaseName = (string) $databaseName;
213-
$this->collectionName = (string) $collectionName;
212+
$this->databaseName = $databaseName;
213+
$this->collectionName = $collectionName;
214214
$this->options = $options;
215215
}
216216

src/Operation/InsertMany.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public function __construct(string $databaseName, string $collectionName, array
125125
unset($options['writeConcern']);
126126
}
127127

128-
$this->databaseName = (string) $databaseName;
129-
$this->collectionName = (string) $collectionName;
128+
$this->databaseName = $databaseName;
129+
$this->collectionName = $collectionName;
130130
$this->documents = $documents;
131131
$this->options = $options;
132132
}

src/Operation/InsertOne.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public function __construct(string $databaseName, string $collectionName, $docum
9999
unset($options['writeConcern']);
100100
}
101101

102-
$this->databaseName = (string) $databaseName;
103-
$this->collectionName = (string) $collectionName;
102+
$this->databaseName = $databaseName;
103+
$this->collectionName = $collectionName;
104104
$this->document = $document;
105105
$this->options = $options;
106106
}

src/Operation/ListCollections.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ListCollections implements Executable
6666
*/
6767
public function __construct(string $databaseName, array $options = [])
6868
{
69-
$this->databaseName = (string) $databaseName;
69+
$this->databaseName = $databaseName;
7070
$this->listCollections = new ListCollectionsCommand($databaseName, ['nameOnly' => false] + $options);
7171
}
7272

src/Operation/ListIndexes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public function __construct(string $databaseName, string $collectionName, array
8383
throw InvalidArgumentException::invalidType('"session" option', $options['session'], Session::class);
8484
}
8585

86-
$this->databaseName = (string) $databaseName;
87-
$this->collectionName = (string) $collectionName;
86+
$this->databaseName = $databaseName;
87+
$this->collectionName = $collectionName;
8888
$this->options = $options;
8989
}
9090

src/Operation/MapReduce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ public function __construct(string $databaseName, string $collectionName, Javasc
251251

252252
$this->checkOutDeprecations($out);
253253

254-
$this->databaseName = (string) $databaseName;
255-
$this->collectionName = (string) $collectionName;
254+
$this->databaseName = $databaseName;
255+
$this->collectionName = $collectionName;
256256
$this->map = $map;
257257
$this->reduce = $reduce;
258258
$this->out = $out;

src/Operation/ModifyCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function __construct(string $databaseName, string $collectionName, array
9292
unset($options['writeConcern']);
9393
}
9494

95-
$this->databaseName = (string) $databaseName;
96-
$this->collectionName = (string) $collectionName;
95+
$this->databaseName = $databaseName;
96+
$this->collectionName = $collectionName;
9797
$this->collectionOptions = $collectionOptions;
9898
$this->options = $options;
9999
}

src/Operation/Update.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ public function __construct(string $databaseName, string $collectionName, $filte
175175
unset($options['writeConcern']);
176176
}
177177

178-
$this->databaseName = (string) $databaseName;
179-
$this->collectionName = (string) $collectionName;
178+
$this->databaseName = $databaseName;
179+
$this->collectionName = $collectionName;
180180
$this->filter = $filter;
181181
$this->update = $update;
182182
$this->options = $options;

src/Operation/Watch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function __construct(Manager $manager, ?string $databaseName, ?string $co
264264

265265
$this->manager = $manager;
266266
$this->databaseName = (string) $databaseName;
267-
$this->collectionName = isset($collectionName) ? (string) $collectionName : null;
267+
$this->collectionName = isset($collectionName) ? $collectionName : null;
268268
$this->pipeline = $pipeline;
269269

270270
$this->aggregate = $this->createAggregate();

0 commit comments

Comments
 (0)