{"id":50549643,"url":"https://github.com/luc45/phpcs-ctrf-reporter","last_synced_at":"2026-06-04T02:01:23.084Z","repository":{"id":354442225,"uuid":"1223659886","full_name":"Luc45/phpcs-ctrf-reporter","owner":"Luc45","description":"CTRF Reporter for PHPCS","archived":false,"fork":false,"pushed_at":"2026-04-28T14:47:42.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-28T16:30:30.690Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Luc45.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-28T14:31:12.000Z","updated_at":"2026-04-28T14:51:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Luc45/phpcs-ctrf-reporter","commit_stats":null,"previous_names":["luc45/phpcs-ctrf-reporter"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Luc45/phpcs-ctrf-reporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luc45%2Fphpcs-ctrf-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luc45%2Fphpcs-ctrf-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luc45%2Fphpcs-ctrf-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luc45%2Fphpcs-ctrf-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Luc45","download_url":"https://codeload.github.com/Luc45/phpcs-ctrf-reporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luc45%2Fphpcs-ctrf-reporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33886160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-06-04T02:01:22.142Z","updated_at":"2026-06-04T02:01:23.077Z","avatar_url":"https://github.com/Luc45.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phpcs-ctrf-reporter\n\nA [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) reporter that emits results in the [Common Test Report Format (CTRF)](https://ctrf.io/) — an open JSON standard for test results consumed by GitHub Actions summaries, dashboards, and other CI tooling.\n\n## Why\n\nPHPCS ships with JUnit XML output, but JUnit XML is older, has looser semantics, and isn't as well-supported by modern CI surfaces. CTRF is a tighter JSON schema that's validatable end-to-end (`ctrf-cli validate`) and feeds into the same reporting pipelines as test runs.\n\n## Install\n\n```bash\ncomposer require --dev luc45/phpcs-ctrf-reporter\n```\n\n## Usage\n\n```bash\nvendor/bin/phpcs --report='Luc45\\PhpcsCtrf\\Reports\\Ctrf' src/\n```\n\nOr write to a file:\n\n```bash\nvendor/bin/phpcs --report-Luc45\\\\PhpcsCtrf\\\\Reports\\\\Ctrf=report.json src/\n```\n\n(Escape the backslashes in the report flag according to your shell.)\n\n## Mapping\n\n| PHPCS finding              | CTRF test status |\n| -------------------------- | ---------------- |\n| ERROR violation            | `failed`         |\n| WARNING violation          | `other`          |\n| Clean file (no violations) | `passed`         |\n\nPHPCS-native metadata (sniff source, severity, fixability, column) is preserved via CTRF's `rawStatus`, `tags`, and `extra` extension fields.\n\n## Example output\n\nGiven a fixture with one violation, the reporter emits:\n\n```json\n{\n    \"reportFormat\": \"CTRF\",\n    \"specVersion\": \"1.0.0\",\n    \"reportId\": \"c236c666-f286-457f-82da-b5074eaec7ec\",\n    \"timestamp\": \"2026-04-28T13:26:26Z\",\n    \"generatedBy\": \"PHP_CodeSniffer 4.0.2\",\n    \"results\": {\n        \"tool\": { \"name\": \"PHP_CodeSniffer\", \"version\": \"4.0.2\" },\n        \"summary\": {\n            \"tests\": 1, \"passed\": 0, \"failed\": 1,\n            \"skipped\": 0, \"pending\": 0, \"other\": 0,\n            \"suites\": 1,\n            \"start\": 1777382786761, \"stop\": 1777382786761, \"duration\": 0,\n            \"extra\": { \"fixable\": 1 }\n        },\n        \"tests\": [\n            {\n                \"name\": \"Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine at example.php (7:34)\",\n                \"status\": \"failed\",\n                \"message\": \"Opening brace should be on a new line\",\n                \"filePath\": \"example.php\",\n                \"line\": 7,\n                \"rawStatus\": \"ERROR\",\n                \"type\": \"lint\",\n                \"tags\": [\"ERROR\", \"fixable\"],\n                \"extra\": {\n                    \"column\": 34,\n                    \"severity\": 5,\n                    \"fixable\": true,\n                    \"source\": \"Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine\"\n                }\n            }\n        ]\n    }\n}\n```\n\n## Validation\n\nOutput passes both `ctrf-cli validate` and the stricter `ctrf-cli validate-strict` (which enforces `additionalProperties: false`):\n\n```bash\nnpx --package=ctrf-cli@latest -- ctrf-cli validate report.json\nnpx --package=ctrf-cli@latest -- ctrf-cli validate-strict report.json\n```\n\n## Testing\n\nCI runs the reporter through PHPCS's own test infrastructure: every commit clones the latest `4.x` branch of [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer), injects this package's reporter and tests via [`bin/inject-into-phpcs.sh`](bin/inject-into-phpcs.sh), and runs PHPCS's full PHPUnit + bashunit suite (4,000+ tests) against the modified tree on PHP 7.2 → 8.5.\n\nThis means the reporter is exercised in the exact harness it would face if merged into PHPCS itself, and any breaking change in PHPCS's API is caught the day it lands upstream — not when a user reports a bug.\n\nTo reproduce locally:\n\n```bash\ngit clone https://github.com/PHPCSStandards/PHP_CodeSniffer.git phpcs\n(cd phpcs \u0026\u0026 composer install)\n./bin/inject-into-phpcs.sh phpcs\n(cd phpcs \u0026\u0026 ./vendor/bin/phpunit)\n```\n\n## Compatibility\n\n- Requires PHP 7.2+\n- Requires PHP_CodeSniffer 4.x\n\n## License\n\nBSD-3-Clause — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc45%2Fphpcs-ctrf-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluc45%2Fphpcs-ctrf-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc45%2Fphpcs-ctrf-reporter/lists"}