Skip to content

Commit 8be7f41

Browse files
committed
Add brick/coding-standard
1 parent 113a8ee commit 8be7f41

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ jobs:
2828
- name: Run PHPStan
2929
run: vendor/bin/phpstan --no-progress
3030

31+
coding-standard:
32+
name: Coding Standard
33+
uses: brick/coding-standard/.github/workflows/coding-standard.yml@v1
34+
with:
35+
php-version: "8.2"
36+
working-directory: "tools/ecs"
37+
3138
phpunit:
3239
name: PHPUnit
3340
runs-on: ubuntu-latest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/vendor
22
/composer.lock
33
/.phpunit.cache
4+
5+
/tools/*
6+
!/tools/ecs/composer.json
7+
!/tools/ecs/ecs.php

tools/ecs/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require": {
3+
"brick/coding-standard": "v1"
4+
},
5+
"config": {
6+
"allow-plugins": {
7+
"dealerdirect/phpcodesniffer-composer-installer": false
8+
}
9+
}
10+
}

tools/ecs/ecs.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
6+
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
7+
use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff;
8+
use Symplify\EasyCodingStandard\Config\ECSConfig;
9+
10+
return static function (ECSConfig $ecsConfig): void {
11+
$ecsConfig->import(__DIR__ . '/vendor/brick/coding-standard/ecs.php');
12+
13+
$libRootPath = realpath(__DIR__ . '/../..');
14+
15+
$ecsConfig->paths(
16+
[
17+
$libRootPath . '/src',
18+
$libRootPath . '/tests',
19+
$libRootPath . '/phpunit.php',
20+
$libRootPath . '/random-tests.php',
21+
__FILE__,
22+
],
23+
);
24+
25+
$ecsConfig->skip([
26+
// Allows alignment in test providers
27+
DuplicateSpacesSniff::class => [$libRootPath . '/tests'],
28+
29+
// We want to keep BigNumber|int|float|string order
30+
OrderedTypesFixer::class => null,
31+
PhpdocTypesOrderFixer::class => null,
32+
]);
33+
};

0 commit comments

Comments
 (0)