Skip to content

This is a shared FriendsOfPHP/php-cs-fixer configuration used primarily in Sandwave projects. But feel free to use it in your projects if you would like.

License

Notifications You must be signed in to change notification settings

sandwave-io/php-cs-fixer-config

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Workflow Status Packagist PHP Version Support Packagist PHP Version Support Packagist Downloads

This is a shared FriendsOfPHP/php-cs-fixer configuration used primarily in Sandwave.io projects. But feel free to use it in your projects if you would like. Also, if you want to propose a change, feel free to create a PR 😁

This package can be used on PHP 7.4, 8.0 and 8.1.

Installation

composer require --dev sandwave-io/php-cs-fixer-config

PHP-CS-Fixer 2.0

If you are still using v2.x of PHP-CS-Fixer in your project, you should use version <1.2.x of this package.

composer require --dev sandwave-io/php-cs-fixer-config:1.2.*

Note that this version is no longer maintained, and you should upgrade to the latest version of PHP-CS-Fixer

Usage

Create a .php-cs-fixer.php configuration file in the root of your project.

<?php

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

return $config;

Also, make sure to ignore the .php_cs.cache file in your git repository.

Adding/overriding rules

It can be the case that you want to change something in the rules. No problem, you can override or add rules as follows:

<?php

$config = new SandwaveIo\PhpCsFixerConfig\Config([
    'declare_strict_types' => true,
]);
$config->getFinder()
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");

return $config;

Be aware when you do this that risky fixers are allowed by default!

Example without risky fixers

<?php

$ruleOverrides = [
    'no_php4_constructor' => false,
    'pow_to_exponentiation' => false,
    'no_unneeded_final_method' => false,
    'no_unreachable_default_argument_value' => false,
    'php_unit_strict' => false,
    'psr4' => false,
];

$config = new SandwaveIo\PhpCsFixerConfig\Config($ruleOverrides, false);

$config->getFinder()
    ->in(__DIR__ . '/src')
    ->in(__DIR__ . '/tests');

return $config;

License

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

Special thanks

Special thanks to Jesse Kramer for the initial project!

About

This is a shared FriendsOfPHP/php-cs-fixer configuration used primarily in Sandwave projects. But feel free to use it in your projects if you would like.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%