spiral / code-style
Code style and static analysis tools rulesets collection
Fund package maintenance!
Requires
- php: >=8.2
- php-cs-fixer/shim: ^3.64
Requires (Dev)
- spiral/dumper: ^3.3
- testo/testo: ^0.10.55
- vimeo/psalm: ^6 || ^7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.0
- v1.1.0
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.2.0
- v0.1.0
- dev-release-please--branches--master--components--spiral/code-style
- dev-ci/mutation-testing
- dev-static-analysis
- dev-coverage
- dev-fix/include-error-message
- dev-testo
- dev-ci/fix-ci
- dev-ci/release-please
- dev-feat/ordered-imports-fqst
This package is auto-updated.
Last update: 2026-10-10 00:03:50 UTC
README
This repository contains ruleset for PHP CS Fixer based on PER-2.
Installation and configuration
Install the package via composer:
composer require --dev spiral/code-style
Create a configuration file .php-cs-fixer.dist.php in the root of your project:
<?php declare(strict_types=1); require_once 'vendor/autoload.php'; return \Spiral\CodeStyle\Builder::create() ->include(__DIR__ . '/src') ->include(__FILE__) ->build();
Feel free to adjust the paths to include/exclude files and directories.
Usage
To more convenient usage, you can add the following commands to the scripts section of the composer.json file:
{
"scripts": {
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
"cs:fix": "php-cs-fixer fix -v"
}
}
Now you can run the following commands:
composer cs:diff composer cs:fix
CI integration
If you want to integrate code style check into CI, add the following step to your GitHub Actions configuration file:
on: push: branches: - '*' name: Check Code Style jobs: cs-check: uses: spiral/gh-actions/.github/workflows/cs.yml@master
If you want GitHub Actions to automatically fix the found errors, add the following step:
on: push: branches: - '*' name: Fix Code Style jobs: cs-fix: permissions: contents: write uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master