Skip to content

Commit 9eb5640

Browse files
committed
Add ECS
1 parent 113a8ee commit 9eb5640

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Coding Standard
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standard:
9+
name: Coding Standard
10+
uses: brick/coding-standard/.github/workflows/coding-standard.yml@main
11+
with:
12+
php-version: "8.2"

.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": "dev-main"
4+
},
5+
"config": {
6+
"allow-plugins": {
7+
"dealerdirect/phpcodesniffer-composer-installer": true
8+
}
9+
}
10+
}

tools/ecs/ecs.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff;
5+
use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
6+
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
7+
use SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff;
8+
use SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff;
9+
use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff;
10+
use Symplify\EasyCodingStandard\Config\ECSConfig;
11+
12+
return static function (ECSConfig $ecsConfig): void {
13+
$ecsConfig->import(__DIR__ . '/vendor/brick/coding-standard/ecs.php');
14+
15+
$libRootPath = __DIR__ . '/../../';
16+
17+
$ecsConfig->paths(
18+
[
19+
$libRootPath . '/src',
20+
$libRootPath . '/tests',
21+
__FILE__,
22+
],
23+
);
24+
25+
$ecsConfig->indentation('spaces');
26+
27+
$ecsConfig->skip([
28+
// Only interested in FunctionCommentSniff.ParamCommentFullStop, excludes the rest
29+
FunctionCommentSniff::class . '.Missing' => null,
30+
FunctionCommentSniff::class . '.MissingReturn' => null,
31+
FunctionCommentSniff::class . '.MissingParamTag' => null,
32+
FunctionCommentSniff::class . '.EmptyThrows' => null,
33+
FunctionCommentSniff::class . '.IncorrectParamVarName' => null,
34+
FunctionCommentSniff::class . '.IncorrectTypeHint' => null,
35+
FunctionCommentSniff::class . '.MissingParamComment' => null,
36+
FunctionCommentSniff::class . '.ParamNameNoMatch' => null,
37+
FunctionCommentSniff::class . '.InvalidReturn' => null,
38+
39+
// Allows alignment in test providers
40+
DuplicateSpacesSniff::class => [$libRootPath . '/tests'],
41+
42+
// Keep a line between same use types, spacing around uses is done in other fixers
43+
UseSpacingSniff::class . '.IncorrectLinesCountBeforeFirstUse' => null,
44+
UseSpacingSniff::class . '.IncorrectLinesCountAfterLastUse' => null,
45+
46+
// We want to keep BigNumber|int|float|string order
47+
OrderedTypesFixer::class => null,
48+
PhpdocTypesOrderFixer::class => null,
49+
50+
// Fails with @ pure @ codeCoverageIgnore on successive lines
51+
DocCommentSpacingSniff::class . '.IncorrectAnnotationsGroup' => null,
52+
]);
53+
};

0 commit comments

Comments
 (0)