{"id":37003409,"url":"https://github.com/isaaceindhoven/php-code-sniffer-baseliner","last_synced_at":"2026-01-14T00:33:19.028Z","repository":{"id":39890249,"uuid":"363059782","full_name":"isaaceindhoven/php-code-sniffer-baseliner","owner":"isaaceindhoven","description":"Baseline tool for PHP_CodeSniffer","archived":true,"fork":false,"pushed_at":"2023-10-24T08:42:00.000Z","size":89,"stargazers_count":16,"open_issues_count":4,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-11-27T15:13:53.784Z","etag":null,"topics":["php","phpcodesniffer","phpcs"],"latest_commit_sha":null,"homepage":"https://isaac.nl","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/isaaceindhoven.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}},"created_at":"2021-04-30T07:20:01.000Z","updated_at":"2023-11-01T11:51:38.000Z","dependencies_parsed_at":"2023-01-21T04:15:28.856Z","dependency_job_id":null,"html_url":"https://github.com/isaaceindhoven/php-code-sniffer-baseliner","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/isaaceindhoven/php-code-sniffer-baseliner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaaceindhoven%2Fphp-code-sniffer-baseliner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaaceindhoven%2Fphp-code-sniffer-baseliner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaaceindhoven%2Fphp-code-sniffer-baseliner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaaceindhoven%2Fphp-code-sniffer-baseliner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isaaceindhoven","download_url":"https://codeload.github.com/isaaceindhoven/php-code-sniffer-baseliner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaaceindhoven%2Fphp-code-sniffer-baseliner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["php","phpcodesniffer","phpcs"],"created_at":"2026-01-14T00:33:18.570Z","updated_at":"2026-01-14T00:33:19.013Z","avatar_url":"https://github.com/isaaceindhoven.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Renamed and moved to iO CodeSniffer Standard\n===========\nThis repository has been archived and renamed, moved to [iO PHP_CodeSniffer Baseliner](https://github.com/iodigital-com/php-code-sniffer-baseliner). Feature sniffs and changes will be processed in the iO repository.\n\n# PHP_CodeSniffer Baseliner\n\nThis tool enables you to integrate [PHP_CodeSniffer][php-code-sniffer] into an existing\nproject by automatically adding `phpcs:ignore` and `phpcs:disable`/`phpcs:enable` instructions throughout the codebase\nas a baseline. This allows you to make PHP_CodeSniffer pass without changing any source code, making it\npossible to use PHP_CodeSniffer in e.g. continuous integration pipelines or git hooks. This way, you can enforce that\nall new code adheres to your coding standard without touching the existing code.\n\n## Installation\n\nRequire the package with composer:\n\n```sh\ncomposer require --dev isaac/php-code-sniffer-baseliner\n```\n\nIt is also possible to install this package as a global composer dependency.\n\n## Usage\n\nIn order to add `phpcs:ignore` and `phpcs:disable`/`phpcs:enable` instructions throughout your project, run:\n\n```sh\nvendor/bin/phpcs-baseliner create-baseline\n```\n\n## How does it work?\n\nFirst, the tool runs `vendor/bin/phpcs` and captures the report. Based on the report output, it will add\n`// phpcs:ignore` instructions to the source code for each violation. It will only ignore the sniffs that actually are\nviolated. In rare cases, adding these instructions could introduce new violations. Therefore, this process is repeated\nuntil no violations are reported by `phpcs`.\n\n## Example\n\nLet's say we want to enforce `declare(strict_types = 1);` statements and native property type hints using\nPHP_CodeSniffer. The [Slevomat Coding Standard][slevomat-coding-standard] has sniffs for this:\n[`SlevomatCodingStandard.TypeHints.DeclareStrictTypes`][declare-strict-types-sniff]\nand [`SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint`][property-type-hint-sniff]. We install\nSlevomat Coding Standard and add the sniffs to our ruleset in `phpcs.xml`.\n\nIf we now run `vendor/bin/phpcs-baseliner create-baseline` in our project, it will add ignore instructions in all files\nnot containing `declare(strict_types = 1);` statements or native property type declarations:\n\n```diff\n- \u003c?php\n+ \u003c?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes -- baseline\n  \n  class Foo {\n+     // phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint -- baseline\n      private $bar;\n  }\n```\n\nIn some cases, it is not possible to insert a `// phpcs:ignore` instruction directly above the violated line (e.g.\nmulti-line strings). In those cases, `// phpcs:disable` and `// phpcs:enable` instructions are added:\n\n```diff\n  \u003c?php\n\n  class Foo {\n+     // phpcs:disable Generic.Files.LineLength.TooLong -- baseline  \n      public const BAR = '\n      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas malesuada, lectus vitae vestibulum vulputate, mi morbi.';\n+     // phpcs:enable Generic.Files.LineLength.TooLong -- baseline\n  }\n```\n\n## Features\n- Automatic indentation\n- Ignoring a group of multiple exclusions per line, e.g. `// phpcs:ignore Generic.Files.LineLength.TooLong, Generic.Arrays.DisallowLongArraySyntax -- baseline`\n- Merging new instructions with existing instructions\n- Messages of existing instructions are merged as wel: `// phpcs:ignore Generic.Files.LineLength.TooLong, Generic.Arrays.DisallowLongArraySyntax -- existing message; baseline`\n- Using `phpcs:disable`/`phpcs:enable` when inserting `phpcs:ignore` is not possible (i.e. for multi-line strings, including HEREDOCs and NOWDOCs)\n- Adding a star prefix when a violation is found within a comment block with stars, e.g.:\n  ```php\n  /*\n   * phpcs:ignore Generic.Files.LineLength.TooLong\n   * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas malesuada, lectus vitae vestibulum vulputate, mi morbi.\n   */\n  ```\n- All features are unit tested, see the [`AddBaselineProcessorTestDataProvider`][unit-test-data-set] class for an extensive test data set.\n\n## Roadmap\n- Support processing files that do not start with `\u003c?php` on the first line.\n- Support processing files that contain `?\u003e`.\n- Support ignoring violations on the first line of a file that end with a multi-line string, example:\n  ```php\n  \u003c?php echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas malesuada, lectus vitae vestibulum vulputate, mi\n  morbi.';\n  ?\u003e\n  ```\n- Support detection of and merging with older types of ignore instructions, such as `@phpcsSuppress`.\n\n[php-code-sniffer]: (https://github.com/squizlabs/PHP_CodeSniffer)\n[slevomat-coding-standard]: (https://github.com/slevomat/coding-standard)\n[declare-strict-types-sniff]: (https://github.com/slevomat/coding-standard#slevomatcodingstandardtypehintsdeclarestricttypes-)\n[property-type-hint-sniff]: (https://github.com/slevomat/coding-standard#slevomatcodingstandardtypehintspropertytypehint-)\n[unit-test-data-set]: (https://github.com/isaaceindhoven/php-code-sniffer-baseliner/blob/master/tests/File/AddBaselineProcessorTestDataProvider.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisaaceindhoven%2Fphp-code-sniffer-baseliner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisaaceindhoven%2Fphp-code-sniffer-baseliner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisaaceindhoven%2Fphp-code-sniffer-baseliner/lists"}