From 3717d3836e653fd813c0e7f9627c02637cfd7c38 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Sat, 6 Jan 2024 00:13:27 +0100 Subject: [PATCH] feat(deps): add Rector for code quality improvements - Added "rector/rector" package to composer.json - Created rector.php configuration file with rules for code quality improvements --- composer.json | 1 + composer.lock | 120 +++++++++++++++++++++++++++++++++++++++++++++++++- rector.php | 22 +++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 rector.php diff --git a/composer.json b/composer.json index bf3a5af..1f18f87 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/phpunit": "^10.1", + "rector/rector": "^0.18.13", "spatie/laravel-ignition": "^2.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index cc3fc70..3a02915 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "977c4e8990bc192edf2ad99855f154dc", + "content-hash": "d901f542703c0b38d905aa8be6c6e938", "packages": [ { "name": "andcarpi/laravel-popper", @@ -9378,6 +9378,68 @@ }, "time": "2023-12-16T09:33:33+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.54", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "3e25f279dada0adc14ffd7bad09af2e2fc3523bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3e25f279dada0adc14ffd7bad09af2e2fc3523bb", + "reference": "3e25f279dada0adc14ffd7bad09af2e2fc3523bb", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-05T15:50:47+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "10.1.11", @@ -9800,6 +9862,62 @@ ], "time": "2023-12-27T15:13:52+00:00" }, + { + "name": "rector/rector", + "version": "0.18.13", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f8011a76d36aa4f839f60f3b4f97707d97176618", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.10.35" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.18.13" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2023-12-20T16:08:01+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.0", diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..08ad538 --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +rule(TypedPropertyFromStrictConstructorRector::class); + + // here we can define, what sets of rules will be applied + // tip: use "SetList" class to autocomplete sets with your IDE + $rectorConfig->sets([ + SetList::CODE_QUALITY, + SetList::CODING_STYLE, + SetList::DEAD_CODE, + SetList::EARLY_RETURN, + SetList::STRICT_BOOLEANS, + LevelSetList::UP_TO_PHP_82 + ]); +};