Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enabled:
- phpdoc_no_empty_return
- phpdoc_no_useless_inheritdoc
- phpdoc_order
- phpdoc_param_order
- phpdoc_property
- phpdoc_scalar
- phpdoc_singular_inheritdoc
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.3.2 Under development

- Enh #17: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)

## 0.3.1 January 20, 2026

- Bug #14: Update descriptions in stub classes to clarify purpose (@terabytesoftw)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ final class EnumDataProviderTagCasesTest extends TestCase

For detailed configuration options and advanced usage.

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

## Package information

Expand Down
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "library",
"description": "Support utilities for enhanced testing capabilities.",
"keywords": [
"php",
"php-forge",
"php",
"support",
"testing",
"tests"
Expand All @@ -16,12 +16,11 @@
"require-dev": {
"infection/infection": "^0.27|^0.32",
"maglnet/composer-require-checker": "^4.1",
"php-forge/coding-standard": "^0.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^2.2",
"symplify/easy-coding-standard": "^13.0"
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -56,11 +55,10 @@
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml",
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist"
],
"tests": "./vendor/bin/phpunit"
}
Expand Down
5 changes: 2 additions & 3 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To keep configuration files synchronized with the latest template updates, use t
downloads the latest configuration files from the template repository.

```bash
composer run sync-metadata
composer sync-metadata
```

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

### When to Run

Expand Down
29 changes: 19 additions & 10 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,74 @@ Tool references:
- [Infection](https://infection.github.io/) for mutation testing.
- [PHPStan](https://phpstan.org/) for static analysis.
- [PHPUnit](https://phpunit.de/) for unit tests.
- [Rector](https://github.com/rectorphp/rector) for automated refactoring.

## Automated refactoring (Rector)

Run Rector to apply automated code refactoring.

```bash
composer rector
```

## Coding standards (ECS)

Run Easy Coding Standard (ECS) and apply fixes.

```bash
composer run ecs
composer ecs
```

## Dependency definition check

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

```bash
composer run check-dependencies
composer check-dependencies
```

## Mutation testing (Infection)

Run mutation testing.

```bash
composer run mutation
composer mutation
```

Run mutation testing with static analysis enabled.

```bash
composer run mutation-static
composer mutation-static
```

## Static analysis (PHPStan)

Run static analysis.

```bash
composer run static
composer static
```

## Unit tests (PHPUnit)

Run the full test suite.

```bash
composer run tests
composer tests
```

## Passing extra arguments

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

Example: run a specific PHPUnit test or filter by name.
Run PHPUnit with code coverage report generation.

```bash
composer run tests -- --filter SvgTest
composer tests -- --coverage-html code_coverage
```

Example: run PHPStan with a different memory limit:
Run PHPStan with a different memory limit.

```bash
composer run static -- --memory-limit=512M
composer static -- --memory-limit=512M
```
89 changes: 8 additions & 81 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,12 @@

declare(strict_types=1);

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

return ECSConfig::configure()
->withConfiguredRule(
ClassDefinitionFixer::class,
[
'space_before_parenthesis' => true,
],
)
->withConfiguredRule(
OrderedClassElementsFixer::class,
[
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'case',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'method_protected_abstract',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'alpha',
],
)
->withConfiguredRule(
OrderedImportsFixer::class,
[
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
)
->withConfiguredRule(
PhpdocTypesOrderFixer::class,
[
'sort_algorithm' => 'none',
'null_adjustment' => 'always_last',
],
)
->withFileExtensions(['php'])
->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
)
->withPhpCsFixerSets(perCS30: true)
->withPreparedSets(
cleanCode: true,
comments: true,
docblocks: true,
namespaces: true,
strict: true,
)
->withRules(
[
NoUnusedImportsFixer::class,
OrderedTraitsFixer::class,
SingleQuoteFixer::class,
]
)
->withSkip(
[
NullableTypeDeclarationFixer::class,
]
);
return $ecsConfigBuilder->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);
18 changes: 3 additions & 15 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@

declare(strict_types=1);

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

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

$rectorConfig->paths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);

$rectorConfig->sets(
[
Rector\Set\ValueObject\SetList::PHP_81,
Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81,
Rector\Set\ValueObject\SetList::TYPE_DECLARATION,
],
);

$rectorConfig->rule(
Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class
);
};
Loading