Search by

ebrana / php-cs-fixer-config

Kamhal24

The eBRANA coding standard for PHP-CS-Fixer: one rule set and one fixer version for all eBRANA PHP projects.

Package info

github.com/ebrana/php-cs-fixer-config

pkg:composer/ebrana/php-cs-fixer-config

Statistics

Installs: 59

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-12-01 12:15 UTC

This package is auto-updated.

Last update: 2026-12-01 12:21:59 UTC


README

The eBRANA coding standard for PHP-CS-Fixer: one rule set and one fixer version for all eBRANA PHP projects.

The rules are the Symfony standard (@Symfony, @Symfony:risky) with a few additions; they are listed with their reasons in src/Config.php.

Installation

composer require --dev ebrana/php-cs-fixer-config

The package requires friendsofphp/php-cs-fixer itself. Do not require the fixer in the project as well: rules and fixer version are released together, so the same code is formatted the same way in every project.

Usage

.php-cs-fixer.dist.php of the project declares only what to check:

<?php

declare(strict_types=1);

use Ebrana\CsFixerConfig\Config;
use PhpCsFixer\Finder;

$finder = (new Finder())
    ->in([__DIR__.'/src', __DIR__.'/tests']);

return Config::create($finder)->setCacheFile(__DIR__.'/.php-cs-fixer.cache');
vendor/bin/php-cs-fixer fix --dry-run --diff   # check
vendor/bin/php-cs-fixer fix                    # fix

Config::create() returns a regular PhpCsFixer\Config. A project that needs an extra rule adds it on top of the shared set:

return Config::create($finder)
    ->setRules(Config::rules() + ['yoda_style' => false]);

Keep such additions rare: a rule that makes sense in one project usually belongs here.

Changing the standard

  1. Change src/Config.php in a pull request and add a line to CHANGELOG.md.
  2. Tag a release. A changed or added rule, or a new fixer minor version, reformats code, so it is a new minor version; a fix that changes no output is a patch.
  3. Each project takes the release in its own dependency-update commit and commits the reformatted code together with it.