@@ -25,18 +25,19 @@ composer require --dev lmc/coding-standard
25
25
use Symplify\EasyCodingStandard\Config\ECSConfig;
26
26
27
27
return ECSConfig::configure()
28
+ ->withPaths([__DIR__ . '/src', __DIR__ . '/tests']) // optionally add 'config' or other directories with PHP files
29
+ ->withRootFiles() // to include ecs.php and all other php files in the root directory
28
30
->withSets(
29
31
[
30
32
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
31
33
]
32
34
);
33
35
34
36
// Be default only checks compatible with PHP 8.0 are enabled.
35
- // Depending on the lowest PHP version your project need to support, you can enable additional checks for
36
- // PHP 8.1, 8.2 and 8.3.
37
+ // Depending on the lowest PHP version your project needs to support, you can enable additional checks.
37
38
38
-
39
- // Import one of ecs-8.1.php, ecs-8.2.php or ecs-8.3.php. Use only one file ( for the highest possible PHP version) .
39
+ // Import one of ecs-8.1.php, ecs-8.2.php or ecs-8.3.php. Use only one additional file (for the highest possible
40
+ // PHP version), the configs for previous versions are automatically included .
40
41
//->withSets(
41
42
// [
42
43
// __DIR__ . '/vendor/lmc/coding-standard/ecs.php',
@@ -45,23 +46,23 @@ return ECSConfig::configure()
45
46
//);
46
47
```
47
48
48
- 2 . Run the check command (for ` src/ ` and ` tests/ ` directories):
49
+ 2 . Run the check command
49
50
50
51
``` bash
51
- vendor/bin/ecs check src/ tests/
52
+ vendor/bin/ecs check
52
53
```
53
54
54
55
3 . Optionally we recommend adding this to ` scripts ` section of your ` composer.json ` :
55
56
56
57
``` json
57
58
"scripts" : {
58
59
"analyze" : [
59
- " vendor/bin/ecs check src/ tests/ --ansi" ,
60
+ " vendor/bin/ecs check --ansi" ,
60
61
" [... other scripts, like PHPStan etc.]"
61
62
],
62
63
"fix" : [
63
64
" ..." ,
64
- " vendor/bin/ecs check ./src/ ./tests/ --ansi --fix"
65
+ " vendor/bin/ecs check --ansi --fix"
65
66
],
66
67
}
67
68
```
@@ -83,6 +84,7 @@ use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
83
84
use Symplify\EasyCodingStandard\Config\ECSConfig;
84
85
85
86
return ECSConfig::configure()
87
+ /* (...) */
86
88
->withSets(
87
89
[
88
90
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
@@ -92,6 +94,7 @@ return ECSConfig::configure()
92
94
->withConfiguredRule(LineLengthSniff::class, ['absoluteLineLimit' => 120])
93
95
// Tests must have @test annotation
94
96
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation']);
97
+ /* (...) */
95
98
```
96
99
97
100
See [ EasyCodingStandard docs] ( https://github.com/symplify/easy-coding-standard#configuration ) for more configuration options.
@@ -111,6 +114,7 @@ use PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff;
111
114
use Symplify\EasyCodingStandard\Config\ECSConfig;
112
115
113
116
return ECSConfig::configure()
117
+ /* (...) */
114
118
->withSkip([
115
119
// Ignore specific check only in specific files
116
120
ForbiddenFunctionsSniff::class => [__DIR__ . '/src-tests/bootstrap.php'],
@@ -126,6 +130,7 @@ return ECSConfig::configure()
126
130
__DIR__ . '/vendor/lmc/coding-standard/ecs.php',
127
131
]
128
132
);
133
+ /* (...) */
129
134
```
130
135
131
136
See [ EasyCodingStandard docs] ( https://github.com/symplify/easy-coding-standard#configuration ) for more configuration options.
0 commit comments