Skip to content

Commit b89b65a

Browse files
committed
chore(ci): add ecs to ci
1 parent ac7d74a commit b89b65a

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
2929
- name: Run PHPStan
3030
run: php vendor/bin/phpstan
31+
- name: Run ECS
32+
run: php vendor/bin/ecs
3133

3234
- name: Run test suite
3335
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
tests/_support
66
tests/_output
77
tests/cases/yii2-app-advanced/_data/db.sqlite
8-
.php-cs-fixer.cache
8+
.php-cs-fixer.cache
9+
.ecs-cache

ecs.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// ecs.php
6+
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
7+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
8+
use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer;
9+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
10+
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
11+
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
12+
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
13+
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
14+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
15+
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
16+
use Symplify\EasyCodingStandard\Config\ECSConfig;
17+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
18+
19+
return static function (ECSConfig $ecsConfig): void {
20+
// Parallel
21+
$ecsConfig->parallel();
22+
23+
$ecsConfig->cacheDirectory('.ecs-cache');
24+
// Paths
25+
$ecsConfig->paths([
26+
__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php'
27+
]);
28+
29+
// A. full sets
30+
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES]);
31+
32+
$ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class);
33+
$ecsConfig->rule(ArraySyntaxFixer::class);
34+
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
35+
'annotations' => ['author', 'inheritdoc']
36+
]);
37+
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
38+
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
39+
'allow_mixed' => true
40+
]);
41+
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
42+
$ecsConfig->rule(NoUnusedImportsFixer::class);
43+
$ecsConfig->rule(DeclareStrictTypesFixer::class);
44+
$ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [
45+
'annotation_exclude' => ['@not-fix', '@internal'],
46+
'annotation_include' => [],
47+
'consider_absent_docblock_as_internal_class' => \true
48+
]);
49+
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
50+
'forbiddenFunctions' => [
51+
'passthru' => null,
52+
'var_dump' => null,
53+
]
54+
]);
55+
$ecsConfig->skip([
56+
ForbiddenFunctionsSniff::class => [
57+
'tests/**',
58+
'console/**'
59+
]
60+
]);
61+
62+
// $ecsConfig->skip([
63+
// FinalClassFixer::class => [
64+
// 'tests/**'
65+
// ]
66+
// ]);
67+
};

0 commit comments

Comments
 (0)