Skip to content

Commit d7abff0

Browse files
committed
Update to psalm 5
1 parent 41b0bc8 commit d7abff0

File tree

10 files changed

+420
-473
lines changed

10 files changed

+420
-473
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"squizlabs/php_codesniffer": "^3.7",
2121
"doctrine/coding-standard": "^11.1",
2222
"symfony/phpunit-bridge": "^5.2",
23-
"vimeo/psalm": "^4.28"
23+
"vimeo/psalm": "^5"
2424
},
2525
"autoload": {
2626
"psr-4": { "MongoDB\\": "src/" },

psalm-baseline.xml

Lines changed: 407 additions & 448 deletions
Large diffs are not rendered by default.

psalm.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<psalm
33
errorLevel="1"
44
errorBaseline="psalm-baseline.xml"
5+
findUnusedBaselineEntry="false"
6+
findUnusedCode="false"
57
resolveFromConfigFile="true"
68
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
79
xmlns="https://getpsalm.org/schema/config"

src/Client.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,8 @@ public function __get(string $databaseName)
162162
return $this->selectDatabase($databaseName);
163163
}
164164

165-
/**
166-
* Return the connection string (i.e. URI).
167-
*
168-
* @return string
169-
*/
170-
public function __toString()
165+
/** Return the connection string (i.e. URI). */
166+
public function __toString(): string
171167
{
172168
return $this->uri;
173169
}

src/Collection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ public function __debugInfo()
185185
* Return the collection namespace (e.g. "db.collection").
186186
*
187187
* @see https://mongodb.com/docs/manual/core/databases-and-collections/
188-
* @return string
189188
*/
190-
public function __toString()
189+
public function __toString(): string
191190
{
192191
return $this->databaseName . '.' . $this->collectionName;
193192
}

src/Database.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,8 @@ public function __get(string $collectionName)
173173
return $this->selectCollection($collectionName);
174174
}
175175

176-
/**
177-
* Return the database name.
178-
*
179-
* @return string
180-
*/
181-
public function __toString()
176+
/** Return the database name. */
177+
public function __toString(): string
182178
{
183179
return $this->databaseName;
184180
}

src/Model/BSONArray.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function bsonSerialize()
8585
#[ReturnTypeWillChange]
8686
public function bsonUnserialize(array $data)
8787
{
88+
/** @psalm-suppress DirectConstructorCall */
8889
self::__construct($data);
8990
}
9091

src/Model/IndexInfo.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ public function __debugInfo()
6161
return $this->info;
6262
}
6363

64-
/**
65-
* Return the index name to allow casting IndexInfo to string.
66-
*
67-
* @return string
68-
*/
69-
public function __toString()
64+
/** Return the index name to allow casting IndexInfo to string. */
65+
public function __toString(): string
7066
{
7167
return $this->getName();
7268
}

src/Model/IndexInput.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ public function __construct(array $index)
7474
$this->index = $index;
7575
}
7676

77-
/**
78-
* Return the index name.
79-
*/
77+
/** Return the index name. */
8078
public function __toString(): string
8179
{
8280
return $this->index['name'];

src/Operation/Aggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function __construct(string $databaseName, ?string $collectionName, array
230230
unset($options['writeConcern']);
231231
}
232232

233-
$this->isExplain = ! empty($options['explain']);
233+
$this->isExplain = $options['explain'] ?? false;
234234
$this->isWrite = is_last_pipeline_operator_write($pipeline) && ! $this->isExplain;
235235

236236
// Explain does not use a cursor

0 commit comments

Comments
 (0)