From c72da779d6f50e82a8636f7e72cb3728b5af2821 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 11 Feb 2024 22:42:57 +0700 Subject: [PATCH] Added Rector. --- .gitattributes | 1 + Makefile | 5 ++++- composer.json | 3 ++- rector.php | 30 ++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 rector.php diff --git a/.gitattributes b/.gitattributes index fee66c5..f055917 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,4 @@ /phpunit.xml.dist export-ignore /psalm.xml.dist export-ignore /codecov.yml export-ignore +/rector.php export-ignore diff --git a/Makefile b/Makefile index 64ca9cb..b73c270 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/composer.json b/composer.json index 4192996..9ba4e39 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..bf7a4d5 --- /dev/null +++ b/rector.php @@ -0,0 +1,30 @@ +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,*/ + ]); +};