Skip to content

jreklund/PHP-CS-Fixer-Compat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Coding Standards Fixer Compat(ibility)

Use older versions of rules in PHP-CS-Fixer v3.34.1 (or newer?).

Installation

composer require --dev jreklund/php-cs-fixer-compat

Requirements

You must install either friendsofphp/php-cs-fixer or php-cs-fixer/shim (recommended) for this package to work.

composer require --dev friendsofphp/php-cs-fixer
composer require --dev php-cs-fixer/shim

Usage

$config = new PhpCsFixer\Config();

return $config
    ->registerCustomFixers([
        new PhpCsFixerCompat\Fixer\Basic\BracesFixer380(),
    ])
    ->setRules([
        '@PER' => true,
        'control_structure_braces' => false,
        'control_structure_continuation_position' => false,
        'braces_position' => false,
        'no_multiple_statements_per_line' => false,
        'statement_indentation' => false,
        'PhpCsFixerCompat/braces_380' => true,
    ])
    ->setFinder(
        PhpCsFixer\Finder::create()
        ->exclude('vendor')
        ->in(__DIR__)
    );

PHP-CS-Fixer/shim

⚠️ Depending on how PHP-CS-Fixer/shim gets executed, you may need to manually load bootstrap.php by requiring it in your .php-cs-fixer.php.

$compatPath = implode(DIRECTORY_SEPARATOR, [
    __DIR__,
    'vendor',
    'jreklund',
    'php-cs-fixer-compat',
]);

$bootstrap = $compatPath . DIRECTORY_SEPARATOR . 'bootstrap.php';

if (file_exists($bootstrap)) {
    require $bootstrap;
}

// config starts here

Rules

All compat rules follow the same naming scheme: PhpCsFixerCompat/{rule}_{version}.

All fixers can be found under the namespace: PhpCsFixerCompat\Fixer\{custom-fixer}.


Rule Version Compat Rule Custom Fixer
braces 3.8.0 braces_380 Basic\BracesFixer380

About

Compatibility layer for older rules that have changed

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages