Skip to content

Commit f64cbc8

Browse files
authored
build(composer-root-version-checker): Add Rector (#919)
1 parent e142c45 commit f64cbc8

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

composer-root-version-checker/Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ MAKEFLAGS += --no-builtin-rules
99
PHPUNIT_BIN = vendor/bin/phpunit
1010
PHPUNIT = $(PHPUNIT_BIN)
1111

12+
RECTOR_BIN = ../vendor-bin/rector/vendor/bin/rector
13+
RECTOR = $(RECTOR_BIN) --config=rector.php
14+
1215

1316
.PHONY: help
1417
help:
@@ -17,7 +20,7 @@ help:
1720

1821

1922
.PHONY: check
20-
check: cs cs_lint check_root_version phpunit
23+
check: rector cs autoreview check_root_version phpunit
2124

2225

2326
.PHONY: check_root_version
@@ -32,6 +35,11 @@ dump_root_version: vendor
3235
@./bin/dump
3336

3437

38+
.PHONY: autoreview
39+
autoreview: ## Runs the AutoReview checks
40+
autoreview: cs_lint rector_lint
41+
42+
3543
.PHONY: cs
3644
cs: ## Runs the fixers
3745
cs: gitignore_sort composer_normalize php_cs_fixer
@@ -75,6 +83,14 @@ php_cs_fixer_lint:
7583
phpunit: $(PHPUNIT_BIN) vendor
7684
$(PHPUNIT)
7785

86+
.PHONY: rector
87+
rector: $(RECTOR_BIN)
88+
$(RECTOR)
89+
90+
.PHONY: rector_lint
91+
rector_lint: $(RECTOR_BIN)
92+
$(RECTOR) --dry-run
93+
7894
vendor: composer.lock
7995
composer install
8096
touch -c $@
@@ -86,3 +102,6 @@ composer.lock: composer.json
86102

87103
$(PHPUNIT_BIN): vendor
88104
touch -c $@
105+
106+
$(RECTOR_BIN):
107+
cd ..; $(MAKE) --makefile Makefile $@
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
use Rector\Config\RectorConfig;
16+
use Rector\PHPUnit\Set\PHPUnitSetList;
17+
use Rector\Set\ValueObject\LevelSetList;
18+
19+
return static function (RectorConfig $rectorConfig): void {
20+
$rectorConfig->paths([
21+
__DIR__.'/bin',
22+
__DIR__.'/src',
23+
__DIR__.'/tests',
24+
]);
25+
26+
$rectorConfig->autoloadPaths([
27+
__DIR__.'/vendor/autoload.php',
28+
__DIR__.'/../vendor-bin/rector/vendor/autoload.php',
29+
]);
30+
31+
$rectorConfig->importNames();
32+
33+
$rectorConfig->sets([
34+
LevelSetList::UP_TO_PHP_81,
35+
LevelSetList::UP_TO_PHP_82,
36+
37+
PHPUnitSetList::PHPUNIT_90,
38+
]);
39+
};

composer-root-version-checker/tests/MakefileTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ protected function getExpectedHelpOutput(): string
4040
4141
check_root_version: Checks that the Composer root version is up to date
4242
dump_root_version: Dumps the latest Composer root version
43+
autoreview: Runs the AutoReview checks
4344
cs: Runs the fixers
4445
cs_lint: Runs the linters
4546
test: Runs the tests

0 commit comments

Comments
 (0)