If you need any help, don't hesitate to ask the community using GitHub Discussions or Gitter.
A fixer is a class that tries to fix a single code style issue (a Fixer
class must implement FixerInterface
).
A ruleset is a collection of rules (fixers) that may be referenced in the config file similarly to a single fixer. When you work on existing fixer please keep in mind it can be a part of a ruleset(s) and changes may affect many users. When working on new fixer please consider if it should be added to some ruleset(s).
A config knows about the code style rules and the files and directories that must be scanned by the tool when run in the context of your project. It is useful for projects that follow a well-known directory structures, but the tool is not limited to any specific structure, and you can configure it in a very flexible way.
ℹ️ IMPORTANT: before contributing with really significant changes that require a lot of effort or are crucial from this tool's architecture perspective, please open RFC on GitHub Discussion. The development effort should start only after the proposal is discussed and the approach aligned.
gh
CLI tool.master
branch (if you already had project locally, then make sure to update this branch before going to next steps). It's good when branch's name reflects intent of the changes, but this is not strict requirement since pull request provides description of the change. However, with good branch naming it's easier to work on multiple changes simultaneously.composer update
(since project does not contain composer.lock
it's better to ensure latest versions of packages by running update
command instead of install
).yield
with proper case description as a key (e.g. yield 'Some specific scenario' => ['some', 'example', 'data'];
). Codebase may still contain test cases in different format, and it's totally acceptable to use yield
approach next to existing return
usages.composer docs
. This requires the highest version of PHP supported by PHP CS Fixer. If it is not installed on your system, you can run it in a Docker container instead: docker-compose run php-8.2 php dev-tools/doc.php
.composer qa
.composer cs:fix
.You can do some things to increase the chance that your pull request is accepted without communication ping-pong between you and the reviewers:
master
branch, that will eliminate risk of problems after the merge.PhpCsFixer\Console\Application::VERSION
, it's done during release.This project provides a Docker setup that allows working on it using any of the PHP versions supported by the tool.
To use it, you first need to install Docker (Docker Compose is a built-in plugin of the main tool).
Next, copy docker-compose.override.yaml.dist
to docker-compose.override.yaml
and edit it to your needs. The relevant parameters that might require some tweaking have comments to help you.
You can then build the images:
docker-compose build --parallel
Now you can run commands needed to work on the project. For example, say you want to run PHPUnit tests on PHP 7.4:
docker-compose run php-7.4 vendor/bin/phpunit
Sometimes it can be more convenient to have a shell inside the container:
docker-compose run php-7.4 sh
/app vendor/bin/phpunit
The images come with an xdebug
script that allows running any PHP command with Xdebug enabled to help debug problems.
docker-compose run php-7.4 xdebug vendor/bin/phpunit
If you're using PhpStorm, you need to create a server with a name that matches the PHP_IDE_CONFIG
environment variable defined in the Docker Compose configuration files, which is php-cs-fixer
by default.
All images use port 9003 for debug connections.
There is a cookbook with basic instructions on how to build a new fixer. Consider reading it before opening a PR.