A tool to automatically fix PHP Coding Standards issues https://cs.symfony.com
Find a file
2026-04-22 08:26:11 +00:00
.github CI: move PHPUnit version management earlier to prevent composer installation phase to run 2 times (#9587) 2026-04-22 08:26:11 +00:00
dev-tools chore: cleanup NoExtraBlankLinesFixer (#9567) 2026-04-16 08:52:01 +02:00
doc feat: @Symfony:risky - add void_return (#9546) 2026-04-11 17:11:54 +00:00
docker/php/ini DX: support PHP 8.4 in local Docker development environment (#8564) 2025-04-05 23:21:22 +02:00
resources UX: enable parallel runner by default (#9408) 2026-02-09 12:39:52 +00:00
src fix: NoRedundantReadonlyPropertyFixer - fix TypeError when trait contains anonymous class (#9457) 2026-04-16 16:48:43 +02:00
tests chore: fix wrong test Attribute (#9586) 2026-04-21 00:35:18 +02:00
.editorconfig chore: Indent JSON files with 4 spaces (#7480) 2023-11-26 19:52:11 +01:00
.env.example DX: change default PHP_CS_FIXER_FAST_LINT_TEST_CASES=1 and run full linting of test cases only on highest and lowest PHP versions in CI (#9448) 2026-02-26 18:25:05 +01:00
.git-blame-ignore-revs chore: Add CS commit to .git-blame-ignore-revs 2026-04-20 13:21:45 +02:00
.gitattributes chore: exclude logo.png and composer-dependency-analyser.php from Composer export (#9516) 2026-03-31 15:19:31 +00:00
.gitignore chore: unify entries in .gitignore (#8982) 2025-08-27 01:11:35 +02:00
.mdlrc DX: Introduce Markdownlint (#7534) 2023-12-09 11:26:19 +01:00
.php-cs-fixer.dist.php chore: CS - apply php_unit_attributes rule (#9578) 2026-04-19 23:14:57 +02:00
.php-cs-fixer.php-highest.php deps: bump the phpstan group in /dev-tools with 2 updates (#9394) 2026-01-30 20:17:14 +00:00
.php-cs-fixer.php-lowest.php chore: apply trailing_comma_in_multiline: elements.arguments (#9314) 2025-12-24 23:32:09 +01:00
.yamllint.yml DX: Ability to run yamllint locally (#9093) 2025-09-24 23:43:57 +02:00
benchmark.sh DX: chmod +x for benchmark.sh file 2021-12-14 19:30:37 +01:00
box.json.dist refactor: don't expose internal commands/rules (#9245) 2025-11-30 23:26:36 +01:00
CHANGELOG.md prepared the 3.95.1 release 2026-04-12 19:00:09 +02:00
compose.override.dist.yaml chore: lint yaml files (#8622) 2025-05-05 11:04:38 +00:00
compose.yaml deps: bump alpine from 3.22 to 3.23 (#9269) 2025-12-05 20:14:52 +01:00
composer-dependency-analyser.php feat: PHP 8.5 compatibility support (#9234) 2025-11-28 02:53:41 +01:00
composer.json feat: Resolve to json format when AI_AGENT environment variable is set (#9542) 2026-04-11 14:21:02 +00:00
CONTRIBUTING.md refactor: don't expose internal commands/rules (#9245) 2025-11-30 23:26:36 +01:00
Dockerfile deps: bump alpine from 3.22 to 3.23 (#9269) 2025-12-05 20:14:52 +01:00
feature-or-bug.rst docs: feature or bug (#6652) 2022-10-17 15:06:15 +02:00
infection.json5.dist test: Ignore PHP version related mutations (#7935) 2024-04-11 11:23:33 +00:00
LICENSE docs: drop license end year (#6767) 2023-02-08 18:36:09 +01:00
logo.md DX: Introduce Markdownlint (#7534) 2023-12-09 11:26:19 +01:00
logo.png Rework documentation 2020-10-25 13:20:44 +01:00
php-cs-fixer chore: fix cs in entry point file (#9064) 2025-09-15 22:56:05 +02:00
phpstan.dist.neon chore: commands cleanup (#9478) 2026-03-07 22:26:52 +00:00
phpunit.xml.dist CI: add failOnDeprecation="true" to PHPUnit config (#8935) 2026-03-28 21:44:29 +01:00
README.md prepared the 3.92.1 release 2025-12-16 00:09:01 +01:00
UPGRADE-v3.md chore: Standardize repository to use British English spelling (#9154) 2025-10-30 09:13:13 +01:00

PHP CS Fixer logo

PHP Coding Standards Fixer

The PHP Coding Standards Fixer (PHP CS Fixer) fixes your code to follow the standards.

If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool not only detects them, but also fixes them for you.

PHP CS Fixer has built-in rule sets, whether you want to follow PHP coding standards as defined by PHP-FIG's PER Coding Style - @PER-CS, a wide community like the Symfony - @Symfony, or our opinionated one - @PhpCsFixer. You can also define your (team's) style through the configuration file.

PHP CS Fixer can not only unify the style of your code, but also help to modernise your codebase towards newer PHP (e.g. @autoPHPMigration and @autoPHPMigration:risky) and newer PHPUnit (e.g. @autoPHPUnitMigration:risky).

There are also @auto and @auto:risky that aim to provide good base rules.

Supported PHP Versions

  • PHP 7.4 - PHP 8.5

Note

Each new PHP version requires a huge effort to support the new syntax. That's why the latest PHP version might not be supported yet. If you need it, please consider supporting the project in any convenient way, for example, with code contributions or reviewing existing PRs. To run PHP CS Fixer on yet unsupported versions "at your own risk" - use --allow-unsupported-php-version=yes option.

Documentation

Installation

The recommended way to install PHP CS Fixer is to use Composer:

composer require --dev friendsofphp/php-cs-fixer
## or when facing conflicts in dependencies:
composer require --dev php-cs-fixer/shim

For more details and other installation methods (also with Docker or behind CI), see installation instructions.

Usage

Assuming you installed PHP CS Fixer as instructed above, you can initialise base config for your project by using following command:

./vendor/bin/php-cs-fixer init

To automatically fix your project, or only check against the need of changes, run:

./vendor/bin/php-cs-fixer fix
./vendor/bin/php-cs-fixer check

See usage, list of built-in rules, list of rule sets and configuration file documentation for more details.

If you need to apply code styles that are not built-in into the tool, you can create custom rules.

Editor Integration

Native support exists for:

Community plugins exist for:

Community

The PHP CS Fixer is maintained on GitHub at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer. Contributions, bug reports and ideas about new features are welcome there.

You can reach us in the GitHub Discussions regarding the project, configuration, possible improvements, ideas and questions.

Contribute

The tool comes with quite a few built-in fixers, but everyone is more than welcome to contribute more of them.