Skip to content

Commit 22913ca

Browse files
chore: implement rector
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent 6c0a56b commit 22913ca

4 files changed

Lines changed: 669 additions & 0 deletions

File tree

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"cs:check": "php-cs-fixer fix --dry-run --diff",
2222
"cs:check:force": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --diff",
2323
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
24+
"rector:apply": "rector && composer cs:fix",
25+
"rector:check": "rector --dry-run",
2426
"test:unit": "phpunit -c phpunit.xml --fail-on-warning",
2527
"test:unit:coverage": "phpunit --coverage-clover coverage.xml -c phpunit.xml --fail-on-warning ",
2628
"test:unit:dev": "phpunit -c phpunit.xml --fail-on-warning --stop-on-error --stop-on-failure",

rector.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
use Rector\Config\RectorConfig;
11+
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
12+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
13+
use Rector\ValueObject\PhpVersion;
14+
15+
return RectorConfig::configure()
16+
->withPaths([
17+
__DIR__ . '/appinfo/routes.php',
18+
__DIR__ . '/lib',
19+
__DIR__ . '/tests/unit',
20+
])
21+
->withAutoloadPaths([
22+
__DIR__ . '/vendor-bin/rector/vendor/nextcloud/ocp/OCP',
23+
])
24+
->withImportNames(importShortClasses: false)
25+
->withPhpVersion(PhpVersion::PHP_82)
26+
->withRules([
27+
TypedPropertyFromStrictConstructorRector::class,
28+
])
29+
->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [
30+
'inline_public' => true,
31+
'rename_property' => true,
32+
]);

vendor-bin/rector/composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"config": {
3+
"platform": {
4+
"php": "8.1"
5+
},
6+
"sort-packages": true
7+
},
8+
"require-dev": {
9+
"nextcloud/rector": "^0.5.2"
10+
}
11+
}

0 commit comments

Comments
 (0)