suin/symplify-cs-fixer

Make Symplify Coding Standard's fixers work with PHP-CS-Fixer

v2.2.0 2019-07-22 09:32 UTC

This package is auto-updated.

Last update: 2024-11-29 05:44:47 UTC


README

Make Symplify Coding Standard's fixers work with PHP-CS-Fixer.

Since Symplify Coding Standard's fixers designed for EasyCodingStandard, its don't work in PHP-CS-Fixer config (.php_cs or .php_cs.dist). This library provide an adaptor layer that bridge the gap between PHP-CS-Fixer and Symplify Coding Standard.

Installation

composer require --dev suin/symplify-cs-fixer

Usage

At first, create a PHP-CS-Fixer ruleset XML (.php_cs.dist or .php_cs) file in the root of your project.

<?php

declare(strict_types=1);

return PhpCsFixer\Config::create()
    ->registerCustomFixers(new SymplifyCsFixer\SymplifyCsFixers())
    ->setRules(
        [
            SymplifyCsFixer\ArrayPropertyDefaultValueFixer::NAME => true,
            SymplifyCsFixer\BlankLineAfterStrictTypesFixer::NAME => true,
            SymplifyCsFixer\BlockPropertyCommentFixer::NAME => true,
            SymplifyCsFixer\ClassStringToClassConstantFixer::NAME => true,
            SymplifyCsFixer\FinalInterfaceFixer::NAME => true,
            SymplifyCsFixer\LineLengthFixer::NAME => [
                'line_length' => 80,
                'break_long_lines' => true,
                'inline_short_lines' => true,
            ],
            SymplifyCsFixer\MethodOrderByTypeFixer::NAME => true,
            SymplifyCsFixer\ParamReturnAndVarTagMalformsFixer::NAME => true,
            SymplifyCsFixer\PrivateMethodOrderByUseFixer::NAME => true,
            SymplifyCsFixer\PropertyNameMatchingTypeFixer::NAME => true,
            SymplifyCsFixer\PropertyOrderByComplexityFixer::NAME => true,
            SymplifyCsFixer\RemoveEmptyDocBlockFixer::NAME => true,
            SymplifyCsFixer\RemoveEndOfFunctionCommentFixer::NAME => true,
            SymplifyCsFixer\RemoveSuperfluousDocBlockWhitespaceFixer::NAME => true,
            SymplifyCsFixer\RemoveUselessDocBlockFixer::NAME => true,
            SymplifyCsFixer\RequireFollowedByAbsolutePathFixer::NAME => true,
            SymplifyCsFixer\StandaloneLineInMultilineArrayFixer::NAME => true,  
        ]
    )
    // ...
    ;

Then run it with the command:

vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff --verbose

Changelog

Please see CHANGELOG for more details.

Contributing

Send issue or pull-request to main repository.