{"id":21664398,"url":"https://github.com/wayofdev/php-cs-fixer-config","last_synced_at":"2025-04-12T00:16:25.771Z","repository":{"id":47503028,"uuid":"513880409","full_name":"wayofdev/php-cs-fixer-config","owner":"wayofdev","description":"🧹 Adds custom rule-sets to PHP CS Fixer for consistent coding standards.","archived":false,"fork":false,"pushed_at":"2025-03-23T19:00:52.000Z","size":1355,"stargazers_count":5,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T00:16:08.417Z","etag":null,"topics":["code-standards","code-style","laravel","php","php-cs-fixer","static-analysis"],"latest_commit_sha":null,"homepage":"https://wayof.dev","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/wayofdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wayofdev"}},"created_at":"2022-07-14T11:49:01.000Z","updated_at":"2024-06-21T20:57:39.000Z","dependencies_parsed_at":"2023-09-26T17:46:41.624Z","dependency_job_id":"8814fe94-ae32-4ebb-946b-c61e14455469","html_url":"https://github.com/wayofdev/php-cs-fixer-config","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":0.6666666666666667,"last_synced_commit":"14d10c8f04825dd735019d85c31c0ef162aa8bac"},"previous_names":[],"tags_count":94,"template":false,"template_full_name":"wayofdev/php-package-tpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fphp-cs-fixer-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fphp-cs-fixer-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fphp-cs-fixer-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fphp-cs-fixer-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wayofdev","download_url":"https://codeload.github.com/wayofdev/php-cs-fixer-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497818,"owners_count":21113984,"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":["code-standards","code-style","laravel","php","php-cs-fixer","static-analysis"],"created_at":"2024-11-25T10:37:24.255Z","updated_at":"2025-04-12T00:16:25.749Z","avatar_url":"https://github.com/wayofdev.png","language":"PHP","funding_links":["https://github.com/sponsors/wayofdev"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://wayof.dev\" target=\"_blank\"\u003e\n        \u003cpicture\u003e\n            \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-dark-mode-only.png\"\u003e\n            \u003cimg width=\"400\" src=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-light-mode-only.png\" alt=\"WayOfDev Logo\"\u003e\n        \u003c/picture\u003e\n    \u003c/a\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eBuild\u003c/strong\u003e\u003cbr\u003e\n    \u003ca href=\"https://github.com/wayofdev/php-cs-fixer-config/actions\" target=\"_blank\"\u003e\u003cimg alt=\"Build Status\" src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fphp-cs-fixer-config%2Fbadge\u0026style=flat-square\u0026label=github%20actions\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eProject\u003c/strong\u003e\u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/wayofdev/cs-fixer-config\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/wayofdev/cs-fixer-config?\u0026style=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/wayofdev/cs-fixer-config\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/wayofdev/cs-fixer-config?\u0026style=flat-square\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/wayofdev/cs-fixer-config\" target=\"_blank\"\u003e\u003cimg alt=\"Commits since latest release\" src=\"https://img.shields.io/github/commits-since/wayofdev/php-cs-fixer-config/latest?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/wayofdev/cs-fixer-config\" target=\"_blank\"\u003e\u003cimg alt=\"PHP Version Require\" src=\"https://poser.pugx.org/wayofdev/cs-fixer-config/require/php?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eQuality\u003c/strong\u003e\u003cbr\u003e\n    \u003ca href=\"https://app.codecov.io/gh/wayofdev/php-cs-fixer-config\" target=\"_blank\"\u003e\u003cimg alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/wayofdev/php-cs-fixer-config?style=flat-square\u0026logo=codecov\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://dashboard.stryker-mutator.io/reports/github.com/wayofdev/php-cs-fixer-config/master\" target=\"_blank\"\u003e\u003cimg alt=\"Mutation testing badge\" src=\"https://img.shields.io/endpoint?style=flat-square\u0026label=mutation%20score\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fwayofdev%2Fphp-cs-fixer-config%2Fmaster\"\u003e\u003c/a\u003e\n    \u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/badge/phpstan%20level-9%20of%209-brightgreen?style=flat-square\" alt=\"PHP Stan Level 9 of 9\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eCommunity\u003c/strong\u003e\u003cbr\u003e\n    \u003ca href=\"https://discord.gg/CE3TcCC5vr\" target=\"_blank\"\u003e\u003cimg alt=\"Discord\" src=\"https://img.shields.io/discord/1228506758562058391?style=flat-square\u0026logo=discord\u0026labelColor=7289d9\u0026logoColor=white\u0026color=39456d\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://x.com/intent/follow?screen_name=wayofdev\" target=\"_blank\"\u003e\u003cimg alt=\"Follow on Twitter (X)\" src=\"https://img.shields.io/badge/-Follow-black?style=flat-square\u0026logo=X\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n# PHP CS Fixer Config\n\nWrapper with pre-defined rules around the [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) package — A tool to automatically fix PHP Coding Standards issues.\n\nThis repository aims to provide a standardized way to apply coding standards across multiple projects, ensuring consistency and adherence to best practices. By using predefined rulesets, it simplifies the setup process and allows teams to quickly integrate PHP-CS-Fixer into their development workflow.\n\n\u003cbr\u003e\n\nIf you **like/use** this package, please consider ⭐️ **starring** it. Thanks!\n\n\u003cbr\u003e\n\n## 📜 Custom Rulesets\n\n**```WayOfDev\\PhpCsFixer\\Config\\RuleSets\\DefaultRuleset::class```**\n\nBased on **`@Symfony`** ruleset\n\n* Used by [`@wayofdev`](https://github.com/wayofdev) organization\n\n**`WayOfDev\\PhpCsFixer\\Config\\RuleSets\\ExtendedPERSet::class`**\n\nBased on **`@PER-CS2.0`** ruleset\n\n* Used by [`@buggregator`](https://github.com/buggregator) and [`@cycle`](http://github.com/cycle) organizations\n\n\u003cbr\u003e\n\n## 💿 Installation\n\n### → Using composer\n\nRequire as dependency:\n\n```bash\ncomposer req --dev wayofdev/cs-fixer-config\n```\n\n\u003cbr\u003e\n\n## 🛠 Configuration\n\n### → Setup\n\n* Create PHP file and name it `.php-cs-fixer.dist.php` and place it inside root directory of project. It will be recognized by PHP CS Fixer automatically.\n\n* Example contents of `.php-cs-fixer.dist.php` file:\n\n   ```php\n    \u003c?php\n\n    declare(strict_types=1);\n\n    use WayOfDev\\PhpCsFixer\\Config\\ConfigBuilder;\n    use WayOfDev\\PhpCsFixer\\Config\\RuleSets\\DefaultSet;\n\n    require_once 'vendor/autoload.php';\n\n    $config = ConfigBuilder::createFromRuleSet(new DefaultSet())\n        -\u003einDir(__DIR__ . '/src')\n        -\u003einDir(__DIR__ . '/tests')\n        -\u003eaddFiles([__FILE__])\n        -\u003egetConfig()\n    ;\n\n    $config-\u003esetCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache');\n\n    return $config;\n   ```\n\n### → Composer Script\n\n* Add `scripts` section to `composer.json`:\n\n  ```diff\n  {\n      \"scripts\": {\n  +       \"cs:diff\": \"php vendor/bin/php-cs-fixer fix --dry-run -v --diff\",\n  +       \"cs:fix\": \"php vendor/bin/php-cs-fixer fix -v\"\n      }\n  }\n  ```\n\n### → Git\n\n* Place `.build` folder file into `.gitignore`\n\n  ```diff\n  +/.build/\n   /vendor/\n  ```\n\n### → Makefile\n\n* If you are using [`Makefile`](https://www.gnu.org/software/make/manual/make.html#Introduction), create a `Makefile` with a `lint-php` and `lint-diff` targets:\n\n  ```diff\n  +APP_RUNNER ?= php\n  +APP_COMPOSER ?= $(APP_RUNNER) composer\n  +\n  +prepare:\n  +  mkdir -p .build/php-cs-fixer\n  +.PHONY: prepare\n\n  +lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer\n  +  $(APP_COMPOSER) cs:fix\n  +.PHONY: lint-php\n\n  +lint-diff: prepare ## Runs php-cs-fixer in dry-run mode and shows diff which will by applied\n  +  $(APP_COMPOSER) cs:diff\n  +.PHONY: lint-diff\n  ```\n\n Or, you can check for one of our pre-configured `Makefile` from any of these repositories:\n\n \u003chttps://github.com/wayofdev/php-cs-fixer-config/blob/master/Makefile\u003e\n\n \u003chttps://github.com/wayofdev/laravel-package-tpl/blob/master/Makefile\u003e\n\n### → GitHub Actions\n\n* To use this package in [GitHub Actions](https://github.com/features/actions), add a `coding-standards.yml` workflow to your repository:\n\n  ```yaml\n  ---\n\n  on:  # yamllint disable-line rule:truthy\n    pull_request:\n      branches:\n        - master\n    push:\n      branches:\n        - master\n\n  name: 🧹 Fix PHP coding standards\n\n  jobs:\n    coding-standards:\n      timeout-minutes: 4\n      runs-on: ${{ matrix.os }}\n      concurrency:\n        cancel-in-progress: true\n        group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}\n      strategy:\n        matrix:\n          os:\n            - ubuntu-latest\n          php-version:\n            - '8.1'\n          dependencies:\n            - locked\n      permissions:\n        contents: write\n      steps:\n        - name: ⚙️ Set git to use LF line endings\n          run: |\n            git config --global core.autocrlf false\n            git config --global core.eol lf\n\n        - name: 🛠️ Setup PHP\n          uses: shivammathur/setup-php@2.30.4\n          with:\n            php-version: ${{ matrix.php-version }}\n            extensions: none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter\n            ini-values: error_reporting=E_ALL\n            coverage: none\n\n        - name: 📦 Check out the codebase\n          uses: actions/checkout@v4.1.5\n\n        - name: 🛠️ Setup problem matchers\n          run: |\n            echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"\n\n        - name: 🤖 Validate composer.json and composer.lock\n          run: composer validate --ansi --strict\n\n        - name: 🔍 Get composer cache directory\n          uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0\n\n        - name: ♻️ Restore cached dependencies installed with composer\n          uses: actions/cache@v4.0.2\n          with:\n            path: ${{ env.COMPOSER_CACHE_DIR }}\n            key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}\n            restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-\n\n        - name: 📥 Install \"${{ matrix.dependencies }}\" dependencies with composer\n          uses: wayofdev/gh-actions/actions/composer/install@v3.1.0\n          with:\n            dependencies: ${{ matrix.dependencies }}\n\n        - name: 🛠️ Prepare environment\n          run: make prepare\n\n        - name: 🚨 Run coding standards task\n          run: composer cs:fix\n          env:\n            PHP_CS_FIXER_IGNORE_ENV: true\n\n        - name: 📤 Commit and push changed files back to GitHub\n          uses: stefanzweifel/git-auto-commit-action@v5.0.1\n          with:\n            commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'\n            branch: ${{ github.head_ref }}\n            commit_author: 'github-actions \u003cgithub-actions@users.noreply.github.com\u003e'\n          env:\n            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n  ```\n\n Or, you can check for one of our pre-configured workflows from any of these repositories:\n\n \u003chttps://github.com/wayofdev/php-cs-fixer-config/blob/master/.github/workflows/coding-standards.yml\u003e\n\n\u003cbr\u003e\n\n## 💻 Usage\n\nFix coding standards by simply running console command:\n\n### → Directly\n\n```bash\nvendor/bin/php-cs-fixer fix -v\n```\n\n### → Via Composer Script\n\nTo use via composer script commands:\n\n* Fixes code to follow coding standards using php-cs-fixer:\n\n  ```bash\n  composer cs:diff\n  ```\n\n* Runs php-cs-fixer in dry-run mode and shows diff which will by applied:\n\n  ```bash\n  composer cs:fix\n  ```\n\n### → Using Makefile\n\n**To use with `Makefile`**\n\n* Fixes code to follow coding standards using php-cs-fixer:\n\n  ```bash\n  make lint-php\n  ```\n\n* Runs php-cs-fixer in dry-run mode and shows diff which will by applied:\n\n  ```bash\n  make lint-diff\n  ```\n\n\u003cbr\u003e\n\n## 🔒 Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n\u003cbr\u003e\n\n## 🙌 Want to Contribute?\n\nThank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:\n\n* 🤔 [Suggest a feature](https://github.com/wayofdev/php-cs-fixer-config/issues/new?assignees=\u0026labels=type%3A+enhancement\u0026projects=\u0026template=2-feature-request.yml\u0026title=%5BFeature%5D%3A+)\n* 🐛 [Report an issue](https://github.com/wayofdev/php-cs-fixer-config/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=1-bug-report.yml\u0026title=%5BBug%5D%3A+)\n* 📖 [Improve documentation](https://github.com/wayofdev/php-cs-fixer-config/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=4-docs-bug-report.yml\u0026title=%5BDocs%5D%3A+)\n* 👨‍💻 Contribute to the code\n\nYou are more than welcome. Before contributing, kindly check our [contribution guidelines](.github/CONTRIBUTING.md).\n\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org)\n\n\u003cbr\u003e\n\n## 🫡 Contributors\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://github.com/wayofdev/php-cs-fixer-config/graphs/contributors\"\u003e\n\u003cimg align=\"left\" src=\"https://img.shields.io/github/contributors-anon/wayofdev/php-cs-fixer-config?style=for-the-badge\" alt=\"Contributors Badge\"/\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\n## 🌐 Social Links\n\n* **Twitter:** Follow our organization [@wayofdev](https://twitter.com/intent/follow?screen_name=wayofdev) and the author [@wlotyp](https://twitter.com/intent/follow?screen_name=wlotyp).\n* **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr).\n\n\u003cbr\u003e\n\n## 🧱 Resources\n\n* Full documentation about all fixers is available here - [PHP-CS-Fixer configuration UI](https://mlocati.github.io/php-cs-fixer-configurator/#version:3.0)\n\n* The official [PHP-CS-Fixer documentation](https://github.com/FriendsOfPHP/PHP-CS-Fixer)\n\n\u003cbr\u003e\n\n## ⚖️ License\n\n[![Licence](https://img.shields.io/github/license/wayofdev/php-cs-fixer-config?style=for-the-badge\u0026color=blue)](./LICENSE.md)\n\n\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fphp-cs-fixer-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwayofdev%2Fphp-cs-fixer-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fphp-cs-fixer-config/lists"}