2017 © Pedro Peláez
 

library php-cs-custom-fixer

PHP-CS-FIXER : my custom fixers

image

pedrotroller/php-cs-custom-fixer

PHP-CS-FIXER : my custom fixers

  • PHP
  • 15 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 46 Versions
  • 12 % Grown

The README.md

PHP-CS-FIXER : Custom fixers

CircleCI Latest Stable Version License Dependabot Status Scrutinizer Code Quality, (*1)

Installation

composer require pedrotroller/php-cs-custom-fixer --dev

Configuration

// .php_cs.dist
<?php

$config = PhpCsFixer\Config::create()
    // ...
    ->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers())
    // ...
;

return $config;

Fixers

PedroTroller/order_behat_steps

Step definition methods in Behat contexts MUST BE ordered by annotation and method name., (*2)

Available options

  • instanceof (optional): Parent class or interface of your behat context classes.
    • default: Behat\Behat\Context\Context

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/order_behat_steps' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*3)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/order_behat_steps')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @Then the response should be received                                    //
+     * @BeforeScenario                                                          //
      */                                                                         //
-    public function theResponseShouldBeReceived()                               //
+    public function reset()                                                     //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @When a demo scenario sends a request to :path                           //
+     * @Given I am on the homepage                                              //
      */                                                                         //
-    public function aDemoScenarioSendsARequestTo($path)                         //
+    public function iAmOnTheHomepage()                                          //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @Given I am on the homepage                                              //
+     * @When a demo scenario sends a request to :path                           //
      */                                                                         //
-    public function iAmOnTheHomepage()                                          //
+    public function aDemoScenarioSendsARequestTo($path)                         //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @BeforeScenario                                                          //
+     * @Then the response should be received                                    //
      */                                                                         //
-    public function reset()                                                     //
+    public function theResponseShouldBeReceived()                               //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
 }                                                                               //
                                                                                 //

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/order_behat_steps' => [ 'instanceof' => [ 'Behat\Behat\Context\Context' ] ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*4)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/order_behat_steps', [ 'instanceof' => [ 'Behat\Behat\Context\Context' ] ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @Then the response should be received                                    //
+     * @BeforeScenario                                                          //
      */                                                                         //
-    public function theResponseShouldBeReceived()                               //
+    public function reset()                                                     //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @When a demo scenario sends a request to :path                           //
+     * @Given I am on the homepage                                              //
      */                                                                         //
-    public function aDemoScenarioSendsARequestTo($path)                         //
+    public function iAmOnTheHomepage()                                          //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @Given I am on the homepage                                              //
+     * @When a demo scenario sends a request to :path                           //
      */                                                                         //
-    public function iAmOnTheHomepage()                                          //
+    public function aDemoScenarioSendsARequestTo($path)                         //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
                                                                                 //
     /**                                                                         //
-     * @BeforeScenario                                                          //
+     * @Then the response should be received                                    //
      */                                                                         //
-    public function reset()                                                     //
+    public function theResponseShouldBeReceived()                               //
     {                                                                           //
         // ...                                                                  //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/ordered_with_getter_and_setter_first

Class/interface/trait methods MUST BE ordered (accessors at the beginning of the class, ordered following properties order)., (*5)

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/ordered_with_getter_and_setter_first' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*6)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/ordered_with_getter_and_setter_first')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
         }                                                                       //
     }                                                                           //
                                                                                 //
-    public function setFirstName($firstName)                                    //
+    public function getIdentifier()                                             //
     {                                                                           //
-        $this->firstName = $firstName;                                          //
+        return $this->identifier;                                               //
     }                                                                           //
                                                                                 //
-    public function setName($name)                                              //
+    public function getName()                                                   //
     {                                                                           //
-        $this->name = $name;                                                    //
+        return $this->name;                                                     //
     }                                                                           //
                                                                                 //
-    public function isEnabled()                                                 //
+    public function setName($name)                                              //
     {                                                                           //
-        return $this->enabled;                                                  //
+        $this->name = $name;                                                    //
     }                                                                           //
                                                                                 //
-    public function getName()                                                   //
+    public function getFirstName()                                              //
     {                                                                           //
-        return $this->name;                                                     //
+        return $this->firstName;                                                //
     }                                                                           //
                                                                                 //
-    public function getIdentifier()                                             //
+    public function setFirstName($firstName)                                    //
     {                                                                           //
-        return $this->identifier;                                               //
+        $this->firstName = $firstName;                                          //
     }                                                                           //
                                                                                 //
-    public function getFirstName()                                              //
+    public function isEnabled()                                                 //
     {                                                                           //
-        return $this->firstName;                                                //
+        return $this->enabled;                                                  //
     }                                                                           //
                                                                                 //
     public function enable()                                                    //
                                                                                 //

PedroTroller/exceptions_punctuation

Exception messages MUST ends by ".", "…", "?" or "!".

Risky: will change the exception message., (*7)

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/exceptions_punctuation' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*8)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/exceptions_punctuation')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 class MyClass {                                                                 //
     public function fun1()                                                      //
     {                                                                           //
-        throw new \Exception('This is the message');                            //
+        throw new \Exception('This is the message.');                           //
     }                                                                           //
                                                                                 //
     public function fun2($data)                                                 //
     {                                                                           //
-        throw new LogicException(sprintf('This is the %s', 'message'));         //
+        throw new LogicException(sprintf('This is the %s.', 'message'));        //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/forbidden_functions

Prohibited functions MUST BE commented on as prohibited, (*9)

Available options

  • comment (optional): The prohibition message to put in the comment, (*10)

    • default: @TODO remove this line
  • functions (optional): The function names to be marked how prohibited, (*11)

    • default: var_dump, dump, die

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/forbidden_functions' => [ 'comment' => 'YOLO' ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*12)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/forbidden_functions', [ 'comment' => 'YOLO' ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 class MyClass {                                                                 //
     public function fun()                                                       //
     {                                                                           //
-        var_dump('this is a var_dump');                                         //
+        var_dump('this is a var_dump'); // YOLO                                 //
                                                                                 //
         $this->dump($this);                                                     //
                                                                                 //
                                                                                 //

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/forbidden_functions' => [ 'comment' => 'NEIN NEIN NEIN !!!', 'functions' => [ 'var_dump', 'var_export' ] ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*13)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/forbidden_functions', [ 'comment' => 'NEIN NEIN NEIN !!!', 'functions' => [ 'var_dump', 'var_export' ] ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 class MyClass {                                                                 //
     public function fun()                                                       //
     {                                                                           //
-        var_dump('this is a var_dump');                                         //
+        var_dump('this is a var_dump'); // NEIN NEIN NEIN !!!                   //
                                                                                 //
         $this->dump($this);                                                     //
                                                                                 //
-        return var_export($this);                                               //
+        return var_export($this); // NEIN NEIN NEIN !!!                         //
     }                                                                           //
                                                                                 //
     public function dump($data)                                                 //
                                                                                 //

PedroTroller/line_break_between_method_arguments

If the declaration of a method is too long, the arguments of this method MUST BE separated (one argument per line), (*14)

Available options

  • automatic-argument-merge (optional): If both conditions are met (the line is not too long and there are not too many arguments), then the arguments are put back inline, (*15)

    • default: true
  • inline-attributes (optional): In the case of a split, the declaration of the attributes of the arguments of the method will be on the same line as the arguments themselves, (*16)

    • default: false
  • max-args (optional): The maximum number of arguments allowed with splitting the arguments into several lines (use false to disable this feature), (*17)

    • default: 3
  • max-length (optional): The maximum number of characters allowed with splitting the arguments into several lines, (*18)

    • default: 120

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/line_break_between_method_arguments' => [ 'max-args' => 4, 'max-length' => 120, 'automatic-argument-merge' => true, 'inline-attributes' => true ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*19)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/line_break_between_method_arguments', [ 'max-args' => 4, 'max-length' => 120, 'automatic-argument-merge' => true, 'inline-attributes' => true ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function fun2($arg1, array $arg2 = [], \ArrayAccess $arg3 = null, bool $bool = true, \Iterator $thisLastArgument = null)
-    {                                                                           //
+    public function fun2(                                                       //
+        $arg1,                                                                  //
+        array $arg2 = [],                                                       //
+        \ArrayAccess $arg3 = null,                                              //
+        bool $bool = true,                                                      //
+        \Iterator $thisLastArgument = null                                      //
+    ) {                                                                         //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function fun3(                                                       //
-        $arg1,                                                                  //
-        array $arg2 = []                                                        //
-    ) {                                                                         //
+    public function fun3($arg1, array $arg2 = [])                               //
+    {                                                                           //
         return;                                                                 //
     }                                                                           //
 }                                                                               //
                                                                                 //

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/line_break_between_method_arguments' => [ 'max-args' => false, 'max-length' => 120, 'automatic-argument-merge' => true, 'inline-attributes' => true ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*20)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/line_break_between_method_arguments', [ 'max-args' => false, 'max-length' => 120, 'automatic-argument-merge' => true, 'inline-attributes' => true ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function fun2($arg1, array $arg2 = [], \ArrayAccess $arg3 = null, bool $bool = true, \Iterator $thisLastArgument = null)
-    {                                                                           //
+    public function fun2(                                                       //
+        $arg1,                                                                  //
+        array $arg2 = [],                                                       //
+        \ArrayAccess $arg3 = null,                                              //
+        bool $bool = true,                                                      //
+        \Iterator $thisLastArgument = null                                      //
+    ) {                                                                         //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function fun3(                                                       //
-        $arg1,                                                                  //
-        array $arg2 = []                                                        //
-    ) {                                                                         //
+    public function fun3($arg1, array $arg2 = [])                               //
+    {                                                                           //
         return;                                                                 //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/line_break_between_statements

Each statement (in, for, foreach, ...) MUST BE separated by an empty line, (*21)

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/line_break_between_statements' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*22)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/line_break_between_statements')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
         do {                                                                    //
             // ...                                                              //
         } while (true);                                                         //
+                                                                                //
         foreach (['foo', 'bar'] as $str) {                                      //
             // ...                                                              //
         }                                                                       //
+                                                                                //
         if (true === false) {                                                   //
             // ...                                                              //
         }                                                                       //
-                                                                                //
                                                                                 //
         while (true) {                                                          //
             // ...                                                              //
                                                                                 //

PedroTroller/comment_line_to_phpdoc_block

Classy elements (method, property, ...) comments MUST BE a PhpDoc block, (*23)

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/comment_line_to_phpdoc_block' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*24)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/comment_line_to_phpdoc_block')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
      */                                                                         //
     private $name;                                                              //
                                                                                 //
-    // @var string | null                                                       //
+    /**                                                                         //
+     * @var string | null                                                       //
+     */                                                                         //
     private $value;                                                             //
                                                                                 //
     /**                                                                         //
@@ @@                                                                            //
         $this->name = $name;                                                    //
     }                                                                           //
                                                                                 //
-    // Get the name                                                             //
-    //                                                                          //
-    // @return string                                                           //
+    /**                                                                         //
+     * Get the name                                                             //
+     *                                                                          //
+     * @return string                                                           //
+     */                                                                         //
     public function getName()                                                   //
     {                                                                           //
         return $this->name;                                                     //
     }                                                                           //
                                                                                 //
-    // Get the value                                                            //
-    // @return null | string                                                    //
+    /**                                                                         //
+     * Get the value                                                            //
+     * @return null | string                                                    //
+     */                                                                         //
     public function getValue()                                                  //
     {                                                                           //
         return $this->value;                                                    //
     }                                                                           //
                                                                                 //
-    // Set the value                                                            //
-                                                                                //
-    // @param string $value                                                     //
+    /**                                                                         //
+     * Set the value                                                            //
+     * @param string $value                                                     //
+     */                                                                         //
     public function setValue($value)                                            //
     {                                                                           //
         $this->value = $value;                                                  //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/useless_code_after_return

All return that are not accessible (i.e. following another return) MUST BE deleted, (*25)

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/useless_code_after_return' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*26)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/useless_code_after_return')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
      */                                                                         //
     public function fun1(Model\User $user, Model\Address $address = null) {     //
         return;                                                                 //
-                                                                                //
-        $user->setName('foo');                                                  //
-                                                                                //
-        return $this;                                                           //
     }                                                                           //
                                                                                 //
     /**                                                                         //
@@ @@                                                                            //
         switch ($this->status) {                                                //
             case 1:                                                             //
                 return $this->name;                                             //
-                break;                                                          //
             default:                                                            //
                 return $this;                                                   //
-                return $this;                                                   //
         }                                                                       //
     }                                                                           //
                                                                                 //
@@ @@                                                                            //
      */                                                                         //
     public function buildCallable()                                             //
     {                                                                           //
-        return function () { return true; return false; };                      //
+        return function () { return true; };                                    //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/doctrine_migrations

Unnecessary empty methods (getDescription(), up(), down()) and comments MUST BE removed from Doctrine migrations, (*27)

Available options

  • instanceof (optional): The parent class of which Doctrine migrations extend
    • default: Doctrine\Migrations\AbstractMigration

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/doctrine_migrations' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*28)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/doctrine_migrations')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 use Doctrine\DBAL\Schema\Schema;                                                //
 use Doctrine\Migrations\AbstractMigration;                                      //
                                                                                 //
-/**                                                                             //
- * Auto-generated Migration: Please modify to your needs!                       //
- */                                                                             //
 final class Version20190323095102 extends AbstractMigration                     //
 {                                                                               //
-    public function getDescription()                                            //
-    {                                                                           //
-        return '';                                                              //
-    }                                                                           //
                                                                                 //
     public function up(Schema $schema)                                          //
     {                                                                           //
-        // this up() migration is auto-generated, please modify it to your needs//
         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
                                                                                 //
         $this->addSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
@@ @@                                                                            //
                                                                                 //
     public function down(Schema $schema)                                        //
     {                                                                           //
-        // this down() migration is auto-generated, please modify it to your needs
         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
                                                                                 //
         $this->addSql('DROP TABLE admin');                                      //
     }                                                                           //
 }                                                                               //
                                                                                 //

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/doctrine_migrations' => [ 'instanceof' => [ 'Doctrine\Migrations\AbstractMigration' ] ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*29)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/doctrine_migrations', [ 'instanceof' => [ 'Doctrine\Migrations\AbstractMigration' ] ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 use Doctrine\DBAL\Schema\Schema;                                                //
 use Doctrine\Migrations\AbstractMigration;                                      //
                                                                                 //
-/**                                                                             //
- * Auto-generated Migration: Please modify to your needs!                       //
- */                                                                             //
 final class Version20190323095102 extends AbstractMigration                     //
 {                                                                               //
-    public function getDescription()                                            //
-    {                                                                           //
-        return '';                                                              //
-    }                                                                           //
                                                                                 //
     public function up(Schema $schema)                                          //
     {                                                                           //
-        // this up() migration is auto-generated, please modify it to your needs//
         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
                                                                                 //
         $this->addSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
@@ @@                                                                            //
                                                                                 //
     public function down(Schema $schema)                                        //
     {                                                                           //
-        // this down() migration is auto-generated, please modify it to your needs
         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
                                                                                 //
         $this->addSql('DROP TABLE admin');                                      //
     }                                                                           //
 }                                                                               //
                                                                                 //

PedroTroller/phpspec

Phpspec scenario functions MUST NOT have a return type declaration., (*30)

Phpspec scenario functions MUST NOT have a scope., (*31)

The methods of the phpspec specification classes MUST BE sorted (let, letGo, its_*, it_*, getMatchers and the rest of the methods), (*32)

Lambda functions MUST NOT have a static scope., (*33)

Available options

  • instanceof (optional): Parent classes of your spec classes.
    • default: PhpSpec\ObjectBehavior

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/phpspec' => true,
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*34)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/phpspec')
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 class TheSpec extends ObjectBehavior                                            //
 {                                                                               //
                                                                                 //
-    function letGo($file) {                                                     //
+    function let($file) {                                                       //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    private function thePrivateMethod() {                                       //
+    function letGo($file) {                                                     //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function itIsNotASpec($file) {                                       //
+    function it_is_a_spec($file) {                                              //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function it_is_a_spec($file) {                                       //
+    function its_other_function($file) {                                        //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function let($file) {                                                //
+    private function thePrivateMethod() {                                       //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function its_other_function($file) {                                 //
+    public function itIsNotASpec($file) {                                       //
         return;                                                                 //
     }                                                                           //
 }                                                                               //
                                                                                 //

Configuration examples

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    [
        // ...
        'PedroTroller/phpspec' => [ 'instanceof' => [ 'PhpSpec\ObjectBehavior' ] ],
        // ...
    ]
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

OR using my rule list builder., (*35)

// .php_cs.dist
<?php

$config = new PhpCsFixer\Config();
// ...
$config->setRules(
    PedroTroller\CS\Fixer\RuleSetFactory::create()
        ->enable('PedroTroller/phpspec', [ 'instanceof' => [ 'PhpSpec\ObjectBehavior' ] ])
        ->getRules()
);
$config->registerCustomFixers(new PedroTroller\CS\Fixer\Fixers());
// ...

return $config;

Fixes

--- Original                                                                     // 80 chars
+++ New                                                                          //
@@ @@                                                                            //
 class TheSpec extends ObjectBehavior                                            //
 {                                                                               //
                                                                                 //
-    function letGo($file) {                                                     //
+    function let($file) {                                                       //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    private function thePrivateMethod() {                                       //
+    function letGo($file) {                                                     //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function itIsNotASpec($file) {                                       //
+    function it_is_a_spec($file) {                                              //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function it_is_a_spec($file) {                                       //
+    function its_other_function($file) {                                        //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function let($file) {                                                //
+    private function thePrivateMethod() {                                       //
         return;                                                                 //
     }                                                                           //
                                                                                 //
-    public function its_other_function($file) {                                 //
+    public function itIsNotASpec($file) {                                       //
         return;                                                                 //
     }                                                                           //
 }                                                                               //
                                                                                 //

Contributions

Before to create a pull request to submit your contributon, you must: - run tests and be sure nothing is broken - rebuilt the documentation, (*36)

How to run tests

composer tests

How to rebuild the documentation

bin/doc > README.md

The Versions

30/07 2018

dev-PhpdocLinesToPhpdocBlockFixer

dev-PhpdocLinesToPhpdocBlockFixer

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/07 2018

dev-master

9999999-dev

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/07 2018

v2.12.1

2.12.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/07 2018

dev-fix/useless_comment-save-empty-line

dev-fix/useless_comment-save-empty-line

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/07 2018

dev-fix/useless_comment_with_interface

dev-fix/useless_comment_with_interface

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

26/07 2018

v3.0.x-dev

3.0.9999999.9999999-dev

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

26/07 2018

v2.12.0

2.12.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2018

v2.11.1

2.11.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

05/07 2018

v2.11.0

2.11.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

05/07 2018

v2.10.2

2.10.2.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

20/06 2018

dev-lineBreakBetweenMethodeArgument/make-reformat-optional

dev-lineBreakBetweenMethodeArgument/make-reformat-optional

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

08/06 2018

v2.10.1

2.10.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

15/05 2018

v2.10.0

2.10.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

15/05 2018

dev-feature/remoce-useless-code-after-return

dev-feature/remoce-useless-code-after-return

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

11/05 2018

v2.9.1

2.9.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

11/05 2018

v2.9.0

2.9.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/04 2018

v2.8.0

2.8.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

12/04 2018

v2.7.0

2.7.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

26/02 2018

v2.6.3

2.6.3.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2018

v2.6.2

2.6.2.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2018

v2.6.1

2.6.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

29/01 2018

v2.6.0

2.6.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

10/01 2018

v2.5.0

2.5.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

09/01 2018

v2.4.0

2.4.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

08/01 2018

v2.3.1

2.3.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

08/01 2018

v2.3.0

2.3.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

12/12 2017

v2.2.2

2.2.2.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2017

v2.2.1

2.2.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2017

v2.2.0

2.2.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

28/11 2017

v2.1.2

2.1.2.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

14/11 2017

v2.1.1

2.1.1.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

20/10 2017

v2.1

2.1.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

04/10 2017

v2.0

2.0.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

08/09 2017

v2.0.x-dev

2.0.9999999.9999999-dev

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

30/12 2016

v1.6.0

1.6.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

05/08 2016

v1.5.0

1.5.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2016

v1.4.0

1.4.0.0

PHP-CS-FIXER : my custom fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

18/05 2016

v1.3.3

1.3.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

07/04 2016

v1.3.2

1.3.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

06/04 2016

v1.3.1

1.3.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

25/03 2016

v1.3.0

1.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

21/03 2016

dev-feature/comments-fixers

dev-feature/comments-fixers

  Sources   Download

MIT

The Requires

 

The Development Requires

15/03 2016

v1.2.1

1.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

15/03 2016

v1.2.0

1.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

14/03 2016

v1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

15/01 2016

v1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires