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
This commit is contained in:
Rico van Zelst
2024-01-06 00:13:27 +01:00
parent 984b7a862d
commit 3717d3836e
3 changed files with 142 additions and 1 deletions

View File

@@ -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": {

120
composer.lock generated
View File

@@ -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",

22
rector.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
return static function (RectorConfig $rectorConfig): void {
// register single rule
$rectorConfig->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
]);
};