From 40c0ea9cbf4dd598c69ab4a4e8977e4afb8e1383 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 24 Jan 2026 13:48:12 -0300 Subject: [PATCH 1/3] feat(coding-standard): Added shared configuration files under `config/` for Composer-based reuse. --- .github/linters/actionlint.yml | 1 - .github/workflows/build.yml | 22 ---- .github/workflows/dependency-check.yml | 21 ---- .github/workflows/mutation.yml | 25 ---- .github/workflows/static.yml | 21 ---- CHANGELOG.md | 4 + README.md | 166 +++++++++++++++++++------ composer.json | 49 ++------ config/ecs.php | 96 ++++++++++++++ config/rector.php | 42 +++++++ docs/development.md | 11 +- docs/svgs/features-mobile.svg | 26 ++-- docs/svgs/features.svg | 26 ++-- docs/testing.md | 99 ++++++--------- ecs.php | 99 ++------------- phpstan.neon | 24 ---- phpunit.xml.dist | 24 ---- rector.php | 34 ++--- 18 files changed, 359 insertions(+), 431 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/dependency-check.yml delete mode 100644 .github/workflows/mutation.yml delete mode 100644 .github/workflows/static.yml create mode 100644 config/ecs.php create mode 100644 config/rector.php delete mode 100644 phpstan.neon delete mode 100644 phpunit.xml.dist diff --git a/.github/linters/actionlint.yml b/.github/linters/actionlint.yml index 785d850..328407a 100644 --- a/.github/linters/actionlint.yml +++ b/.github/linters/actionlint.yml @@ -4,4 +4,3 @@ paths: ignore: - '"pull_request" section is alias node but mapping node is expected' - '"push" section is alias node but mapping node is expected' - - "section is alias node but mapping node is expected" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 3254d3d..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -on: - pull_request: &ignore-paths - paths-ignore: - - ".gitattributes" - - ".gitignore" - - "CHANGELOG.md" - - "docs/**" - - "README.md" - - push: *ignore-paths - -name: build - -permissions: - contents: read - -jobs: - phpunit: - uses: yii2-framework/actions/.github/workflows/phpunit.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml deleted file mode 100644 index e69d7d1..0000000 --- a/.github/workflows/dependency-check.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -on: - pull_request: &ignore-paths - paths-ignore: - - ".gitattributes" - - ".gitignore" - - "CHANGELOG.md" - - "docs/**" - - "README.md" - - push: *ignore-paths - -name: Composer require checker - -permissions: - contents: read - pull-requests: write - -jobs: - composer-require-checker: - uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@main diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml deleted file mode 100644 index 91ef2b9..0000000 --- a/.github/workflows/mutation.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -on: - pull_request: &ignore-paths - paths-ignore: - - ".gitattributes" - - ".gitignore" - - "CHANGELOG.md" - - "docs/**" - - "README.md" - - push: *ignore-paths - -name: mutation test - -permissions: - contents: read - pull-requests: write - -jobs: - mutation: - uses: yii2-framework/actions/.github/workflows/infection.yml@v1 - with: - phpstan: true - secrets: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml deleted file mode 100644 index 99d7c1c..0000000 --- a/.github/workflows/static.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -on: - pull_request: &ignore-paths - paths-ignore: - - ".gitattributes" - - ".gitignore" - - "CHANGELOG.md" - - "docs/**" - - "README.md" - - push: *ignore-paths - -name: static analysis - -permissions: - contents: read - pull-requests: write - -jobs: - phpstan: - uses: yii2-framework/actions/.github/workflows/phpstan.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md index 825c32f..7daab10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,5 @@ # Changelog + +## 0.1.0 January 24, 2026 + +- Enh #1 Added shared configuration files under `config/` for Composer-based reuse (@terabytesoftw) diff --git a/README.md b/README.md index 6d30a53..4e89d64 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,22 @@

- - - - Yii Framework - -

Template

+ + PHP Forge + +

Coding Standard


- - PHPUnit - - - Mutation Testing - - - PHPStan + + Super-Linter

- A Yii2 extension template to create your own Yii2 extensions
- PHPUnit, PHPStan, Codeception, and best practices ready out of the box + Centralized ECS and Rector configuration for PHP projects
+ Share one set of rules across multiple repositories via Composer.

## Features @@ -34,46 +26,138 @@ Feature Overview +## Installation + +```bash +composer require php-forge/coding-standard:^0.1 --dev +``` + ## Quick start -### Installation +This package provides shared configuration files under `vendor/php-forge/coding-standard/config/`: -```bash -composer require github_username/github_repository-name +- `config/ecs.php` (shared ECS rules, no paths) +- `config/rector.php` (shared Rector rules, no paths) + +Consumer repositories should create wrapper config files at the repository root. +Wrappers define the paths for that repository and import the shared configuration. + +### Generic repository + +#### ECS (ecs.php) + +Create `ecs.php` in your repository root: + +```php +withPaths( + [ + __DIR__ . '/src', + __DIR__ . '/tests', + ], +); ``` -### Basic Usage +To override or skip rules locally, apply changes after requiring the shared config: -Describe how to use your extension in a basic way. +```php +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withSkip([ + // Add project-specific skips here. + ]); +``` -## Package information +#### Rector (rector.php) -[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php) -[![Yii 2.0.x](https://img.shields.io/badge/2.0.53-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white)](https://github.com/yiisoft/yii2/tree/2.0.53) -[![Yii 22.0.x](https://img.shields.io/badge/22.0.x-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white)](https://github.com/yiisoft/yii2/tree/22.0) -[![Latest Stable Version](https://img.shields.io/packagist/v/yii2-extensions/template.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/yii2-extensions/template) -[![Total Downloads](https://img.shields.io/packagist/dt/yii2-extensions/template.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/yii2-extensions/template) +Create `rector.php` in your repository root: + +```php +import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php'); -## Our social networks + $rectorConfig->paths( + [ + __DIR__ . '/src', + __DIR__ . '/tests', + ], + ); -[![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white&labelColor=000000)](https://x.com/Terabytesoftw) + // Project-specific overrides can be added after the import. + // $rectorConfig->skip([...]); +}; +``` + +### Yii2 repositories + +If you need framework-specific rules (Yii2), keep them in a separate config file (or a separate package) +and import it after the base configuration. Do not mix Yii2-specific rules into the generic base. + +Example (Rector): + +```php +import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php'); + $rectorConfig->import(__DIR__ . '/rector-yii2.php'); + + $rectorConfig->paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); +}; +``` + +## Composer scripts + +Follow the same convention used across PHP Forge repositories: + +```json +{ + "scripts": { + "ecs": "./vendor/bin/ecs --fix", + "rector": "./vendor/bin/rector process" + } +} +``` + +## Documentation + +- [Testing Guide](docs/testing.md) +- [Development Guide](docs/development.md) + +## Package information + +[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php) +[![Latest Stable Version](https://img.shields.io/packagist/v/php-forge/coding-standard.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/php-forge/coding-standard) +[![Total Downloads](https://img.shields.io/packagist/dt/php-forge/coding-standard.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/php-forge/coding-standard) ## License diff --git a/composer.json b/composer.json index 45e64bf..3d93975 100644 --- a/composer.json +++ b/composer.json @@ -1,68 +1,41 @@ { - "name": "yii2/template", + "name": "php-forge/coding-standard", "type": "library", - "description": "_____", + "description": "Coding standards for PHP projects.", "keywords": [ - "_____" + "coding-standard", + "php", + "yii2" ], "license": "BSD-3-Clause", "minimum-stability": "dev", "prefer-stable": true, "require": { "php": ">=8.1", - "yiisoft/yii2": "^2.2" - }, - "require-dev": { - "infection/infection": "^0.27|^0.31", - "maglnet/composer-require-checker": "^4.1", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan-strict-rules": "^2.0.3", - "phpunit/phpunit": "^10.5", "rector/rector": "^2.1", - "symplify/easy-coding-standard": "^13.0", - "yii2-extensions/phpstan": "^0.3" + "symplify/easy-coding-standard": "^13.0" }, "autoload": { "psr-4": { - "yii\\template\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "yii\\template\\tests\\": "tests" + "PHPForge\\CodingStandard\\": "/" } }, "extra": { "branch-alias": { - "dev-main": "1.0.x-dev" + "dev-main": "0.2.x-dev" } }, "config": { - "sort-packages": true, - "allow-plugins": { - "infection/extension-installer": true, - "phpstan/extension-installer": true, - "yiisoft/yii2-composer": true - } + "sort-packages": true }, "scripts": { - "check-dependencies": "./vendor/bin/composer-require-checker check", "ecs": "./vendor/bin/ecs --fix", - "mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100", - "mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'", - "rector": "./vendor/bin/rector process src", - "static": "./vendor/bin/phpstan --memory-limit=-1", "sync-metadata": [ "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 .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml", - "curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php", - "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 .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml" ], - "tests": "./vendor/bin/phpunit" + "rector": "./vendor/bin/rector process" } } diff --git a/config/ecs.php b/config/ecs.php new file mode 100644 index 0000000..cb68994 --- /dev/null +++ b/config/ecs.php @@ -0,0 +1,96 @@ +withConfiguredRule( + ClassDefinitionFixer::class, + [ + 'space_before_parenthesis' => true, + ], + ) + ->withConfiguredRule( + NullableTypeDeclarationFixer::class, + [ + 'syntax' => 'union', + ], + ) + ->withConfiguredRule( + OrderedClassElementsFixer::class, + [ + 'order' => [ + 'use_trait', + 'constant_public', + 'constant_protected', + 'constant_private', + 'case', + 'property_public', + 'property_protected', + 'property_private', + 'construct', + 'destruct', + 'magic', + 'method_public_abstract', + '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', + ], + ) + ->withConfiguredRule( + PhpUnitTestCaseStaticMethodCallsFixer::class, + [ + 'call_type' => 'self', + ], + ) + ->withFileExtensions(['php']) + ->withPhpCsFixerSets(perCS30: true) + ->withPreparedSets( + cleanCode: true, + comments: true, + docblocks: true, + namespaces: true, + strict: true, + ) + ->withRules( + [ + NoUnusedImportsFixer::class, + OrderedTraitsFixer::class, + SingleQuoteFixer::class, + ], + ); diff --git a/config/rector.php b/config/rector.php new file mode 100644 index 0000000..ccc509b --- /dev/null +++ b/config/rector.php @@ -0,0 +1,42 @@ +parallel(); + + $rectorConfig->importNames(); + + $rectorConfig->sets( + [ + SetList::PHP_81, + LevelSetList::UP_TO_PHP_81, + SetList::TYPE_DECLARATION, + ], + ); + + $rectorConfig->skip( + [ + TypedPropertyFromCreateMockAssignRector::class, + ], + ); + + $rectorConfig->rules( + [ + SimplifyEmptyArrayCheckRector::class, + ], + ); +}; diff --git a/docs/development.md b/docs/development.md index dfb83e9..e6689f0 100644 --- a/docs/development.md +++ b/docs/development.md @@ -20,11 +20,12 @@ 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 | -| `infection.json5` | Infection mutation testing configuration | -| `phpstan.neon` | PHPStan static analysis configuration | -| `phpunit.xml.dist` | PHPUnit test configuration | -| `rector.php` | Rector refactoring configuration | + +## Shared configuration layout + +This package exposes shared configuration files under `config/`. +Consumer repositories should create wrapper config files at their repository root +and import these shared configs. ### When to Run diff --git a/docs/svgs/features-mobile.svg b/docs/svgs/features-mobile.svg index bf256de..275ea03 100644 --- a/docs/svgs/features-mobile.svg +++ b/docs/svgs/features-mobile.svg @@ -1,5 +1,5 @@ - +
-

Best Practices

-

PSR standards • Clean code • Documentation ready

+

Centralized Configuration

+

Easy Coding Standard (ECS) • Rector

-

Easy Setup

-

Quick start template • Configuration examples • Clear structure

+

Composer-Friendly Approach

+

Update rules in one place

-

GitHub Actions

-

CI/CD workflows • Automated testing • Quality checks

+

Designed to be Extended

+

Local overrides • Skips remain possible

-

Quality Tools

-

PHPStan Level Max • StyleCI • Super-Linter integration

-
-
-

PHP 8.1+

-

Modern PHP features • Type safety • Performance optimizations

-
-
-

Testing Ready

-

PHPUnit setup • Mutation testing • Codecov integration

+

Minimal Consumer Repositories

+

Define only project paths

diff --git a/docs/svgs/features.svg b/docs/svgs/features.svg index 7b45188..ad2ff55 100644 --- a/docs/svgs/features.svg +++ b/docs/svgs/features.svg @@ -1,4 +1,4 @@ - +
-

Best Practices

-

PSR standards • Clean code • Documentation ready

+

Centralized Configuration

+

Easy Coding Standard (ECS) • Rector

-

Easy Setup

-

Quick start template • Configuration examples • Clear structure

+

Composer-Friendly Approach

+

Update rules in one place

-

GitHub Actions

-

CI/CD workflows • Automated testing • Quality checks

+

Designed to be Extended

+

Local overrides • Skips remain possible

-

Quality Tools

-

PHPStan Level Max • StyleCI • Super-Linter integration

-
-
-

PHP 8.1+

-

Modern PHP features • Type safety • Performance optimizations

-
-
-

Testing Ready

-

PHPUnit setup • Mutation testing • Codecov integration

+

Minimal Consumer Repositories

+

Define only project paths

diff --git a/docs/testing.md b/docs/testing.md index 8373457..9db2f98 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -1,95 +1,78 @@ # Testing -This document describes the quality assurance tools and testing workflows available in this project. +This package provides a consistent set of [Composer](https://getcomposer.org/) scripts for local validation. -## Code refactoring +Tool references: -Automatically refactors code to modern standards and applies best practices. +- [Composer Require Checker](https://github.com/maglnet/ComposerRequireChecker) for dependency definition checks. +- [Easy Coding Standard (ECS)](https://github.com/easy-coding-standard/easy-coding-standard) for coding standards. +- [Infection](https://infection.github.io/) for mutation testing. +- [PHPStan](https://phpstan.org/) for static analysis. +- [PHPUnit](https://phpunit.de/) for unit tests. -| Tool | Command | Target | Purpose | -| -------------------------------- | --------------------- | ------ | ------------------------------ | -| [Rector](https://getrector.com/) | `composer run rector` | `src/` | Upgrade and modernize codebase | +## Coding standards (ECS) -```shell -composer run rector -``` - ---- - -## Code style and standards - -Automatically fixes coding standard issues to maintain consistent code style across the project. - -| Tool | Command | Purpose | -| ------------------------------------------------------------------------------------ | ------------------ | ----------------------------------------- | -| [Easy Coding Standard](https://github.com/easy-coding-standard/easy-coding-standard) | `composer run ecs` | Enforce PER 3.0 + PSR-12 coding standards | +Run Easy Coding Standard (ECS) and apply fixes. -```shell +```bash composer run ecs ``` ---- +### Shared configuration -## Dependency checking +This repository ships shared configuration files under `config/` for reuse. +Consumer repositories should define their own wrapper `ecs.php` and set project paths there. -Checks if all dependencies are correctly defined in `composer.json` to avoid missing packages in production. +## Dependency definition check -| Tool | Command | Purpose | -| ----------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------ | -| [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) | `composer run check-dependencies` | Verify all used classes and functions are declared as dependencies | +Verify that runtime dependencies are correctly declared in `composer.json`. -```shell +```bash composer run check-dependencies ``` ---- +## Mutation testing (Infection) -## Mutation Testing +Run mutation testing. -Evaluates the quality of your test suite by introducing mutations and checking if tests catch them. - -| Tool | Command | Coverage | Purpose | -| ----------------------------------------- | ----------------------- | -------- | -------------------------------- | -| [Infection](https://infection.github.io/) | `composer run mutation` | 100% MSI | Measure test suite effectiveness | - -```shell +```bash composer run mutation ``` ---- - -## Mutation Testing with Static Analysis - -Combines mutation testing with PHPStan analysis for comprehensive quality checks. +Run mutation testing with static analysis enabled. -```shell +```bash composer run mutation-static ``` ---- +## Static analysis (PHPStan) -## Static Analysis +Run static analysis. -Performs static code analysis to detect bugs, type errors, and code quality issues before runtime. +```bash +composer run static +``` -| Tool | Command | Level | Purpose | -| ------------------------------- | --------------------- | --------- | ------------------------------------- | -| [PHPStan](https://phpstan.org/) | `composer run static` | Level Max | Detect type errors and potential bugs | +## Unit tests (PHPUnit) -```shell -composer run static +Run the full test suite. + +```bash +composer run tests ``` ---- +## Passing extra arguments + +Composer scripts support forwarding additional arguments using `--`. -## Unit Testing +Example: run a specific PHPUnit test or filter by name. -Executes unit tests to verify functionality and ensure code correctness. +```bash +composer run tests -- --filter SvgTest +``` -| Tool | Command | Framework | Purpose | -| ------------------------------ | -------------------- | ----------- | -------------------- | -| [PHPUnit](https://phpunit.de/) | `composer run tests` | PHPUnit 10+ | Verify code behavior | +Example: run PHPStan with a different memory limit: -```shell -composer run tests +```bash +composer run static -- --memory-limit=512M ``` diff --git a/ecs.php b/ecs.php index 4f78988..5e92c64 100644 --- a/ecs.php +++ b/ecs.php @@ -2,94 +2,13 @@ declare(strict_types=1); -use PhpCsFixer\Fixer\ClassNotation\{ClassDefinitionFixer, OrderedClassElementsFixer, OrderedTraitsFixer}; -use PhpCsFixer\Fixer\Import\{NoUnusedImportsFixer, OrderedImportsFixer}; -use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer; -use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer; -use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer; -use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer; -use Symplify\EasyCodingStandard\Config\ECSConfig; +/** + * Prefer importing vendor/php-forge/coding-standard/config/ecs.php in consumer repositories. + * + * @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder + */ +$ecsConfigBuilder = require __DIR__ . '/config/ecs.php'; -return ECSConfig::configure() - ->withConfiguredRule( - ClassDefinitionFixer::class, - [ - 'space_before_parenthesis' => true, - ], - ) - ->withConfiguredRule( - NullableTypeDeclarationFixer::class, - [ - 'syntax' => 'union', - ], - ) - ->withConfiguredRule( - OrderedClassElementsFixer::class, - [ - 'order' => [ - 'use_trait', - 'constant_public', - 'constant_protected', - 'constant_private', - 'case', - 'property_public', - 'property_protected', - 'property_private', - 'construct', - 'destruct', - 'magic', - 'method_public_abstract', - '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', - ], - ) - ->withConfiguredRule( - PhpUnitTestCaseStaticMethodCallsFixer::class, - [ - 'call_type' => 'self', - ], - ) - ->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, - ] - ); +return $ecsConfigBuilder->withPaths( + [__DIR__ . '/config'], +); diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 735031c..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,24 +0,0 @@ -includes: - - phar://phpstan.phar/conf/bleedingEdge.neon - -parameters: - bootstrapFiles: - - tests/bootstrap.php - - level: max - - paths: - - src - - tests - - tmpDir: %currentWorkingDirectory%/runtime - - # Enable strict advanced checks - checkImplicitMixed: true - checkBenevolentUnionTypes: true - checkUninitializedProperties: true - checkMissingCallableSignature: true - checkTooWideReturnTypesInProtectedAndPublicMethods: true - reportAnyTypeWideningInVarTag: true - reportPossiblyNonexistentConstantArrayOffset: true - reportPossiblyNonexistentGeneralArrayOffset: true diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 33b6694..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - tests - - - - - - ./src - - - diff --git a/rector.php b/rector.php index 25d1066..11e1b45 100644 --- a/rector.php +++ b/rector.php @@ -2,35 +2,15 @@ declare(strict_types=1); -return static function (\Rector\Config\RectorConfig $rectorConfig): void { - $rectorConfig->parallel(); +use Rector\Config\RectorConfig; - $rectorConfig->importNames(); +/** + * Prefer importing vendor/php-forge/coding-standard/config/rector.php in consumer repositories. + */ +return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/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->skip( - [ - \Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector::class, - ], - ); - - $rectorConfig->rules( - [ - \Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class, - ], + [__DIR__ . '/config'], ); }; From 7cda3bb5bd7ac5a05ae003f32b855f5f53882eab Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 24 Jan 2026 14:01:35 -0300 Subject: [PATCH 2/3] style: Refactor code formatting for consistency in configuration files. --- README.md | 38 ++++++++++++++++++++++---------------- composer.json | 2 +- ecs.php | 4 +++- rector.php | 4 +++- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 4e89d64..86b61b6 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,17 @@ declare(strict_types=1); $ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php'; return $ecsConfigBuilder - ->withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withSkip([ - // Add project-specific skips here. - ]); + ->withPaths( + [ + __DIR__ . '/src', + __DIR__ . '/tests', + ], + ) + ->withSkip( + [ + // add project-specific skips here. + ], + ); ``` #### Rector (rector.php) @@ -105,7 +109,7 @@ return static function (RectorConfig $rectorConfig): void { ], ); - // Project-specific overrides can be added after the import. + // project-specific overrides can be added after the import. // $rectorConfig->skip([...]); }; ``` @@ -128,10 +132,12 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php'); $rectorConfig->import(__DIR__ . '/rector-yii2.php'); - $rectorConfig->paths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]); + $rectorConfig->paths( + [ + __DIR__ . '/src', + __DIR__ . '/tests', + ], + ); }; ``` @@ -141,10 +147,10 @@ Follow the same convention used across PHP Forge repositories: ```json { - "scripts": { - "ecs": "./vendor/bin/ecs --fix", - "rector": "./vendor/bin/rector process" - } + "scripts": { + "ecs": "./vendor/bin/ecs --fix", + "rector": "./vendor/bin/rector process" + } } ``` diff --git a/composer.json b/composer.json index 3d93975..234d6a1 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "autoload": { "psr-4": { - "PHPForge\\CodingStandard\\": "/" + "PHPForge\\CodingStandard\\": "./" } }, "extra": { diff --git a/ecs.php b/ecs.php index 5e92c64..f6c705f 100644 --- a/ecs.php +++ b/ecs.php @@ -10,5 +10,7 @@ $ecsConfigBuilder = require __DIR__ . '/config/ecs.php'; return $ecsConfigBuilder->withPaths( - [__DIR__ . '/config'], + [ + __DIR__ . '/config', + ], ); diff --git a/rector.php b/rector.php index 11e1b45..70de101 100644 --- a/rector.php +++ b/rector.php @@ -11,6 +11,8 @@ $rectorConfig->import(__DIR__ . '/config/rector.php'); $rectorConfig->paths( - [__DIR__ . '/config'], + [ + __DIR__ . '/config', + ], ); }; From 62bcb4510f8548f4f1ea7316c0b425a3a75dde19 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 24 Jan 2026 14:05:24 -0300 Subject: [PATCH 3/3] style: Update headings and table formatting for consistency in documentation. --- README.md | 2 +- docs/development.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 86b61b6..aa92151 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ PHP Forge -

Coding Standard

+

Coding standard


diff --git a/docs/development.md b/docs/development.md index e6689f0..fd10316 100644 --- a/docs/development.md +++ b/docs/development.md @@ -15,11 +15,11 @@ composer run sync-metadata This command updates the following configuration files: -| File | Purpose | -| ------------------ | -------------------------------------------- | -| `.editorconfig` | Editor settings and code style configuration | -| `.gitattributes` | Git attributes and file handling rules | -| `.gitignore` | Git ignore patterns and exclusions | +| File | Purpose | +| ---------------- | -------------------------------------------- | +| `.editorconfig` | Editor settings and code style configuration | +| `.gitattributes` | Git attributes and file handling rules | +| `.gitignore` | Git ignore patterns and exclusions | ## Shared configuration layout