File tree Expand file tree Collapse file tree 9 files changed +32
-18
lines changed
UnifiedSpecTests/Constraint Expand file tree Collapse file tree 9 files changed +32
-18
lines changed Original file line number Diff line number Diff line change 6565
6666 - name : " Run Psalm"
6767 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 1111use function MongoDB \BSON \fromPHP ;
1212use function MongoDB \BSON \toRelaxedExtendedJSON ;
1313use function printf ;
14- use function rand ;
14+ use function random_int ;
1515
1616require __DIR__ . '/../vendor/autoload.php ' ;
1717
@@ -28,7 +28,7 @@ function toJSON(object $document): string
2828$ documents = [];
2929
3030for ($ i = 0 ; $ i < 100 ; $ i ++) {
31- $ documents [] = ['randomValue ' => rand (0 , 1000 )];
31+ $ documents [] = ['randomValue ' => random_int (0 , 1000 )];
3232}
3333
3434$ collection ->insertMany ($ documents );
Original file line number Diff line number Diff line change 1313 <file >examples</file >
1414 <file >tests</file >
1515 <file >tools</file >
16+ <file >rector.php</file >
1617
1718 <!-- Target minimum supported PHP version -->
1819 <config name =" php_version" value =" 70200" />
Original file line number Diff line number Diff line change 22
33use Rector \Config \RectorConfig ;
44use 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 ;
58
69return static function (RectorConfig $ rectorConfig ): void {
710 $ rectorConfig ->paths ([
1114 __DIR__ . '/tools ' ,
1215 ]);
1316
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+ ]);
1830
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 ' ]);
2333};
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ public function provideTypeMapValues()
210210 'Array field path converted to array ' => [
211211 [
212212 'root ' => 'object ' ,
213- 'array ' => ' MongoDB\Model\ BSONArray' ,
213+ 'array ' => BSONArray::class ,
214214 'fieldPaths ' => [
215215 'field ' => 'array ' ,
216216 'field.$ ' => 'object ' ,
@@ -219,22 +219,22 @@ public function provideTypeMapValues()
219219 ],
220220 [
221221 'root ' => 'object ' ,
222- 'array ' => ' MongoDB\Model\ BSONArray' ,
222+ 'array ' => BSONArray::class ,
223223 'fieldPaths ' => ['nested ' => 'array ' ],
224224 ],
225225 'field.$ ' ,
226226 ],
227227 'Array field path without root key ' => [
228228 [
229229 'root ' => 'object ' ,
230- 'array ' => ' MongoDB\Model\ BSONArray' ,
230+ 'array ' => BSONArray::class ,
231231 'fieldPaths ' => [
232232 'field ' => 'array ' ,
233233 'field.$.nested ' => 'array ' ,
234234 ],
235235 ],
236236 [
237- 'array ' => ' MongoDB\Model\ BSONArray' ,
237+ 'array ' => BSONArray::class ,
238238 'fieldPaths ' => ['nested ' => 'array ' ],
239239 ],
240240 'field.$ ' ,
Original file line number Diff line number Diff line change @@ -549,7 +549,7 @@ public function testOpenDownloadStreamByNameShouldRequireFilenameAndRevisionToEx
549549 $ this ->bucket ->uploadFromStream ('filename ' , $ this ->createStream ('bar ' ));
550550
551551 $ this ->expectException (FileNotFoundException::class);
552- $ this ->bucket ->openDownloadStream ($ filename , ['revision ' => $ revision ]);
552+ $ this ->bucket ->openDownloadStreamByName ($ filename , ['revision ' => $ revision ]);
553553 }
554554
555555 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
2020 stream_wrapper_unregister ($ protocol );
2121 }
2222
23- stream_wrapper_register ($ protocol , static ::class, STREAM_IS_URL );
23+ stream_wrapper_register ($ protocol , self ::class, STREAM_IS_URL );
2424 }
2525
2626 public function stream_close (): void
Original file line number Diff line number Diff line change @@ -1107,8 +1107,7 @@ public function testResumeTokenNotFoundDoesNotAdvanceKey(): void
11071107 try {
11081108 $ changeStream ->next ();
11091109 $ this ->fail ('Exception for missing resume token was not thrown ' );
1110- } catch (ResumeTokenException $ e ) {
1111- } catch (ServerException $ e ) {
1110+ } catch (ResumeTokenException | ServerException $ e ) {
11121111 }
11131112
11141113 $ this ->assertFalse ($ changeStream ->valid ());
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ private function doToString()
368368 return 'matches ' . $ this ->exporter ()->export ($ this ->value );
369369 }
370370
371+ /** @psalm-return never-return */
371372 private static function failAt (string $ message , string $ keyPath ): void
372373 {
373374 $ prefix = empty ($ keyPath ) ? '' : sprintf ('Field path "%s": ' , $ keyPath );
You can’t perform that action at this time.
0 commit comments