Skip to content

Commit fdf868c

Browse files
committed
Fix coding standard errors
1 parent 58d03aa commit fdf868c

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
10101010
*
10111011
* @see RenameCollection::__construct() for supported options
10121012
* @param string $newCollectionName New name for this collection
1013-
* @param array $options Additional options
1013+
* @param array $options Additional options
10141014
* @return array|object Command result document
10151015
* @throws UnsupportedException if options are not supported by the selected server
10161016
* @throws InvalidArgumentException for parameter/option parsing errors

src/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public function modifyCollection($collectionName, array $collectionOptions, arra
476476
*
477477
* @see RenameCollection::__construct() for supported options
478478
* @param string $newCollectionName New name for this collection
479-
* @param array $options Additional options
479+
* @param array $options Additional options
480480
* @return array|object Command result document
481481
* @throws UnsupportedException if options are unsupported on the selected server
482482
* @throws InvalidArgumentException for parameter/option parsing errors

src/Operation/RenameCollection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
use MongoDB\Driver\WriteConcern;
2525
use MongoDB\Exception\InvalidArgumentException;
2626
use MongoDB\Exception\UnsupportedException;
27+
2728
use function current;
2829
use function is_array;
30+
use function is_bool;
2931
use function MongoDB\server_supports_feature;
3032

3133
/**
@@ -149,8 +151,10 @@ public function execute(Server $server)
149151
/* The server may return an error if the collection does not exist.
150152
* Check for an error code (or message for pre-3.2 servers) and
151153
* return the command reply instead of throwing. */
152-
if ($e->getCode() === self::$errorCodeNamespaceNotFound ||
153-
$e->getMessage() === self::$errorMessageNamespaceNotFound) {
154+
if (
155+
$e->getCode() === self::$errorCodeNamespaceNotFound ||
156+
$e->getMessage() === self::$errorMessageNamespaceNotFound
157+
) {
154158
return $e->getResultDocument();
155159
}
156160

tests/Collection/CollectionFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function testFindWithinTransaction(): void
332332
}
333333
}
334334

335-
public function testRenameCollection()
335+
public function testRenameCollection(): void
336336
{
337337
$writeResult = $this->collection->insertOne(['x' => 1]);
338338
$this->assertEquals(1, $writeResult->getInsertedCount());
@@ -341,7 +341,7 @@ public function testRenameCollection()
341341
$this->assertCommandSucceeded($commandResult);
342342
}
343343

344-
public function testWithOptionsInheritsOptions()
344+
public function testWithOptionsInheritsOptions(): void
345345
{
346346
$collectionOptions = [
347347
'readConcern' => new ReadConcern(ReadConcern::LOCAL),

tests/Operation/RenameCollectionFunctionalTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
namespace MongoDB\Tests\Operation;
44

5-
use MongoDB\Model\CollectionInfo;
6-
use MongoDB\Model\CollectionInfoIterator;
75
use MongoDB\Operation\InsertOne;
86
use MongoDB\Operation\ListCollections;
97
use MongoDB\Operation\RenameCollection;
108
use MongoDB\Tests\CommandObserver;
9+
10+
use function call_user_func;
11+
use function is_callable;
1112
use function sprintf;
1213
use function version_compare;
1314

1415
class RenameCollectionFunctionalTest extends FunctionalTestCase
1516
{
16-
public function testDefaultWriteConcernIsOmitted()
17+
public function testDefaultWriteConcernIsOmitted(): void
1718
{
1819
(new CommandObserver())->observe(
19-
function () {
20+
function (): void {
2021
$operation = new RenameCollection(
2122
'admin',
2223
$this->getCollectionName(),
@@ -26,13 +27,13 @@ function () {
2627

2728
$operation->execute($this->getPrimaryServer());
2829
},
29-
function (array $event) {
30+
function (array $event): void {
3031
$this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand());
3132
}
3233
);
3334
}
3435

35-
public function testRenameExistingCollection()
36+
public function testRenameExistingCollection(): void
3637
{
3738
$that = $this;
3839
$renamedCollectionName = $this->getCollectionName() . '.renamed';
@@ -56,7 +57,7 @@ public function testRenameExistingCollection()
5657
/**
5758
* @depends testRenameExistingCollection
5859
*/
59-
public function testRenameNonexistentCollection()
60+
public function testRenameNonexistentCollection(): void
6061
{
6162
$this->assertCollectionDoesNotExist($this->getCollectionName());
6263

@@ -68,14 +69,14 @@ public function testRenameNonexistentCollection()
6869
$this->assertIsObject($commandResult);
6970
}
7071

71-
public function testSessionOption()
72+
public function testSessionOption(): void
7273
{
7374
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
7475
$this->markTestSkipped('Sessions are not supported');
7576
}
7677

7778
(new CommandObserver())->observe(
78-
function () {
79+
function (): void {
7980
$operation = new RenameCollection(
8081
'admin',
8182
$this->getCollectionName(),
@@ -85,7 +86,7 @@ function () {
8586

8687
$operation->execute($this->getPrimaryServer());
8788
},
88-
function (array $event) {
89+
function (array $event): void {
8990
$this->assertObjectHasAttribute('lsid', $event['started']->getCommand());
9091
}
9192
);
@@ -97,7 +98,7 @@ function (array $event) {
9798
*
9899
* @param string $collectionName
99100
*/
100-
private function assertCollectionDoesNotExist($collectionName)
101+
private function assertCollectionDoesNotExist(string $collectionName): void
101102
{
102103
$operation = new ListCollections('admin');
103104
$collections = $operation->execute($this->getPrimaryServer());
@@ -124,7 +125,7 @@ private function assertCollectionDoesNotExist($collectionName)
124125
*
125126
* @param callable $callback
126127
*/
127-
private function assertCollectionExists($collectionName, $callback = null)
128+
private function assertCollectionExists($collectionName, ?callable $callback = null): void
128129
{
129130
if ($callback !== null && ! is_callable($callback)) {
130131
throw new InvalidArgumentException('$callback is not a callable');

tests/Operation/RenameCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RenameCollectionTest extends TestCase
1010
/**
1111
* @dataProvider provideInvalidConstructorOptions
1212
*/
13-
public function testConstructorOptionTypeChecks(array $options)
13+
public function testConstructorOptionTypeChecks(array $options): void
1414
{
1515
$this->expectException(InvalidArgumentException::class);
1616
new RenameCollection($this->getDatabaseName(), $this->getCollectionName(), $this->getCollectionName() . '.renamed', $options);

0 commit comments

Comments
 (0)