File tree 9 files changed +32
-18
lines changed
UnifiedSpecTests/Constraint
9 files changed +32
-18
lines changed Original file line number Diff line number Diff line change 65
65
66
66
- name : " Run Psalm"
67
67
run : " vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)"
68
+
69
+ - name : " Run Rector"
70
+ run : " vendor/bin/rector --ansi --dry-run"
Original file line number Diff line number Diff line change 11
11
use function MongoDB \BSON \fromPHP ;
12
12
use function MongoDB \BSON \toRelaxedExtendedJSON ;
13
13
use function printf ;
14
- use function rand ;
14
+ use function random_int ;
15
15
16
16
require __DIR__ . '/../vendor/autoload.php ' ;
17
17
@@ -28,7 +28,7 @@ function toJSON(object $document): string
28
28
$ documents = [];
29
29
30
30
for ($ i = 0 ; $ i < 100 ; $ i ++) {
31
- $ documents [] = ['randomValue ' => rand (0 , 1000 )];
31
+ $ documents [] = ['randomValue ' => random_int (0 , 1000 )];
32
32
}
33
33
34
34
$ collection ->insertMany ($ documents );
Original file line number Diff line number Diff line change 13
13
<file >examples</file >
14
14
<file >tests</file >
15
15
<file >tools</file >
16
+ <file >rector.php</file >
16
17
17
18
<!-- Target minimum supported PHP version -->
18
19
<config name =" php_version" value =" 70200" />
Original file line number Diff line number Diff line change 2
2
3
3
use Rector \Config \RectorConfig ;
4
4
use Rector \DeadCode \Rector \ClassLike \RemoveAnnotationRector ;
5
+ use Rector \Php56 \Rector \FunctionLike \AddDefaultValueForUndefinedVariableRector ;
6
+ use Rector \Php71 \Rector \FuncCall \RemoveExtraParametersRector ;
7
+ use Rector \Set \ValueObject \LevelSetList ;
5
8
6
9
return static function (RectorConfig $ rectorConfig ): void {
7
10
$ rectorConfig ->paths ([
11
14
__DIR__ . '/tools ' ,
12
15
]);
13
16
14
- /**
15
- * All classes are public API by default, unless marked with @internal.
16
- */
17
- $ rectorConfig ->ruleWithConfiguration (RemoveAnnotationRector::class, ['api ' ]);
17
+ // Modernize code
18
+ $ rectorConfig ->sets ([LevelSetList::UP_TO_PHP_72 ]);
19
+
20
+ $ rectorConfig ->skip ([
21
+ // Falsely detect unassigned variables in code paths stopped by PHPUnit\Framework\Assert::markTestSkipped()
22
+ AddDefaultValueForUndefinedVariableRector::class => [
23
+ __DIR__ . '/tests/ ' ,
24
+ ],
25
+ // @see https://github.com/phpstan/phpstan-src/pull/2429
26
+ RemoveExtraParametersRector::class => [
27
+ __DIR__ . '/src/Operation/ ' ,
28
+ ],
29
+ ]);
18
30
19
- // define sets of rules
20
- // $rectorConfig->sets([
21
- // LevelSetList::UP_TO_PHP_72
22
- // ]);
31
+ // All classes are public API by default, unless marked with @internal.
32
+ $ rectorConfig ->ruleWithConfiguration (RemoveAnnotationRector::class, ['api ' ]);
23
33
};
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ public function provideTypeMapValues()
210
210
'Array field path converted to array ' => [
211
211
[
212
212
'root ' => 'object ' ,
213
- 'array ' => ' MongoDB\Model\ BSONArray' ,
213
+ 'array ' => BSONArray::class ,
214
214
'fieldPaths ' => [
215
215
'field ' => 'array ' ,
216
216
'field.$ ' => 'object ' ,
@@ -219,22 +219,22 @@ public function provideTypeMapValues()
219
219
],
220
220
[
221
221
'root ' => 'object ' ,
222
- 'array ' => ' MongoDB\Model\ BSONArray' ,
222
+ 'array ' => BSONArray::class ,
223
223
'fieldPaths ' => ['nested ' => 'array ' ],
224
224
],
225
225
'field.$ ' ,
226
226
],
227
227
'Array field path without root key ' => [
228
228
[
229
229
'root ' => 'object ' ,
230
- 'array ' => ' MongoDB\Model\ BSONArray' ,
230
+ 'array ' => BSONArray::class ,
231
231
'fieldPaths ' => [
232
232
'field ' => 'array ' ,
233
233
'field.$.nested ' => 'array ' ,
234
234
],
235
235
],
236
236
[
237
- 'array ' => ' MongoDB\Model\ BSONArray' ,
237
+ 'array ' => BSONArray::class ,
238
238
'fieldPaths ' => ['nested ' => 'array ' ],
239
239
],
240
240
'field.$ ' ,
Original file line number Diff line number Diff line change @@ -549,7 +549,7 @@ public function testOpenDownloadStreamByNameShouldRequireFilenameAndRevisionToEx
549
549
$ this ->bucket ->uploadFromStream ('filename ' , $ this ->createStream ('bar ' ));
550
550
551
551
$ this ->expectException (FileNotFoundException::class);
552
- $ this ->bucket ->openDownloadStream ($ filename , ['revision ' => $ revision ]);
552
+ $ this ->bucket ->openDownloadStreamByName ($ filename , ['revision ' => $ revision ]);
553
553
}
554
554
555
555
public function testOpenUploadStream (): void
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public static function register($protocol = 'unusable'): void
20
20
stream_wrapper_unregister ($ protocol );
21
21
}
22
22
23
- stream_wrapper_register ($ protocol , static ::class, STREAM_IS_URL );
23
+ stream_wrapper_register ($ protocol , self ::class, STREAM_IS_URL );
24
24
}
25
25
26
26
public function stream_close (): void
Original file line number Diff line number Diff line change @@ -1107,8 +1107,7 @@ public function testResumeTokenNotFoundDoesNotAdvanceKey(): void
1107
1107
try {
1108
1108
$ changeStream ->next ();
1109
1109
$ this ->fail ('Exception for missing resume token was not thrown ' );
1110
- } catch (ResumeTokenException $ e ) {
1111
- } catch (ServerException $ e ) {
1110
+ } catch (ResumeTokenException | ServerException $ e ) {
1112
1111
}
1113
1112
1114
1113
$ this ->assertFalse ($ changeStream ->valid ());
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ private function doToString()
368
368
return 'matches ' . $ this ->exporter ()->export ($ this ->value );
369
369
}
370
370
371
+ /** @psalm-return never-return */
371
372
private static function failAt (string $ message , string $ keyPath ): void
372
373
{
373
374
$ prefix = empty ($ keyPath ) ? '' : sprintf ('Field path "%s": ' , $ keyPath );
You can’t perform that action at this time.
0 commit comments