{"id":16078453,"url":"https://github.com/romanzipp/php-cs-fixer-config","last_synced_at":"2025-03-17T17:30:30.539Z","repository":{"id":40448005,"uuid":"329960963","full_name":"romanzipp/PHP-CS-Fixer-Config","owner":"romanzipp","description":"Personal PHP-CS-Fixer wrapper \u0026 Custom rules \u0026 preset management inlcuding PHPStorm integration","archived":false,"fork":false,"pushed_at":"2024-10-02T10:20:02.000Z","size":922,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T02:09:28.712Z","etag":null,"topics":["php","php-cs-fixer","php7","php8","phpstorm","styling","syntax"],"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/romanzipp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"romanzipp"}},"created_at":"2021-01-15T16:12:00.000Z","updated_at":"2024-10-02T10:19:59.000Z","dependencies_parsed_at":"2024-10-27T15:38:29.202Z","dependency_job_id":"5a8c7871-950c-4d7c-8ab3-2fe7b9c61779","html_url":"https://github.com/romanzipp/PHP-CS-Fixer-Config","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":"0.021739130434782594","last_synced_commit":"7b1907a1cd2b790361c7f0b20fc8fc234b0e3140"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FPHP-CS-Fixer-Config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FPHP-CS-Fixer-Config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FPHP-CS-Fixer-Config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FPHP-CS-Fixer-Config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romanzipp","download_url":"https://codeload.github.com/romanzipp/PHP-CS-Fixer-Config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871904,"owners_count":20361380,"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","php-cs-fixer","php7","php8","phpstorm","styling","syntax"],"created_at":"2024-10-09T10:12:56.140Z","updated_at":"2025-03-17T17:30:30.179Z","avatar_url":"https://github.com/romanzipp.png","language":"PHP","funding_links":["https://github.com/sponsors/romanzipp"],"categories":[],"sub_categories":[],"readme":"# PHP-CS-Fixer Configuration\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/romanzipp/PHP-CS-Fixer-Config.svg?style=flat-square)](https://packagist.org/packages/romanzipp/php-cs-fixer-config)\n[![Total Downloads](https://img.shields.io/packagist/dt/romanzipp/PHP-CS-Fixer-Config.svg?style=flat-square)](https://packagist.org/packages/romanzipp/php-cs-fixer-config)\n[![License](https://img.shields.io/packagist/l/romanzipp/PHP-CS-Fixer-Config.svg?style=flat-square)](https://packagist.org/packages/romanzipp/php-cs-fixer-config)\n[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/romanzipp/PHP-CS-Fixer-Config/tests.yml?style=flat-square)](https://github.com/romanzipp/PHP-CS-Fixer-Config/actions)\n\nPersonal [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) wrapper, preset management and custom rules.\n\n## Installation\n\n```\ncomposer require romanzipp/php-cs-fixer-config --dev\n```\n\n**Notice**: You also need to [install the PHP-CS-Fixer package](https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation) itself if you need a local installation with executable in your `vendor/bin` folder.\n\n## Usage\n\nThis package has been created to streamline configuration management for multiple projects and keeping PHP CS Fixer rules up to date.\n\n#### `.php-cs-fixer.dist.php`\n\n```php\nreturn romanzipp\\Fixer\\Config::make()\n    -\u003ein(__DIR__)\n    -\u003epreset(\n        new romanzipp\\Fixer\\Presets\\PrettyPHP()\n    )\n    -\u003eout();\n```\n\n## Available Presets\n\n- [**PrettyPHP**](src/Presets/PrettyPHP.php)\n- [**PrettyLaravel**](src/Presets/PrettyLaravel.php) (extends [PrettyPHP](src/Presets/PrettyPHP.php))\n\nYou can easily create your own presets by extending the [**AbstractPreset**](src/Presets/AbstractPreset.php) class.\n\n### Overriding presets\n\nIn case you only need some tweaks for specific projects - which won't deserve an own preset - there are various methods you can make us of.\n\n```php\n$config = romanzipp\\Fixer\\Config::make();\n\n$config-\u003eallowRisky(true);                  // Allow risky rules.\n$config-\u003ewithRules(['...']);                // Set additional rules\n$config-\u003eexclude(['...']);                  // Add single or many files to the list of excluded files.\n$config-\u003eexcludeDirectories(['...']);       // Add single or many directories to the list of excluded directories.\n```\n\n## Available Rules\n\n### Convert PHPDoc Classes to FQCN\n\n```php\n$fixer-\u003ewithRules([\n    'RomanZipp/phpdoc_fqcn' =\u003e true,\n]);\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eShow code sample\u003c/summary\u003e\n\n#### Bad\n\n```php\nuse App\\Foo;\nuse App\\Bar;\n\n/**\n * @param  Foo $foo\n * @return Bar[]  \n */\nfunction foo(Foo $foo): array {}\n```\n\n#### Good\n\n```php\nuse App\\Foo;\n\n/**\n * @param  \\App\\Foo $foo\n * @return \\App\\Bar[]  \n */\nfunction foo(Foo $foo): array {}\n```\n\u003c/details\u003e\n\n## Advanced Usage\n\n### Access the config and finder instances\n\n```php\nreturn romanzipp\\Fixer\\Config::make()\n    // ...\n    -\u003efinderCallback(static function (PhpCsFixer\\Finder $finder): void {\n        // ...\n    })\n    -\u003econfigCallback(static function (PhpCsFixer\\Config $config): void {\n        $config-\u003eregisterCustomFixers();\n        // ...\n    })\n    // ...\n    -\u003eout();\n```\n\n## PHPStorm Configuration\n\n### Prequisites\n\nYou will need to install PHP CS Fixer globally on your system because PHPStorm [does not allow](https://youtrack.jetbrains.com/issue/WI-56557) you to set the php-cs-fixer executable on a per-project basis or relative to the project path.\n\n```shell\ncomposer global require friendsofphp/php-cs-fixer\n```\n### 1. Enable Inspection\n\n![](images/inspection.png)\n\n### 2. Select ruleset .php-cs-fixer.dist.php file `[...]`\n\n![](images/ruleset.png)\n\nUnfortunately you have to repeat this process for every project since [there is a bug in PHPStorm](https://youtrack.jetbrains.com/issue/WI-56557) which prevents users from using relative paths for the `.php-cs-fixer.dist.php` configuration or executable file.\n\nAnother theoretical approach to this issue is to create a unified ruleset file in your users .composer folder. This has the downside on only having one single ruleset.\n\n### 3. Navigate to Quality Tools by clicking on the \"PHP CS Fixer\" link\n\n![](images/navigate.png)\n\n### 4. Select PHP-CS-Fixer executable\n\n![](images/executable.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanzipp%2Fphp-cs-fixer-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanzipp%2Fphp-cs-fixer-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanzipp%2Fphp-cs-fixer-config/lists"}