{"id":16316477,"url":"https://github.com/erickskrauch/php-cs-fixer-custom-fixers","last_synced_at":"2025-08-21T22:31:09.603Z","repository":{"id":166531203,"uuid":"642012454","full_name":"erickskrauch/php-cs-fixer-custom-fixers","owner":"erickskrauch","description":"A set of custom fixers for PHP-CS-Fixer","archived":false,"fork":false,"pushed_at":"2024-06-21T20:22:41.000Z","size":132,"stargazers_count":20,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-19T06:08:47.719Z","etag":null,"topics":["php-cs-fixer","php-cs-fixer-custom-fixers"],"latest_commit_sha":null,"homepage":"","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/erickskrauch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-17T16:18:34.000Z","updated_at":"2024-10-23T08:43:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"a743009f-00c7-4dc3-b47c-8a3ddf4c3320","html_url":"https://github.com/erickskrauch/php-cs-fixer-custom-fixers","commit_stats":null,"previous_names":["erickskrauch/php-cs-fixer-custom-fixers"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erickskrauch%2Fphp-cs-fixer-custom-fixers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erickskrauch%2Fphp-cs-fixer-custom-fixers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erickskrauch%2Fphp-cs-fixer-custom-fixers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erickskrauch%2Fphp-cs-fixer-custom-fixers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erickskrauch","download_url":"https://codeload.github.com/erickskrauch/php-cs-fixer-custom-fixers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230537056,"owners_count":18241515,"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":["php-cs-fixer","php-cs-fixer-custom-fixers"],"created_at":"2024-10-10T22:04:43.089Z","updated_at":"2024-12-20T05:08:09.696Z","avatar_url":"https://github.com/erickskrauch.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-CS-Fixer custom fixers\n\nA set of custom fixers for [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer).\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-build-status]][link-build-status]\n\n## Installation\n\nRun:\n\n```sh\ncomposer require --dev erickskrauch/php-cs-fixer-custom-fixers\n```\n\nThen in your configuration file (`.php-cs-fixer.php`) register fixers and use them:\n\n```php\n\u003c?php\nreturn (new \\PhpCsFixer\\Config())\n    -\u003eregisterCustomFixers(new \\ErickSkrauch\\PhpCsFixer\\Fixers())\n    -\u003esetRules([\n        'ErickSkrauch/align_multiline_parameters' =\u003e true,\n        // See the rest of the fixers below\n    ]);\n```\n\n## Fixers\n\nTable of contents:\n\n* [`ErickSkrauch/align_multiline_parameters`](#erickskrauchalign_multiline_parameters) - Align multiline function params (or remove alignment).\n* [`ErickSkrauch/blank_line_around_class_body`](#erickskrauchblank_line_around_class_body) - Add space inside class body.\n* [`ErickSkrauch/blank_line_before_return`](#erickskrauchblank_line_before_return) - Add blank line before `return`.\n* [`ErickSkrauch/line_break_after_statements`](#erickskrauchline_break_after_statements) - Add blank line after control structures.\n* [`ErickSkrauch/multiline_if_statement_braces`](#erickskrauchmultiline_if_statement_braces) - Fix brace position for multiline `if` statements.\n* [`ErickSkrauch/ordered_overrides`](#erickskrauchordered_overrides) - Sort overridden methods.\n* [`ErickSkrauch/remove_class_name_method_usages`](#erickskrauchremove_class_name_method_usages-yii2) - Replace `::className()` with `:class` (Yii2).\n\n### `ErickSkrauch/align_multiline_parameters`\n\nForces aligned or not aligned multiline function parameters:\n\n```diff\n--- Original\n+++ New\n@@ @@\n  function foo(\n      string $string,\n-     int $index = 0,\n-     $arg = 'no type',\n-     ...$variadic,\n+     int    $index    = 0,\n+            $arg      = 'no type',\n+         ...$variadic\n  ): void {}\n```\n\n**Configuration:**\n\n* `variables` - when set to `true`, forces variables alignment. On `false` forces strictly no alignment.\n  You can set it to `null` to disable touching of variables. **Default**: `true`.\n\n* `defaults` - when set to `true`, forces defaults alignment. On `false` forces strictly no alignment.\n  You can set it to `null` to disable touching of defaults. **Default**: `false`.\n\n### `ErickSkrauch/blank_line_around_class_body`\n\nEnsure that a class body contains one blank line after its definition and before its end:\n\n```diff\n--- Original\n+++ New\n@@ @@\n  \u003c?php\n  class Test {\n+\n      public function func() {\n          $obj = new class extends Foo {\n+\n              public $prop;\n+\n          }\n      }\n+\n  }\n```\n\n**Configuration:**\n\n* `apply_to_anonymous_classes` - should this fixer be applied to anonymous classes? If it is set to `false`, than\n  anonymous classes will be fixed to don't have empty lines around body. **Default**: `true`.\n\n* `blank_lines_count` - adjusts an amount of the blank lines. **Default**: `1`.\n\n### `ErickSkrauch/blank_line_before_return`\n\nThis is extended version of the original `blank_line_before_statement` fixer. It applies only to `return` statements\nand only in cases, when on the current nesting level more than one statements.\n\n```diff\n--- Original\n+++ New\n@@ @@\n \u003c?php\n public function foo() {\n     $a = 'this';\n     $b = 'is';\n+\n     return \"$a $b awesome\";\n }\n\n public function bar() {\n     $this-\u003efoo();\n     return 'okay';\n }\n```\n\n### `ErickSkrauch/line_break_after_statements`\n\nEnsures that there is one blank line above the next statements: `if`, `switch`, `for`, `foreach`, `while`, `do-while` and `try-catch-finally`.\n\n```diff\n--- Original\n+++ New\n@@ @@\n \u003c?php\n $a = 123;\n if ($a === 123) {\n     // Do something here\n }\n+\n $b = [1, 2, 3];\n foreach ($b as $number) {\n     if ($number === 3) {\n         echo 'it is three!';\n     }\n }\n+\n $c = 'next statement';\n```\n\n### `ErickSkrauch/multiline_if_statement_braces`\n\nEnsures that multiline if statement body curly brace placed on the right line.\n\n```diff\n--- Original\n+++ New\n@@ @@\n \u003c?php\n if ($condition1 === 123\n- \u0026\u0026 $condition2 = 321) {\n+ \u0026\u0026 $condition2 = 321\n+) {\n     // Do something here\n }\n```\n\n**Configuration:**\n\n* `keep_on_own_line` - should this place closing bracket on its own line? If it's set to `false`, than\n  curly bracket will be placed right after the last condition statement. **Default**: `true`.\n\n### `ErickSkrauch/ordered_overrides`\n\nOverridden and implemented methods must be sorted in the same order as they are defined in parent classes.\n\n```diff\n--- Original\n+++ New\n@@ @@\n \u003c?php\n class Foo implements Serializable {\n\n-    public function unserialize($data) {}\n+    public function serialize() {}\n\n-    public function serialize() {}\n+    public function unserialize($data) {}\n\n }\n```\n\n**Caveats:**\n\n* This fixer is implemented against the PHP-CS-Fixer principle and relies on runtime, classes autoloading and reflection. If dependencies are missing or the autoloader isn't configured correctly, the fixer will not be able to discover the order of methods in parents.\n\n* Fixer prioritizes `extends` and applies `implements` afterwards. It searches for the deepest parents of classes and takes them as the basis for sorting, ignoring later reordering.\n\n* This fixer runs BEFORE the `ordered_interfaces` fixer, so you might need to run PHP-CS-Fixer twice when you're using this fixer to get proper result. See [this discussion](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7760) for more info.\n\n### `ErickSkrauch/remove_class_name_method_usages` (Yii2)\n\nReplaces Yii2 [`BaseObject::className()`](https://github.com/yiisoft/yii2/blob/e53fc0ded1/framework/base/BaseObject.php#L84)\nusages with native `::class` keyword, introduced in PHP 5.5.\n\n```diff\n--- Original\n+++ New\n@@ @@\n  \u003c?php\n  use common\\models\\User;\n  \n- $className = User::className();\n+ $className = User::class;\n```\n\n[ico-version]: https://img.shields.io/packagist/v/erickskrauch/php-cs-fixer-custom-fixers.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/erickskrauch/php-cs-fixer-custom-fixers.svg?style=flat-square\n[ico-build-status]: https://img.shields.io/github/actions/workflow/status/erickskrauch/php-cs-fixer-custom-fixers/ci.yml?branch=master\u0026style=flat-square\n\n[link-packagist]: https://packagist.org/packages/erickskrauch/php-cs-fixer-custom-fixers\n[link-downloads]: https://packagist.org/packages/erickskrauch/php-cs-fixer-custom-fixers/stats\n[link-build-status]: https://github.com/erickskrauch/php-cs-fixer-custom-fixers/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickskrauch%2Fphp-cs-fixer-custom-fixers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferickskrauch%2Fphp-cs-fixer-custom-fixers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferickskrauch%2Fphp-cs-fixer-custom-fixers/lists"}