Skip to content

Commit f39e4f8

Browse files
committed
Add ECS
1 parent 80bb9db commit f39e4f8

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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

.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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff;
6+
use SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff;
7+
use SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff;
8+
use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff;
9+
use Symplify\EasyCodingStandard\Config\ECSConfig;
10+
11+
return static function (ECSConfig $ecsConfig): void {
12+
$ecsConfig->import(__DIR__ . '/vendor/brick/coding-standard/ecs.php');
13+
14+
$libRootPath = __DIR__ . '/../../';
15+
16+
$ecsConfig->paths(
17+
[
18+
$libRootPath . '/src',
19+
$libRootPath . '/tests',
20+
__FILE__,
21+
],
22+
);
23+
24+
$ecsConfig->indentation('spaces');
25+
26+
$ecsConfig->skip([
27+
// Only interested in FunctionCommentSniff.ParamCommentFullStop, excludes the rest
28+
FunctionCommentSniff::class . '.Missing' => null,
29+
FunctionCommentSniff::class . '.MissingReturn' => null,
30+
FunctionCommentSniff::class . '.MissingParamTag' => null,
31+
FunctionCommentSniff::class . '.EmptyThrows' => null,
32+
FunctionCommentSniff::class . '.IncorrectParamVarName' => null,
33+
FunctionCommentSniff::class . '.IncorrectTypeHint' => null,
34+
FunctionCommentSniff::class . '.MissingParamComment' => null,
35+
FunctionCommentSniff::class . '.ParamNameNoMatch' => null,
36+
FunctionCommentSniff::class . '.InvalidReturn' => null,
37+
38+
// Keep a line between same use types, spacing around uses is done in other fixers
39+
UseSpacingSniff::class . '.IncorrectLinesCountBeforeFirstUse' => null,
40+
UseSpacingSniff::class . '.IncorrectLinesCountAfterLastUse' => null,
41+
]);
42+
};

0 commit comments

Comments
 (0)