algoritma / php-coding-standards
A usefull PHP Coding Standard for your projects, based on PHPStan, PHP CS Fixer and Rector.
Installs: 31
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:composer-plugin
pkg:composer/algoritma/php-coding-standards
Requires
- php: >=8.1
- composer-plugin-api: ^1.1 || ^2.0
- ext-json: *
- composer/composer: ^1.3.2 || ^2.0
- friendsofphp/php-cs-fixer: v3.91.1
- nette/neon: ^3.4
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-deprecation-rules: ^2.0
- rector/rector: ^2.0
- rector/type-perfect: ^2.0
- symfony/console: ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0
- symplify/phpstan-rules: ^14.0
- ticketswap/phpstan-error-formatter: ^1.1
- tomasvotruba/type-coverage: ^2.0
Requires (Dev)
- composer/semver: ^3.0
- jangregor/phpstan-prophecy: ^2.0
- phpspec/prophecy: ^v1.20
- phpspec/prophecy-phpunit: ^v2.3
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.0
- roave/security-advisories: dev-latest
- dev-main
- 3.0.38
- 3.0.37
- 3.0.36
- 3.0.35
- 3.0.34
- 3.0.33
- 3.0.32
- 3.0.31
- 3.0.30
- 3.0.29
- 3.0.28
- 3.0.27
- 3.0.26
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- v1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- v1.0.0
- dev-dependabot/composer/friendsofphp/php-cs-fixer-v3.91.2
This package is auto-updated.
Last update: 2025-12-04 13:39:42 UTC
README
| Version | PHP version supported |
|---|---|
| 3.0 | >= 8.1 |
Installation
To install the coding standard, run the following command:
$ composer require --dev algoritma/php-coding-standards
When you install it, a plugin will ask you some questions to setup your project automatically.
The installer will add the .php-cs-fixer.dist.php, rector.php, and phpstan.neon files in your project root directory. You can then edit them manually if you need to make any changes.
The CS config will be configured to find your project files using composer autoload sources. Only psr-0, psr-4 and classmap autoloads are supported.
The installer will also add five scripts in your composer.json;
"scripts": { "cs-check": "php-cs-fixer fix --dry-run --diff --allow-risky yes", "cs-fix": "php-cs-fixer fix --diff --allow-risky yes", "rector-check": "rector process --dry-run", "rector-fix": "rector process", "phpstan": "phpstan analyze" }
Usage
To start code style check:
$ composer cs-check
To automatically fix code style:
$ composer cs-fix
To automatically check for refactor:
$ composer rector-check
To automatically refactor fix:
$ composer rector-fix
To run static analisys check:
$ composer phpstan
Main Dependencies
This project relies on the following tools to enforce coding standards:
Configuration
For more information on how to configure the tools, please refer to their official documentation.
Risky rules (PHP-CS-Fixer)
Risky rules may be unstable, and cause unintended behavioral changes to your code. If you want to add these rules, you can create your own .php-cs-fixer.php
configuration:
<?php /** @var \PhpCsFixer\Config $config */ $config = include __DIR__ . '/.php-cs-fixer.dist.php'; $rulesProvider = new Algoritma\CodingStandards\Rules\CompositeRulesProvider([ new Algoritma\CodingStandards\Rules\DefaultRulesProvider(), new Algoritma\CodingStandards\Rules\RiskyRulesProvider(), new Algoritma\CodingStandards\Rules\ArrayRulesProvider([ // additional rules or rules to override ]), ]); $config->setRules($rulesProvider->getRules()); return $config;
Generate configuration
If you have any problem updating to a new version, you can regenerate
the default .php-cs-fixer.dist.php with the command:
$ composer algoritma-cs-create-config
$ composer algoritma-cs-create-config --help
Usage:
algoritma-cs-create-config [options]
Options:
--no-dev Do not include autoload-dev directories
--no-risky Do not include risky rules
If you have any problem updating to a new version, you can regenerate
the default rector.php with the command:
$ composer algoritma-rector-create-config
$ composer algoritma-rector-create-config --help
Usage:
algoritma-rector-create-config [options]
Options:
--no-dev Do not include autoload-dev directories
If you have any problem updating to a new version, you can regenerate
the default phpstan.neon with the command:
$ composer algoritma-phpstan-create-config
$ composer algoritma-phpstan-create-config --help
Usage:
algoritma-phpstan-create-config [options]
Options:
--no-dev Do not include autoload-dev directories