Skip to content

Commit 69ca842

Browse files
Added rector
1 parent a65d1cc commit 69ca842

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/psalm.xml export-ignore
1515
/CHANGELOG.md export-ignore
1616
/README.md export-ignore
17+
/rector.yml export-ignore

.github/workflows/static.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,42 @@ jobs:
6868

6969
- name: Execute Psalm
7070
run: vendor/bin/psalm --no-progress --output-format=github
71+
72+
rector:
73+
name: Rector
74+
runs-on: ubuntu-20.04
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v2
79+
80+
- name: Setup PHP
81+
uses: shivammathur/setup-php@v2
82+
with:
83+
php-version: 7.4
84+
tools: composer:v2, cs2pr
85+
coverage: none
86+
87+
- name: Install Dependencies
88+
uses: nick-invision/retry@v1
89+
with:
90+
timeout_minutes: 5
91+
max_attempts: 5
92+
command: composer update --no-interaction --no-progress
93+
94+
- name: Install PHPUnit
95+
uses: nick-invision/retry@v1
96+
with:
97+
timeout_minutes: 5
98+
max_attempts: 5
99+
command: composer bin phpunit update --no-interaction --no-progress
100+
101+
- name: Install Rector
102+
uses: nick-invision/retry@v1
103+
with:
104+
timeout_minutes: 5
105+
max_attempts: 5
106+
command: composer bin rector update --no-interaction --no-progress
107+
108+
- name: Execute Rector
109+
run: vendor/bin/rector process --dry-run --output-format=checkstyle | cs2pr

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ psalm-baseline:
2020
psalm-show-info:
2121
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --show-info=true
2222

23-
test: phpunit phpstan-analyze psalm-analyze
23+
rector-dry-run:
24+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/rector --rm registry.gitlab.com/grahamcampbell/php:7.4-cli process --dry-run
25+
26+
rector-fix:
27+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/rector --rm registry.gitlab.com/grahamcampbell/php:7.4-cli process
28+
29+
test: phpunit phpstan-analyze psalm-analyze rector-dry-run
2430

2531
clean:
2632
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor

rector.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
parameters:
2+
autoload_paths:
3+
- 'vendor/autoload.php'
4+
- 'vendor-bin/phpunit/vendor/autoload.php'
5+
auto_import_names: true
6+
import_short_classes: false
7+
import_doc_blocks: false
8+
php_version_features: '5.6'
9+
paths:
10+
- 'lib'
11+
- 'test'
12+
sets:
13+
- 'code-quality'
14+
- 'dead-code'
15+
- 'php52'
16+
- 'php53'
17+
- 'php54'
18+
- 'php55'
19+
- 'php56'
20+
- 'phpunit40'
21+
- 'phpunit50'
22+
23+
services:
24+
Rector\SOLID\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector: ~
25+
Rector\SOLID\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector: ~
26+
Rector\SOLID\Rector\If_\ChangeNestedIfsToEarlyReturnRector: ~
27+
Rector\SOLID\Rector\If_\RemoveAlwaysElseRector: ~

vendor-bin/rector/composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"require": {
3+
"rector/rector": "~0.7.48"
4+
},
5+
"config": {
6+
"preferred-install": "dist"
7+
}
8+
}

0 commit comments

Comments
 (0)