Skip to content

Commit

Permalink
Add rector files yiisoft/yii-dev-tool#232
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Sep 27, 2022
1 parent 63636cc commit 42c5e31
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.env.example'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'

name: rector

jobs:
rector:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: composer:v2
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Update composer
run: composer self-update

- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- run: vendor/bin/rector process --ansi

- name: Check for Rector modified files
id: rector-git-check
run: echo ::set-output name=modified::$(if git diff --exit-code --no-patch; then echo "false"; else echo "true"; fi)

- name: Git config
if: steps.rector-git-check.outputs.modified == 'true'
run: |
git config --global user.name 'rector-bot'
git config --global user.email 'rector@yiiframework.com'
- name: Commit Rector changes
if: steps.rector-git-check.outputs.modified == 'true'
run: git commit -am "[rector] Apply fixes"

- name: Push changes
if: steps.rector-git-check.outputs.modified == 'true'
run: git push

22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

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

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);
};

0 comments on commit 42c5e31

Please # to comment.