Skip to content

Commit 65ffdab

Browse files
feat(dev): Add php-forge/coding-standard to development dependencies for code quality checks (#119)
1 parent 9bb3020 commit 65ffdab

4 files changed

Lines changed: 14 additions & 118 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Bug #116: Update `LICENSE` and `composer.json` (@terabytesoftw)
1919
- Bug #117: Raise PHPStan level to `5` (@terabytesoftw)
2020
- Bug #118: Add `phpdoc_param_order` rule and update namespace references in `rector.php` (@terabytesoftw)
21+
- Enh #119: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
2122

2223
## 0.1.2 June 10, 2024
2324

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
},
3333
"require-dev": {
3434
"maglnet/composer-require-checker": "^4.7",
35+
"php-forge/coding-standard": "^0.1",
3536
"php-forge/support": "^0.3",
3637
"phpstan/extension-installer": "^1.4",
3738
"phpstan/phpstan": "^2.1",
3839
"phpstan/phpstan-strict-rules": "^2.0.3",
3940
"phpunit/phpunit": "^10.5",
40-
"rector/rector": "^2.2",
41-
"symplify/easy-coding-standard": "^13.0",
4241
"xepozz/internal-mocker": "^1.4"
4342
},
4443
"suggest": {
@@ -81,11 +80,9 @@
8180
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
8281
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
8382
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
84-
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
8583
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
8684
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
87-
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
88-
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
85+
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist"
8986
],
9087
"tests": "./vendor/bin/phpunit"
9188
}

ecs.php

Lines changed: 8 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,12 @@
22

33
declare(strict_types=1);
44

5-
use PhpCsFixer\Fixer\ClassNotation\{ClassDefinitionFixer, OrderedClassElementsFixer, OrderedTraitsFixer};
6-
use PhpCsFixer\Fixer\Import\{NoUnusedImportsFixer, OrderedImportsFixer};
7-
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
8-
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
9-
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
10-
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
11-
use Symplify\EasyCodingStandard\Config\ECSConfig;
5+
/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
6+
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';
127

13-
return ECSConfig::configure()
14-
->withConfiguredRule(
15-
ClassDefinitionFixer::class,
16-
[
17-
'space_before_parenthesis' => true,
18-
],
19-
)
20-
->withConfiguredRule(
21-
NullableTypeDeclarationFixer::class,
22-
[
23-
'syntax' => 'union',
24-
],
25-
)
26-
->withConfiguredRule(
27-
OrderedClassElementsFixer::class,
28-
[
29-
'order' => [
30-
'use_trait',
31-
'constant_public',
32-
'constant_protected',
33-
'constant_private',
34-
'case',
35-
'property_public',
36-
'property_protected',
37-
'property_private',
38-
'construct',
39-
'destruct',
40-
'magic',
41-
'method_public_abstract',
42-
'method_protected_abstract',
43-
'method_public',
44-
'method_protected',
45-
'method_private',
46-
],
47-
'sort_algorithm' => 'alpha',
48-
],
49-
)
50-
->withConfiguredRule(
51-
OrderedImportsFixer::class,
52-
[
53-
'imports_order' => [
54-
'class',
55-
'function',
56-
'const',
57-
],
58-
'sort_algorithm' => 'alpha',
59-
],
60-
)
61-
->withConfiguredRule(
62-
PhpdocTypesOrderFixer::class,
63-
[
64-
'sort_algorithm' => 'none',
65-
'null_adjustment' => 'always_last',
66-
],
67-
)
68-
->withConfiguredRule(
69-
PhpUnitTestCaseStaticMethodCallsFixer::class,
70-
[
71-
'call_type' => 'self',
72-
],
73-
)
74-
->withFileExtensions(['php'])
75-
->withPaths(
76-
[
77-
__DIR__ . '/src',
78-
__DIR__ . '/tests',
79-
],
80-
)
81-
->withPhpCsFixerSets(perCS30: true)
82-
->withPreparedSets(
83-
cleanCode: true,
84-
comments: true,
85-
docblocks: true,
86-
namespaces: true,
87-
strict: true,
88-
)
89-
->withRules(
90-
[
91-
NoUnusedImportsFixer::class,
92-
OrderedTraitsFixer::class,
93-
SingleQuoteFixer::class,
94-
]
95-
);
8+
return $ecsConfigBuilder->withPaths(
9+
[
10+
__DIR__ . '/src',
11+
__DIR__ . '/tests',
12+
],
13+
);

rector.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,15 @@
22

33
declare(strict_types=1);
44

5-
return static function (\Rector\Config\RectorConfig $rectorConfig): void {
6-
$rectorConfig->parallel();
5+
use Rector\Config\RectorConfig;
76

8-
$rectorConfig->importNames();
7+
return static function (RectorConfig $rectorConfig): void {
8+
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');
99

1010
$rectorConfig->paths(
1111
[
1212
__DIR__ . '/src',
1313
__DIR__ . '/tests',
1414
],
1515
);
16-
17-
$rectorConfig->sets(
18-
[
19-
\Rector\Set\ValueObject\SetList::PHP_81,
20-
\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81,
21-
\Rector\Set\ValueObject\SetList::TYPE_DECLARATION,
22-
],
23-
);
24-
25-
$rectorConfig->skip(
26-
[
27-
\Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector::class,
28-
],
29-
);
30-
31-
$rectorConfig->rules(
32-
[
33-
\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class,
34-
],
35-
);
3616
};

0 commit comments

Comments
 (0)