Skip to content

Commit e2927b1

Browse files
committed
chore: Import nextcloud/rector and use it in rector config
Signed-off-by: Côme Chilliet <come@chilliet.eu>
1 parent 5a3ca8f commit e2927b1

File tree

4 files changed

+79
-33
lines changed

4 files changed

+79
-33
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"vimeo/psalm": "^5.9",
1616
"sabre/vobject": "^4.5",
1717
"rector/rector": "^1.0",
18-
"phpunit/phpunit": "^9.6"
18+
"phpunit/phpunit": "^9.6",
19+
"nextcloud/rector": "^0.2.1"
1920
},
2021
"require": {
2122
"php": "^8.0.2",

composer.lock

Lines changed: 64 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,17 @@
22

33
declare(strict_types=1);
44

5-
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
5+
use Nextcloud\Rector\Set\NextcloudSets;
66
use Rector\Config\RectorConfig;
7-
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
8-
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;
9-
use Rector\Set\ValueObject\LevelSetList;
10-
use Rector\Set\ValueObject\SetList;
117

12-
return static function (RectorConfig $rectorConfig): void {
13-
$rectorConfig->paths([
8+
return RectorConfig::configure()
9+
->withPaths([
10+
__DIR__ . '/appinfo',
1411
__DIR__ . '/lib',
1512
__DIR__ . '/tests',
13+
])
14+
->withPhpSets(php81: true)
15+
->withTypeCoverageLevel(1)
16+
->withSets([
17+
NextcloudSets::NEXTCLOUD_27,
1618
]);
17-
18-
// register a single rule
19-
$rectorConfig->rule(RemoveUnusedPromotedPropertyRector::class);
20-
$rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class);
21-
$rectorConfig->rule(LongArrayToShortArrayRector::class);
22-
23-
// define sets of rules
24-
$rectorConfig->sets([
25-
LevelSetList::UP_TO_PHP_80,
26-
// SetList::CODE_QUALITY,
27-
SetList::CODING_STYLE,
28-
SetList::TYPE_DECLARATION,
29-
// SetList::DEAD_CODE,
30-
]);
31-
};

tests/OperationTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@
4444
use Psr\Log\LoggerInterface;
4545

4646
class OperationTest extends TestCase {
47-
/** @var IL10N&MockObject */
48-
private IL10N|MockObject $l;
49-
/** @var IManager&MockObject */
50-
private IManager|MockObject $calendarManager;
47+
private IL10N&MockObject $l;
48+
private IManager&MockObject $calendarManager;
5149
private Operation $operation;
52-
/** @var ICreateFromString&MockObject */
53-
private ICreateFromString|MockObject $calendar;
54-
/** @var FlatpakAdapter&MockObject */
55-
private FlatpakAdapter|MockObject $flatpakAdapter;
50+
private ICreateFromString&MockObject $calendar;
51+
private FlatpakAdapter&MockObject $flatpakAdapter;
5652

5753
protected function setUp(): void {
5854
parent::setUp();

0 commit comments

Comments
 (0)