From 7f3ea076441ce198e3a143b04c9f9319e537950b Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 14 Feb 2024 10:08:13 -0500 Subject: [PATCH] Adding rector tool to codebase --- Makefile | 14 ++++++++++++-- rector.php | 22 ++++++++++++++++++++++ tools/rector/composer.json | 5 +++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 rector.php create mode 100644 tools/rector/composer.json diff --git a/Makefile b/Makefile index 629c3085..794c3813 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ PHP_CS_FIXER = tools/php-cs-fixer/vendor/bin/php-cs-fixer PHPUNIT = tools/phpunit/vendor/bin/phpunit PSALM = tools/psalm/vendor/bin/psalm CHURN = tools/churn/vendor/bin/churn +RECTOR = tools/rector/vendor/bin/rector PSALM_BASELINE_FILE = psalm-baseline.xml BARD = src/SonsOfPHP/Bard/bin/bard @@ -213,9 +214,18 @@ churn-install: churn-upgrade: $(COMPOSER) upgrade --working-dir=tools/churn --no-interaction --prefer-dist --optimize-autoloader --with-all-dependencies -tools-install: psalm-install php-cs-fixer-install phpunit-install churn-install +rector: + $(RECTOR) --dry-run -tools-upgrade: psalm-upgrade php-cs-fixer-upgrade phpunit-upgrade churn-upgrade +rector-install: + $(COMPOSER) install --working-dir=tools/rector --no-interaction --prefer-dist --optimize-autoloader + +rector-upgrade: + $(COMPOSER) upgrade --working-dir=tools/rector --no-interaction --prefer-dist --optimize-autoloader --with-all-dependencies + +tools-install: psalm-install php-cs-fixer-install phpunit-install churn-install rector-install + +tools-upgrade: psalm-upgrade php-cs-fixer-upgrade phpunit-upgrade churn-upgrade rector-upgrade ## Documentation docs-install: ## Install deps for building docs diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..e10c787e --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +withPaths([ + __DIR__ . '/src', + ]) + ->withSkip([ + __DIR__ . '/src/SonsOfPHP/*/vendor/*', + __DIR__ . '/src/SonsOfPHP/*/*/vendor/*', + __DIR__ . '/src/SonsOfPHP/*/*/*/vendor/*', + __DIR__ . '/src/SonsOfPHP/*/*/*/*/vendor/*', + ]) + // This should be the same version that is found in composer.json file + ->withPhpSets(php81: true) + ->withRules([ + AddVoidReturnTypeWhereNoReturnRector::class, + ]); diff --git a/tools/rector/composer.json b/tools/rector/composer.json new file mode 100644 index 00000000..056d015c --- /dev/null +++ b/tools/rector/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "rector/rector": "^1.0" + } +}