Skip to content

Commit 411b5a6

Browse files
authored
Add Rector as dev dependency (#23)
* Add and initialise Rector * Add Rector entries to Makefile
1 parent e91f14a commit 411b5a6

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
help:
44
@echo ""
55
@echo "Available tasks:"
6-
@echo " test Run all tests and generate coverage"
7-
@echo " watch Run all tests and coverage when a source file is upaded"
8-
@echo " lint Run linter and code style checker"
9-
@echo " lint-fix Fix linter and code style checker errors"
10-
@echo " unit Run unit tests and generate coverage"
11-
@echo " static Run static analysis"
12-
@echo " vendor Install dependencies"
13-
@echo " clean Remove vendor and composer.lock"
6+
@echo " test Run all tests and generate coverage"
7+
@echo " watch Run all tests and coverage when a source file is upaded"
8+
@echo " lint Run linter and code style checker"
9+
@echo " lint-fix Fix linter and code style checker errors"
10+
@echo " rector Do a Rector dry run"
11+
@echo " rector-fix Apply Rector rules to the code"
12+
@echo " unit Run unit tests and generate coverage"
13+
@echo " static Run static analysis"
14+
@echo " vendor Install dependencies"
15+
@echo " clean Remove vendor and composer.lock"
1416
@echo ""
1517

1618
vendor: $(wildcard composer.lock)
@@ -23,6 +25,13 @@ lint: vendor
2325
lint-fix: vendor
2426
vendor/bin/ecs check src tests demo --fix
2527

28+
rector: vendor
29+
vendor/bin/rector --dry-run
30+
31+
rector-fix: vendor
32+
vendor/bin/rector
33+
vendor/bin/ecs check src tests --fix
34+
2635
unit: vendor
2736
phpdbg -qrr vendor/bin/phpunit --testdox --coverage-text --coverage-clover=coverage.xml --coverage-html=./report/
2837

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"overtrue/phplint": "^0.2.0",
3434
"phpunit/phpunit": "^7.0|^8.0|^9.0",
3535
"psr/http-message": "^1.0.1",
36+
"rector/rector": "^0.14.0",
3637
"symplify/easy-coding-standard": "^11.1",
3738
"tuupola/http-factory": "^1.0"
3839
},

rector.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Set\ValueObject\SetList;
8+
use Rector\PHPUnit\Set\PHPUnitSetList;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->paths([
12+
__DIR__ . "/src",
13+
__DIR__ . "/tests",
14+
__DIR__ . "/demo",
15+
]);
16+
17+
$rectorConfig->sets([
18+
LevelSetList::UP_TO_PHP_72,
19+
// SetList::CODE_QUALITY,
20+
// SetList::DEAD_CODE,
21+
// SetList::PRIVATIZATION,
22+
// SetList::NAMING,
23+
// SetList::TYPE_DECLARATION,
24+
// SetList::EARLY_RETURN,
25+
// SetList::TYPE_DECLARATION_STRICT,
26+
// PHPUnitSetList::PHPUNIT_CODE_QUALITY,
27+
// PHPUnitSetList::PHPUNIT_90,
28+
// SetList::CODING_STYLE,
29+
]);
30+
};

0 commit comments

Comments
 (0)