{"id":21526062,"url":"https://github.com/nelson6e65/php-code-sniffer-helpers","last_synced_at":"2025-04-09T23:32:48.717Z","repository":{"id":57024804,"uuid":"347662823","full_name":"nelson6e65/php-code-sniffer-helpers","owner":"nelson6e65","description":"Helpers for PHP Code Sniffer.","archived":false,"fork":false,"pushed_at":"2024-06-06T12:15:53.000Z","size":446,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T09:34:07.698Z","etag":null,"topics":["composer","composer-scripts","lint-staged","php","phpcbf","phpcs"],"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/nelson6e65.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"patreon":"nelson6e65","custom":["https://paypal.me/n6e65"]}},"created_at":"2021-03-14T14:41:44.000Z","updated_at":"2024-06-06T12:14:58.000Z","dependencies_parsed_at":"2024-06-06T12:38:19.287Z","dependency_job_id":"3379eb58-1402-4946-a4c3-4f87587c2a83","html_url":"https://github.com/nelson6e65/php-code-sniffer-helpers","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"7cf95606ba5c0b26a340a86bff7b5d8264b93677"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelson6e65%2Fphp-code-sniffer-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelson6e65%2Fphp-code-sniffer-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelson6e65%2Fphp-code-sniffer-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nelson6e65%2Fphp-code-sniffer-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nelson6e65","download_url":"https://codeload.github.com/nelson6e65/php-code-sniffer-helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129637,"owners_count":21052610,"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":["composer","composer-scripts","lint-staged","php","phpcbf","phpcs"],"created_at":"2024-11-24T01:41:57.268Z","updated_at":"2025-04-09T23:32:48.682Z","avatar_url":"https://github.com/nelson6e65.png","language":"PHP","funding_links":["https://patreon.com/nelson6e65","https://paypal.me/n6e65"],"categories":[],"sub_categories":[],"readme":"# PHP Code Sniffer Helpers\n\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/nelson6e65/code-sniffer-helpers)\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/nelson6e65/code-sniffer-helpers)\n\n[![GitHub release](https://img.shields.io/github/tag/nelson6e65/php-code-sniffer-helpers.svg?logo=github)](https://github.com/nelson6e65/php-code-sniffer-helpers/tags)\n[![Latest Version](https://img.shields.io/packagist/v/nelson6e65/code-sniffer-helpers.svg?label=stable)](https://packagist.org/packages/nelson6e65/code-sniffer-helpers)\n[![Latest unstable Version](https://img.shields.io/packagist/vpre/nelson6e65/code-sniffer-helpers.svg?label=unstable)](https://packagist.org/packages/nelson6e65/code-sniffer-helpers#dev-main)\n\n[![License](https://img.shields.io/github/license/nelson6e65/php-code-sniffer-helpers.svg)](LICENSE)\n[![time tracker](https://wakatime.com/badge/github/nelson6e65/php-code-sniffer-helpers.svg)](https://wakatime.com/badge/github/nelson6e65/php-code-sniffer-helpers)\n\nHelpers for PHP Code Sniffer.\n\n## Installation\n\n```sh\ncomposer require --dev nelson6e65/code-sniffer-helpers\n```\n\n## Features\n\n### Composer scripts\n\n#### `phpcbf` for lint-staged\n\nA wrapper to fix your staged code (or argumented files/folders) using the **PHP Code Sniffer** auto-fixer.\n\nThere is a bug that does not allows you to use it directly as autofixer (https://github.com/squizlabs/PHP_CodeSniffer/issues/1818). There is [a workarround for using it as a composer script](https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-735620637), but does not works for using it in a [lint-staged](https://github.com/okonet/lint-staged) pre-commit hook.\n\nThis helper is designed to be run with lint-staged, but you can also use it directly in your composer script.\n\n##### Setup with lint-staged\n\nAdd the script to your composer.json:\n\n```json\n{\n  \"scripts\": {\n    \"cs:fix-filtered\": [\"NelsonMartell\\\\PhpCodeSniffer\\\\ComposerScripts::phpcbf\"]\n  }\n}\n```\n\n\u003e I used `\"cs:fix-filtered\"` name, but you can use any script name you like.\n\nConfigure your Husky + lint-staged in your package.json\n\n```json\n{\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"lint-staged\"\n    }\n  },\n  \"lint-staged\": {\n    \"*.php\": \"composer cs:fix-filtered\"\n  }\n}\n```\n\n\u003e Example for Husky 4. Adapt it if you use Husky 5.\n\n##### Usage\n\nYou can also run it directly with composer by using `composer cs:fix-filtered {PATHS}`. Example:\n\n```sh\ncomposer cs:fix-filtered src/ tests/ config/my-config-file.php\n```\n\n\u003e Note: Non exixtent files/directories are ignored.\n\n##### Output\n\nThe output is inspired on [pretty-quick](https://github.com/azz/pretty-quick) output:\n\n```sh\ncomposer cs:fix-filtered config/ src/Example.php src/non-existent-file.php\n```\n\n![output1](.github/screenshots/output1.png)\n\n## License\n\n[![License](https://img.shields.io/github/license/nelson6e65/php-code-sniffer-helpers.svg)](LICENSE)\n\nCopyright (c) 2021 Nelson Martell\n\nRead the [`LICENSE` file](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelson6e65%2Fphp-code-sniffer-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnelson6e65%2Fphp-code-sniffer-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelson6e65%2Fphp-code-sniffer-helpers/lists"}