Skip to content

Commit 832a50b

Browse files
committed
Add rector files yiisoft/yii-dev-tool#232
1 parent 117a502 commit 832a50b

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.github/workflows/rector.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
on:
2+
push:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.env.example'
9+
- '.gitattributes'
10+
- 'infection.json.dist'
11+
- 'phpunit.xml.dist'
12+
13+
name: rector
14+
15+
jobs:
16+
rector:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Install PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: 8.0
26+
tools: composer:v2
27+
coverage: none
28+
29+
- name: Determine composer cache directory
30+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
31+
32+
- name: Cache dependencies installed with composer
33+
uses: actions/cache@v2
34+
with:
35+
path: ${{ env.COMPOSER_CACHE_DIR }}
36+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
37+
restore-keys: |
38+
php${{ matrix.php }}-composer-
39+
40+
- name: Update composer
41+
run: composer self-update
42+
43+
- name: Install dependencies with composer
44+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
45+
46+
- run: vendor/bin/rector process --ansi
47+
48+
- name: Check for Rector modified files
49+
id: rector-git-check
50+
run: echo ::set-output name=modified::$(if git diff --exit-code --no-patch; then echo "false"; else echo "true"; fi)
51+
52+
- name: Git config
53+
if: steps.rector-git-check.outputs.modified == 'true'
54+
run: |
55+
git config --global user.name 'rector-bot'
56+
git config --global user.email 'rector@yiiframework.com'
57+
58+
- name: Commit Rector changes
59+
if: steps.rector-git-check.outputs.modified == 'true'
60+
run: git commit -am "[rector] Apply fixes"
61+
62+
- name: Push changes
63+
if: steps.rector-git-check.outputs.modified == 'true'
64+
run: git push
65+

rector.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
17+
18+
// define sets of rules
19+
$rectorConfig->sets([
20+
LevelSetList::UP_TO_PHP_80,
21+
]);
22+
};

0 commit comments

Comments
 (0)