juliangut/php-cs-fixer-custom-fixers

Custom fixers for PHP CS Fixer

1.0 2022-09-28 22:28 UTC

This package is auto-updated.

Last update: 2024-04-05 14:42:16 UTC


README

PHP version Latest Version License

Total Downloads Monthly Downloads

php-cs-fixer-custom-fixers

Custom fixers for PHP-CS-Fixer

Installation

Composer

composer require --dev juliangut/php-cs-fixer-custom-fixers

Usage

Register custom fixers on PHP-CS-Fixer configuration

 <?php

 use Jgut\PhpCsFixerCustomFixers\Fixers;
 use Jgut\PhpCsFixerCustomFixers\Fixer\Comment\LeadingUppercaseCommentFixer;
 use Jgut\PhpCsFixerCustomFixers\Fixer\Comment\PhpdocLeadingUppercaseSummaryFixer;
 use Jgut\PhpCsFixerCustomFixers\Fixer\LanguageConstruct\FloatLeadingZeroFixer;
 use PhpCsFixer\Config;

 return (new Config())
+    ->registerCustomFixers(new Fixers())
     ->setRules([
         '@PSR2' => true,
         // ...,
+        LeadingUppercaseCommentFixer::name() => true,
+        PhpdocLeadingUppercaseSummaryFixer::name() => true,
+        FloatLeadingZeroFixer::name() => true,
     ]);

Fixers

LanguageConstruct

FloatLeadingZeroFixer

Float values should or should not have a leading zero

 <?php
 
 class Foo
 {
-    private float $value = .5;
+    private float $value = 0.5;
 }
Configuration

leading_zero (string), should add or should remove a leading zero

Comment

LeadingUppercaseCommentFixer

Comments should start with a leading uppercase letter

 <?php

-// this is a comment
+// This is a comment

 /*
- * this is a block comment
+ * This is a block comment
  */

PhpdocLeadingUppercaseSummaryFixer

Docblock summary should start with a leading uppercase letter

 <?php

 class Foo
 {
     /**
-     * this is a docblock summary.
+     * This is a docblock summary.
      */
     public function bar()
     {
     }
 }

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.