Skip to content

Commit b353173

Browse files
Merge v2.1 into v2.x (#1760)
2 parents 145e099 + 94527f2 commit b353173

18 files changed

+48
-44
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"require-dev": {
2020
"doctrine/coding-standard": "^12.0",
2121
"phpunit/phpunit": "^10.5.35",
22-
"rector/rector": "^1.2",
22+
"rector/rector": "^2.1.4",
2323
"squizlabs/php_codesniffer": "^3.7",
2424
"vimeo/psalm": "6.5.*"
2525
},

rector.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
<?php
22

3+
use PhpParser\Node\Expr\Cast\Bool_;
4+
use PhpParser\Node\Expr\Cast\Double;
5+
use PhpParser\Node\Expr\Cast\Int_;
36
use Rector\Config\RectorConfig;
47
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
58
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
69
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
710
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
8-
use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector;
9-
use Rector\PHPUnit\Set\PHPUnitSetList;
10-
use Rector\Set\ValueObject\LevelSetList;
11+
use Rector\Renaming\Rector\Cast\RenameCastRector;
12+
use Rector\Renaming\ValueObject\RenameCast;
1113

12-
return static function (RectorConfig $rectorConfig): void {
13-
$rectorConfig->paths([
14+
return RectorConfig::configure()
15+
->withPaths([
1416
__DIR__ . '/examples',
1517
__DIR__ . '/src',
1618
__DIR__ . '/tests',
1719
__DIR__ . '/tools',
18-
]);
19-
20-
// Modernize code
21-
$rectorConfig->sets([
22-
LevelSetList::UP_TO_PHP_74,
23-
PHPUnitSetList::PHPUNIT_100,
24-
]);
25-
26-
$rectorConfig->rule(ChangeSwitchToMatchRector::class);
27-
$rectorConfig->rule(StaticDataProviderClassMethodRector::class);
28-
20+
])
21+
->withPhpSets(php74: true)
22+
->withComposerBased(phpunit: true)
23+
->withRules([
24+
ChangeSwitchToMatchRector::class,
25+
])
26+
// All classes are public API by default, unless marked with @internal.
27+
->withConfiguredRule(RemoveAnnotationRector::class, ['api'])
28+
// Fix PHP 8.5 deprecations
29+
->withConfiguredRule(
30+
RenameCastRector::class,
31+
[
32+
new RenameCast(Int_::class, Int_::KIND_INTEGER, Int_::KIND_INT),
33+
new RenameCast(Bool_::class, Bool_::KIND_BOOLEAN, Bool_::KIND_BOOL),
34+
new RenameCast(Double::class, Double::KIND_DOUBLE, Double::KIND_FLOAT),
35+
],
36+
)
2937
// phpcs:disable Squiz.Arrays.ArrayDeclaration.KeySpecified
30-
$rectorConfig->skip([
38+
->withSkip([
3139
RemoveExtraParametersRector::class,
3240
// Do not use ternaries extensively
3341
IfIssetToCoalescingRector::class,
3442
ChangeSwitchToMatchRector::class => [
3543
__DIR__ . '/tests/SpecTests/Operation.php',
3644
],
37-
]);
45+
])
3846
// phpcs:enable
39-
40-
// All classes are public API by default, unless marked with @internal.
41-
$rectorConfig->ruleWithConfiguration(RemoveAnnotationRector::class, ['api']);
42-
};
47+
->withImportNames(importNames: false, removeUnusedImports: true);

src/GridFS/Bucket.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
use MongoDB\GridFS\Exception\StreamException;
3535
use MongoDB\Model\BSONArray;
3636
use MongoDB\Model\BSONDocument;
37-
use MongoDB\Operation\Find;
3837

3938
use function array_intersect_key;
4039
use function array_key_exists;

src/GridFS/ReadableStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function __construct(private CollectionWrapper $collectionWrapper, privat
8080
$this->length = $file->length;
8181

8282
if ($this->length > 0) {
83-
$this->numChunks = (integer) ceil($this->length / $this->chunkSize);
83+
$this->numChunks = (int) ceil($this->length / $this->chunkSize);
8484
$this->expectedLastChunkSize = $this->length - (($this->numChunks - 1) * $this->chunkSize);
8585
}
8686
}
@@ -182,7 +182,7 @@ public function seek(int $offset): void
182182
* changed, we'll also need to reset the buffer.
183183
*/
184184
$lastChunkOffset = $this->chunkOffset;
185-
$this->chunkOffset = (integer) floor($offset / $this->chunkSize);
185+
$this->chunkOffset = (int) floor($offset / $this->chunkSize);
186186
$this->bufferOffset = $offset % $this->chunkSize;
187187

188188
if ($lastChunkOffset === $this->chunkOffset) {

src/Model/CollectionInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __debugInfo(): array
5858
public function getCappedMax(): ?int
5959
{
6060
/* The MongoDB server might return this number as an integer or float */
61-
return isset($this->info['options']['max']) ? (integer) $this->info['options']['max'] : null;
61+
return isset($this->info['options']['max']) ? (int) $this->info['options']['max'] : null;
6262
}
6363

6464
/**
@@ -69,7 +69,7 @@ public function getCappedMax(): ?int
6969
public function getCappedSize(): ?int
7070
{
7171
/* The MongoDB server might return this number as an integer or float */
72-
return isset($this->info['options']['size']) ? (integer) $this->info['options']['size'] : null;
72+
return isset($this->info['options']['size']) ? (int) $this->info['options']['size'] : null;
7373
}
7474

7575
/**

src/Model/DatabaseInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ public function getName(): string
6363
public function getSizeOnDisk(): int
6464
{
6565
/* The MongoDB server might return this number as an integer or float */
66-
return (integer) $this->info['sizeOnDisk'];
66+
return (int) $this->info['sizeOnDisk'];
6767
}
6868

6969
/**
7070
* Return whether the database is empty.
7171
*/
7272
public function isEmpty(): bool
7373
{
74-
return (boolean) $this->info['empty'];
74+
return (bool) $this->info['empty'];
7575
}
7676

7777
/**

src/Model/IndexInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getName(): string
8484
*/
8585
public function getVersion(): int
8686
{
87-
return (integer) $this->info['v'];
87+
return (int) $this->info['v'];
8888
}
8989

9090
/**

src/Operation/Count.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function execute(Server $server): int
143143
throw new UnexpectedValueException('count command did not return a numeric "n" value');
144144
}
145145

146-
return (integer) $result->n;
146+
return (int) $result->n;
147147
}
148148

149149
/**

src/Operation/CountDocuments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function execute(Server $server): int
124124
throw new UnexpectedValueException('count command did not return a numeric "n" value');
125125
}
126126

127-
return (integer) $result->n;
127+
return (int) $result->n;
128128
}
129129

130130
private function createAggregate(): Aggregate

src/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ function is_write_concern_acknowledged(WriteConcern $writeConcern): bool
409409
function server_supports_feature(Server $server, int $feature): bool
410410
{
411411
$info = $server->getInfo();
412-
$maxWireVersion = isset($info['maxWireVersion']) ? (integer) $info['maxWireVersion'] : 0;
413-
$minWireVersion = isset($info['minWireVersion']) ? (integer) $info['minWireVersion'] : 0;
412+
$maxWireVersion = isset($info['maxWireVersion']) ? (int) $info['maxWireVersion'] : 0;
413+
$minWireVersion = isset($info['minWireVersion']) ? (int) $info['minWireVersion'] : 0;
414414

415415
return $minWireVersion <= $feature && $maxWireVersion >= $feature;
416416
}

0 commit comments

Comments
 (0)