A shared php-cs-fixer config used in our packages.

2.1.2 2022-11-01 16:43 UTC

This package is auto-updated.

Last update: 2022-12-01 16:52:17 UTC


Latest Version Software License Build Status

This is a shared FriendsOfPHP/PHP-CS-Fixer configuration used in our packages.


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


Create a .php_cs.dist configuration file in the root of your project.


$config = new DistortedFusion\PhpCsFixerConfig\Config();
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");

return $config;

Adding or overloading rules

Adding an array of rules to the construct of the Config object allows you to add or overload rules:


$config = new DistortedFusion\PhpCsFixerConfig\Config([
    'psr0' => false,
    'psr4' => false,
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");

return $config;

Composer scripts

Adding composer scripts makes it easy to add aliases for testing and fixing code styling.

Please Note: The config contains risky rules by default, this requires the usage of --allow-risky=yes. If you don't want to run risky rules you can excluded them in the .php-cs.dist config.

    "scripts": {
        "phpcs-fix" : "php-cs-fixer fix --using-cache=no --allow-risky=yes --ansi",
        "phpcs": "php-cs-fixer fix -v --diff --dry-run --allow-risky=yes --ansi",
        "test": [
    "scripts-descriptions": {
        "phpcs": "Runs coding style test suite",
        "test": "Runs all tests"


To run the tests, run the following command from the project folder:

$ composer test


If you discover a security vulnerability within this package, please send an e-mail to Kevin Dierkx via kevin@distortedfusion.com. All security vulnerabilities will be promptly addressed.


Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.


The MIT License (MIT). Please see License File for more information.