{"id":19962986,"url":"https://github.com/taptima/php-cs-fixer","last_synced_at":"2025-05-03T22:31:35.328Z","repository":{"id":46711239,"uuid":"251179598","full_name":"taptima/php-cs-fixer","owner":"taptima","description":"New fixers for PHP-CS-Fixer","archived":false,"fork":false,"pushed_at":"2022-04-06T08:39:04.000Z","size":60,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-04T08:08:30.670Z","etag":null,"topics":["codestyle","doctrine-migrations","php","php-cs-fixer","php-cs-fixer-custom-fixers","php7","phpcsfixer"],"latest_commit_sha":null,"homepage":"https://taptima.ru/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taptima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T02:17:20.000Z","updated_at":"2022-04-04T08:40:55.000Z","dependencies_parsed_at":"2022-09-14T21:40:45.993Z","dependency_job_id":null,"html_url":"https://github.com/taptima/php-cs-fixer","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taptima%2Fphp-cs-fixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taptima%2Fphp-cs-fixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taptima%2Fphp-cs-fixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taptima%2Fphp-cs-fixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taptima","download_url":"https://codeload.github.com/taptima/php-cs-fixer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224374661,"owners_count":17300691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codestyle","doctrine-migrations","php","php-cs-fixer","php-cs-fixer-custom-fixers","php7","phpcsfixer"],"created_at":"2024-11-13T02:14:07.909Z","updated_at":"2024-11-13T02:14:08.516Z","avatar_url":"https://github.com/taptima.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-CS-Fixer\n\n[![Latest Stable Version](https://poser.pugx.org/taptima/php-cs-fixer/v/stable)](https://packagist.org/packages/taptima/php-cs-fixer)\n[![License](https://poser.pugx.org/taptima/php-cs-fixer/license)](https://packagist.org/packages/taptima/php-cs-fixer)\n\nThis repository appeared thanks to the [PedroTroller/PhpCSFixer-Custom-Fixers](https://github.com/PedroTroller/PhpCSFixer-Custom-Fixers) and the code from this repository is used here.\n\n# Installation\n\n```bash\ncomposer require --dev taptima/php-cs-fixer dev-master\n```\n\n### Configuration\n\n```php\n// .php-cs-fixer.php\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n    // ...\n;\n\nreturn $config;\n```\n\nYou can also include the ruleset used by the Taptima company. It includes the @Symfony, @PSR and other rules to get the best codestyle result.\n@Taptima rule set can be viewed [here](https://github.com/taptima/php-cs-fixer/blob/master/src/Taptima/CS/RuleSetFactory.php#L15).\n```php\n// .php-cs-fixer.php\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    -\u003esetRules(\n        Taptima\\CS\\RuleSetFactory::create([\n            '@Taptima' =\u003e true,\n            // other rules\n        ])\n        -\u003etaptima()\n        -\u003egetRules()\n    )\n    -\u003eregisterCustomFixers(\n        new Taptima\\CS\\Fixers()\n    )\n\n    return $config;\n```\n\n# Fixers\n\n\n## Taptima/doctrine_migrations\n\nRemove useless getDescription(), up(), down() and comments from Doctrine\\Migrations\\AbstractMigration if needed.\n\n### Configuration\n\n```php\n// .php-cs-fixer.php\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules([\n        // ...\n        'Taptima/doctrine_migrations' =\u003e true,\n        // ...\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n**OR** using my [rule list builder](doc/rule-set-factory.md).\n\n```php\n// .php-cs-fixer.php.dist\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules(Taptima\\CS\\RuleSetFactory::create()\n        -\u003eenable('Taptima/doctrine_migrations')\n        -\u003egetRules()\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n### Fixes\n\n```diff\n--- Original                                                                     // 80 chars\n+++ New                                                                          //\n@@ @@                                                                            //\n use Doctrine\\DBAL\\Schema\\Schema;                                                //\n use Doctrine\\Migrations\\AbstractMigration;                                      //\n                                                                                 //\n-/**                                                                             //\n- * Auto-generated Migration: Please modify to your needs!                       //\n- */                                                                             //\n final class Version20190323095102 extends AbstractMigration                     //\n {                                                                               //\n-    public function getDescription()                                            //\n-    {                                                                           //\n-        return '';                                                              //\n-    }                                                                           //\n                                                                                 //\n     public function up(Schema $schema)                                          //\n     {                                                                           //\n-        // this up() migration is auto-generated, please modify it to your needs//\n         $this-\u003eabortIf('mysql' !== $this-\u003econnection-\u003egetDatabasePlatform()-\u003egetName(), 'Migration can only be executed safely on \\'mysql\\'.');\n                                                                                 //\n         $this-\u003eaddSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \\'(DC2Type:guid)\\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');\n@@ @@                                                                            //\n                                                                                 //\n     public function down(Schema $schema)                                        //\n     {                                                                           //\n-        // this down() migration is auto-generated, please modify it to your needs\n         $this-\u003eabortIf('mysql' !== $this-\u003econnection-\u003egetDatabasePlatform()-\u003egetName(), 'Migration can only be executed safely on \\'mysql\\'.');\n                                                                                 //\n         $this-\u003eaddSql('DROP TABLE admin');                                      //\n     }                                                                           //\n }                                                                               //\n                                                                                 //\n```\n### Configuration\n\n```php\n// .php-cs-fixer.php\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules([\n        // ...\n        'Taptima/doctrine_migrations' =\u003e [ 'instanceof' =\u003e [ 'Doctrine\\Migrations\\AbstractMigration' ] ],\n        // ...\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n**OR** using my [rule list builder](doc/rule-set-factory.md).\n\n```php\n// .php-cs-fixer.php.dist\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules(Taptima\\CS\\RuleSetFactory::create()\n        -\u003eenable('Taptima/doctrine_migrations', [ 'instanceof' =\u003e [ 'Doctrine\\Migrations\\AbstractMigration' ] ])\n        -\u003egetRules()\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n### Fixes\n\n```diff\n--- Original                                                                     // 80 chars\n+++ New                                                                          //\n@@ @@                                                                            //\n use Doctrine\\DBAL\\Schema\\Schema;                                                //\n use Doctrine\\Migrations\\AbstractMigration;                                      //\n                                                                                 //\n-/**                                                                             //\n- * Auto-generated Migration: Please modify to your needs!                       //\n- */                                                                             //\n final class Version20190323095102 extends AbstractMigration                     //\n {                                                                               //\n-    public function getDescription()                                            //\n-    {                                                                           //\n-        return '';                                                              //\n-    }                                                                           //\n                                                                                 //\n     public function up(Schema $schema)                                          //\n     {                                                                           //\n-        // this up() migration is auto-generated, please modify it to your needs//\n         $this-\u003eabortIf('mysql' !== $this-\u003econnection-\u003egetDatabasePlatform()-\u003egetName(), 'Migration can only be executed safely on \\'mysql\\'.');\n                                                                                 //\n         $this-\u003eaddSql('CREATE TABLE admin (identifier CHAR(36) NOT NULL COMMENT \\'(DC2Type:guid)\\', PRIMARY KEY(identifier)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');\n@@ @@                                                                            //\n                                                                                 //\n     public function down(Schema $schema)                                        //\n     {                                                                           //\n-        // this down() migration is auto-generated, please modify it to your needs\n         $this-\u003eabortIf('mysql' !== $this-\u003econnection-\u003egetDatabasePlatform()-\u003egetName(), 'Migration can only be executed safely on \\'mysql\\'.');\n                                                                                 //\n         $this-\u003eaddSql('DROP TABLE admin');                                      //\n     }                                                                           //\n }                                                                               //\n                                                                                 //\n```\n\n## Taptima/ordered_setters_and_getters\n\nClass/interface/trait setters and getters MUST BE ordered (order is setter, isser, hasser, adder, remover, getter).\n\n### Configuration\n\n```php\n// .php-cs-fixer.php\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules([\n        // ...\n        'Taptima/ordered_setters_and_getters' =\u003e true,\n        // ...\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n**OR** using my [rule list builder](doc/rule-set-factory.md).\n\n```php\n// .php-cs-fixer.php.dist\n\u003c?php\n\n$config = PhpCsFixer\\Config::create()\n    // ...\n    -\u003esetRules(Taptima\\CS\\RuleSetFactory::create()\n        -\u003eenable('Taptima/ordered_setters_and_getters')\n        -\u003egetRules()\n    ])\n    // ...\n    -\u003eregisterCustomFixers(new Taptima\\CS\\Fixers())\n;\n\nreturn $config;\n```\n\n### Fixes\n\n```diff\n--- Original                                                                     // 80 chars\n+++ New                                                                          //\n@@ @@                                                                            //\n         $this-\u003efirstName = $firstName;                                          //\n     }                                                                           //\n                                                                                 //\n-    public function setName($name)                                              //\n+    public function getFirstName()                                              //\n     {                                                                           //\n-        $this-\u003ename = $name;                                                    //\n+        return $this-\u003efirstName;                                                //\n     }                                                                           //\n                                                                                 //\n-    public function isEnabled()                                                 //\n+    public function setName($name)                                              //\n     {                                                                           //\n-        return $this-\u003eenabled;                                                  //\n+        $this-\u003ename = $name;                                                    //\n     }                                                                           //\n                                                                                 //\n     public function getName()                                                   //\n@@ @@                                                                            //\n         return $this-\u003ename;                                                     //\n     }                                                                           //\n                                                                                 //\n-    public function getIdentifier()                                             //\n+    public function isEnabled()                                                 //\n     {                                                                           //\n-        return $this-\u003eidentifier;                                               //\n+        return $this-\u003eenabled;                                                  //\n     }                                                                           //\n                                                                                 //\n-    public function getFirstName()                                              //\n+    public function getIdentifier()                                             //\n     {                                                                           //\n-        return $this-\u003efirstName;                                                //\n+        return $this-\u003eidentifier;                                               //\n     }                                                                           //\n                                                                                 //\n     public function enable()                                                    //\n@@ @@                                                                            //\n     }                                                                           //\n                                                                                 //\n     /**                                                                         //\n-     * @return Item                                                             //\n-     */                                                                         //\n-    public function getItems()                                                  //\n-    {                                                                           //\n-        return $this-\u003eitems;                                                    //\n-    }                                                                           //\n-                                                                                //\n-    /**                                                                         //\n      * @param Item $item                                                        //\n      * @return User                                                             //\n      */                                                                         //\n@@ @@                                                                            //\n         $this-\u003eitems-\u003eremoveElement($item);                                     //\n                                                                                 //\n         return $this;                                                           //\n+    }                                                                           //\n+                                                                                //\n+    /**                                                                         //\n+     * @return Item                                                             //\n+     */                                                                         //\n+    public function getItems()                                                  //\n+    {                                                                           //\n+        return $this-\u003eitems;                                                    //\n     }                                                                           //\n }                                                                               //\n                                                                                 //\n```\n\n# Contributions\n\nBefore to create a pull request to submit your contributon, you must:\n - run tests and be sure nothing is broken\n - rebuilt the documentation\n\n## How to run tests\n\n```bash\ncomposer tests\n```\n\n## How to rebuild the documentation\n\n```bash\ntools/doc \u003e README.md\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaptima%2Fphp-cs-fixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaptima%2Fphp-cs-fixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaptima%2Fphp-cs-fixer/lists"}