Skip to content

Commit

Permalink
Added Rector.
Browse files Browse the repository at this point in the history
  • Loading branch information
corpsee committed Feb 11, 2024
1 parent d831076 commit c72da77
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/codecov.yml export-ignore
/rector.php export-ignore
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ code-style-fix: php-info install ## Fix code style
psalm: php-info install ## Run Psalm check
$(PHP) vendor/bin/psalm --config=psalm.xml.dist --threads=4 --show-snippet=true --show-info=true

.PHONY: php-info list install install-force update test test-coverage mutation-test code-style-fix psalm
rector: php-info install ## Run Rector
$(PHP) vendor/bin/rector process --clear-cache --dry-run

.PHONY: php-info list install install-force update test test-coverage mutation-test code-style-fix psalm rector
.DEFAULT_GOAL := list
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"phpmd/phpmd": "^1.5",
"sebastian/phpcpd": "^6.0",
"phploc/phploc": "^7.0",
"php-parallel-lint/php-parallel-lint": "^1.3"
"php-parallel-lint/php-parallel-lint": "^1.3",
"rector/rector": "^1.0"
},
"extra": {
"platform": {
Expand Down
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
//use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->skip([]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
/* SetList::PHP_81,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,*/
]);
};

0 comments on commit c72da77

Please sign in to comment.