Skip to content

Commit 905a363

Browse files
committed
chore(tools): use castor for cs fixer and phpstan instead of tools directory
1 parent 1d0ab8a commit 905a363

File tree

12 files changed

+123
-1995
lines changed

12 files changed

+123
-1995
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,18 @@ jobs:
77
- name: checkout
88
uses: actions/checkout@master
99
- name: setup
10-
uses: shivammathur/[email protected]
11-
with:
12-
php-version: 8.2
13-
coverage: none
14-
- name: install PHP CS Fixer
15-
run: 'composer install -n --prefer-dist --optimize-autoloader --working-dir=tools/php-cs-fixer'
10+
uses: castor-php/[email protected]
1611
- name: 'php-cs-fixer check'
17-
run: 'tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.php --dry-run --diff'
12+
run: 'castor qa:cs:check'
1813
phpstan:
1914
runs-on: ubuntu-latest
2015
steps:
2116
- name: checkout
2217
uses: actions/checkout@master
23-
- name: cache-composer
24-
uses: actions/cache@v4
25-
with:
26-
path: ~/.composer/cache/
27-
key: composer-${{ github.sha }}
2818
- name: setup
29-
uses: shivammathur/[email protected]
30-
with:
31-
php-version: 8.3
32-
coverage: none
33-
- name: composer install
34-
run: composer update --prefer-stable
35-
- name: install phpstan
36-
run: 'composer install -n --prefer-dist --optimize-autoloader --working-dir=tools/phpstan'
19+
uses: castor-php/[email protected]
3720
- name: 'phpstan check'
38-
run: 'tools/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan/phpstan.neon'
21+
run: 'castor qa:phpstan'
3922
tests:
4023
runs-on: ubuntu-latest
4124
name: tests

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ vendor/
55
tests/cache/
66
tests/Bundle/Resources/var
77
tools/phpstan/cache/
8+
cache/
89
site/
9-
.build/
10+
.build/
11+
.castor*
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
$finder = (new PhpCsFixer\Finder())
4-
->in(__DIR__ . '/../../src')
5-
->in(__DIR__ . '/../../tests')
4+
->in(__DIR__ . '/src')
5+
->in(__DIR__ . '/tests')
6+
->append([__DIR__ . '/castor.php'])
67
->exclude(['cache', 'Bundle/Resources/var'])
78
;
89

castor.composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"castor-php/php-qa": "@dev"
4+
}
5+
}

castor.composer.lock

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castor.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Castor\Attribute\AsTask;
6+
7+
use function Castor\PHPQa\php_cs_fixer;
8+
use function Castor\PHPQa\phpstan;
9+
10+
#[AsTask('cs:check', namespace: 'qa', description: 'Check for coding standards without fixing them')]
11+
function qa_cs_check()
12+
{
13+
php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '--dry-run', '--diff'], '3.50', [
14+
'kubawerlos/php-cs-fixer-custom-fixers' => '^3.21',
15+
]);
16+
}
17+
18+
#[AsTask('cs:fix', namespace: 'qa', description: 'Fix all coding standards')]
19+
function qa_cs_fix()
20+
{
21+
php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php'], '3.50', [
22+
'kubawerlos/php-cs-fixer-custom-fixers' => '^3.21',
23+
]);
24+
}
25+
26+
#[AsTask('phpstan', namespace: 'qa', description: 'Run PHPStan for static analysis')]
27+
function qa_phpstan()
28+
{
29+
phpstan(['analyse', '--configuration', __DIR__ . '/phpstan.neon', '-vvv'], '1.11.1');
30+
}

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src/
5+
6+
tmpDir: cache
7+
8+
ignoreErrors:
9+
- "#Instantiated class fromIteratorToArray not found#"
10+
- "#Instantiated class toArray not found#"
11+
12+
parallel:
13+
maximumNumberOfProcesses: 1

tools/php-cs-fixer/composer.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)