Skip to content

Commit

Permalink
build(composer-root-version-checker): Add Rector (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Nov 21, 2023
1 parent e142c45 commit f64cbc8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
21 changes: 20 additions & 1 deletion composer-root-version-checker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ MAKEFLAGS += --no-builtin-rules
PHPUNIT_BIN = vendor/bin/phpunit
PHPUNIT = $(PHPUNIT_BIN)

RECTOR_BIN = ../vendor-bin/rector/vendor/bin/rector
RECTOR = $(RECTOR_BIN) --config=rector.php


.PHONY: help
help:
Expand All @@ -17,7 +20,7 @@ help:


.PHONY: check
check: cs cs_lint check_root_version phpunit
check: rector cs autoreview check_root_version phpunit


.PHONY: check_root_version
Expand All @@ -32,6 +35,11 @@ dump_root_version: vendor
@./bin/dump


.PHONY: autoreview
autoreview: ## Runs the AutoReview checks
autoreview: cs_lint rector_lint


.PHONY: cs
cs: ## Runs the fixers
cs: gitignore_sort composer_normalize php_cs_fixer
Expand Down Expand Up @@ -75,6 +83,14 @@ php_cs_fixer_lint:
phpunit: $(PHPUNIT_BIN) vendor
$(PHPUNIT)

.PHONY: rector
rector: $(RECTOR_BIN)
$(RECTOR)

.PHONY: rector_lint
rector_lint: $(RECTOR_BIN)
$(RECTOR) --dry-run

vendor: composer.lock
composer install
touch -c $@
Expand All @@ -86,3 +102,6 @@ composer.lock: composer.json

$(PHPUNIT_BIN): vendor
touch -c $@

$(RECTOR_BIN):
cd ..; $(MAKE) --makefile Makefile $@
39 changes: 39 additions & 0 deletions composer-root-version-checker/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/*
* This file is part of the humbug/php-scoper package.
*
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
* Pádraic Brady <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/bin',
__DIR__.'/src',
__DIR__.'/tests',
]);

$rectorConfig->autoloadPaths([
__DIR__.'/vendor/autoload.php',
__DIR__.'/../vendor-bin/rector/vendor/autoload.php',
]);

$rectorConfig->importNames();

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
LevelSetList::UP_TO_PHP_82,

PHPUnitSetList::PHPUNIT_90,
]);
};
1 change: 1 addition & 0 deletions composer-root-version-checker/tests/MakefileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function getExpectedHelpOutput(): string
check_root_version: Checks that the Composer root version is up to date
dump_root_version: Dumps the latest Composer root version
autoreview: Runs the AutoReview checks
cs: Runs the fixers
cs_lint: Runs the linters
test: Runs the tests
Expand Down

0 comments on commit f64cbc8

Please sign in to comment.