Skip to content

Commit 3f5b5d3

Browse files
committed
feat(dev): Add php-forge/coding-standard to development dependencies for code quality checks.
1 parent 3906008 commit 3f5b5d3

File tree

8 files changed

+42
-118
lines changed

8 files changed

+42
-118
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enabled:
5555
- phpdoc_no_empty_return
5656
- phpdoc_no_useless_inheritdoc
5757
- phpdoc_order
58+
- phpdoc_param_order
5859
- phpdoc_property
5960
- phpdoc_scalar
6061
- phpdoc_singular_inheritdoc

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 0.3.2 Under development
44

5+
- Bug #17: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
6+
57
## 0.3.1 January 20, 2026
68

79
- Bug #14: Update descriptions in stub classes to clarify purpose (@terabytesoftw)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ final class EnumDataProviderTagCasesTest extends TestCase
299299

300300
For detailed configuration options and advanced usage.
301301

302-
- [Testing Guide](docs/testing.md)
303-
- [Development Guide](docs/development.md)
302+
- 🧪 [Testing Guide](docs/testing.md)
303+
- 🛠️ [Development Guide](docs/development.md)
304304

305305
## Package information
306306

composer.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "library",
44
"description": "Support utilities for enhanced testing capabilities.",
55
"keywords": [
6-
"php",
76
"php-forge",
7+
"php",
88
"support",
99
"testing",
1010
"tests"
@@ -16,12 +16,11 @@
1616
"require-dev": {
1717
"infection/infection": "^0.27|^0.32",
1818
"maglnet/composer-require-checker": "^4.1",
19+
"php-forge/coding-standard": "^0.1",
1920
"phpstan/extension-installer": "^1.4",
2021
"phpstan/phpstan": "^2.1",
2122
"phpstan/phpstan-strict-rules": "^2.0.3",
22-
"phpunit/phpunit": "^10.5",
23-
"rector/rector": "^2.2",
24-
"symplify/easy-coding-standard": "^13.0"
23+
"phpunit/phpunit": "^10.5"
2524
},
2625
"autoload": {
2726
"psr-4": {
@@ -56,11 +55,10 @@
5655
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
5756
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
5857
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
59-
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
58+
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml",
6059
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
6160
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
62-
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
63-
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
61+
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist"
6462
],
6563
"tests": "./vendor/bin/phpunit"
6664
}

docs/development.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To keep configuration files synchronized with the latest template updates, use t
88
downloads the latest configuration files from the template repository.
99

1010
```bash
11-
composer run sync-metadata
11+
composer sync-metadata
1212
```
1313

1414
### Updated Files
@@ -20,11 +20,10 @@ This command updates the following configuration files:
2020
| `.editorconfig` | Editor settings and code style configuration |
2121
| `.gitattributes` | Git attributes and file handling rules |
2222
| `.gitignore` | Git ignore patterns and exclusions |
23-
| `ecs.php` | Easy Coding Standard configuration |
23+
| `.styleci.yml` | StyleCI code style analysis configuration |
2424
| `infection.json5` | Infection mutation testing configuration |
2525
| `phpstan.neon` | PHPStan static analysis configuration |
2626
| `phpunit.xml.dist` | PHPUnit test configuration |
27-
| `rector.php` | Rector refactoring configuration |
2827

2928
### When to Run
3029

docs/testing.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,74 @@ Tool references:
99
- [Infection](https://infection.github.io/) for mutation testing.
1010
- [PHPStan](https://phpstan.org/) for static analysis.
1111
- [PHPUnit](https://phpunit.de/) for unit tests.
12+
- [Rector](https://github.com/rectorphp/rector) for automated refactoring.
13+
14+
## Automated refactoring (Rector)
15+
16+
Run Rector to apply automated code refactoring.
17+
18+
```bash
19+
composer rector
20+
```
1221

1322
## Coding standards (ECS)
1423

1524
Run Easy Coding Standard (ECS) and apply fixes.
1625

1726
```bash
18-
composer run ecs
27+
composer ecs
1928
```
2029

2130
## Dependency definition check
2231

2332
Verify that runtime dependencies are correctly declared in `composer.json`.
2433

2534
```bash
26-
composer run check-dependencies
35+
composer check-dependencies
2736
```
2837

2938
## Mutation testing (Infection)
3039

3140
Run mutation testing.
3241

3342
```bash
34-
composer run mutation
43+
composer mutation
3544
```
3645

3746
Run mutation testing with static analysis enabled.
3847

3948
```bash
40-
composer run mutation-static
49+
composer mutation-static
4150
```
4251

4352
## Static analysis (PHPStan)
4453

4554
Run static analysis.
4655

4756
```bash
48-
composer run static
57+
composer static
4958
```
5059

5160
## Unit tests (PHPUnit)
5261

5362
Run the full test suite.
5463

5564
```bash
56-
composer run tests
65+
composer tests
5766
```
5867

5968
## Passing extra arguments
6069

6170
Composer scripts support forwarding additional arguments using `--`.
6271

63-
Example: run a specific PHPUnit test or filter by name.
72+
Run PHPUnit with code coverage report generation.
6473

6574
```bash
66-
composer run tests -- --filter SvgTest
75+
composer tests -- --coverage-html code_coverage
6776
```
6877

69-
Example: run PHPStan with a different memory limit:
78+
Run PHPStan with a different memory limit.
7079

7180
```bash
72-
composer run static -- --memory-limit=512M
81+
composer static -- --memory-limit=512M
7382
```

ecs.php

Lines changed: 8 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +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\Phpdoc\PhpdocTypesOrderFixer;
8-
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
9-
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
10-
use Symplify\EasyCodingStandard\Config\ECSConfig;
5+
/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
6+
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';
117

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

rector.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +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->rule(
26-
Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class
27-
);
2816
};

0 commit comments

Comments
 (0)