{"id":25818313,"url":"https://github.com/alma-oss/php-coding-standard","last_synced_at":"2025-02-28T07:09:00.422Z","repository":{"id":30567685,"uuid":"125386379","full_name":"alma-oss/php-coding-standard","owner":"alma-oss","description":"PHP coding standard used in Alma Career projects, but usable anywhere else","archived":false,"fork":false,"pushed_at":"2025-02-27T14:43:51.000Z","size":283,"stargazers_count":14,"open_issues_count":5,"forks_count":10,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-02-27T19:03:00.809Z","etag":null,"topics":["alma-career","coding-standard","php","php-code-sniffer","php-cs-fixer"],"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/alma-oss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2018-03-15T15:18:40.000Z","updated_at":"2025-02-27T14:37:48.000Z","dependencies_parsed_at":"2024-04-28T23:21:38.926Z","dependency_job_id":"19a337aa-7905-425e-b165-11e79a139385","html_url":"https://github.com/alma-oss/php-coding-standard","commit_stats":{"total_commits":122,"total_committers":5,"mean_commits":24.4,"dds":0.0901639344262295,"last_synced_commit":"aadd0002613b426d1f5304822e3d39beeba2e99f"},"previous_names":["alma-oss/php-coding-standard"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alma-oss%2Fphp-coding-standard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alma-oss%2Fphp-coding-standard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alma-oss%2Fphp-coding-standard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alma-oss%2Fphp-coding-standard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alma-oss","download_url":"https://codeload.github.com/alma-oss/php-coding-standard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241115345,"owners_count":19912224,"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":["alma-career","coding-standard","php","php-code-sniffer","php-cs-fixer"],"created_at":"2025-02-28T07:08:59.846Z","updated_at":"2025-02-28T07:09:00.408Z","avatar_url":"https://github.com/alma-oss.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alma Career Coding Standard for PHP\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/lmc/coding-standard.svg?style=flat-square)](https://packagist.org/packages/lmc/coding-standard)\n\nPHP coding standard used in [Alma Career][Alma Career] (formerly LMC) products.\n\nThe standard is based on [PSR-12][psr-12] and partially [PER 2.0][per-2] and adds\nvarious checks to make sure the code is readable, follows the same conventions, and does not contain common mistakes.\n\nWe use [EasyCodingStandard][ecs] to define and execute checks created for both [PHP-CS-Fixer] and [PHP_CodeSniffer].\n\n## Installation\n\n```bash\ncomposer require --dev lmc/coding-standard\n```\n\n## Usage\n\n1. Create `ecs.php` file in the root directory of your project and import the code-style rules:\n\n```php\n\u003c?php declare(strict_types=1);\n\nuse Lmc\\CodingStandard\\Set\\SetList;\nuse Symplify\\EasyCodingStandard\\Config\\ECSConfig;\n\nreturn ECSConfig::configure()\n    -\u003ewithPaths([__DIR__ . '/src', __DIR__ . '/tests']) // optionally add 'config' or other directories with PHP files\n    -\u003ewithRootFiles() // to also check ecs.php and all other php files in the root directory\n    -\u003ewithSets(\n        [\n            SetList::ALMACAREER,\n        ]\n    );\n```\n\n2. Run the check command\n\n```bash\nvendor/bin/ecs check\n```\n\n3. Optionally we recommend adding this to `scripts` section of your `composer.json`:\n\n```json\n    \"scripts\": {\n        \"analyze\": [\n            \"vendor/bin/ecs check --ansi\",\n            \"[... other scripts, like PHPStan etc.]\"\n        ],\n        \"fix\": [\n            \"...\",\n            \"vendor/bin/ecs check --ansi --fix\"\n        ],\n    }\n```\n\nNow you will be able to run the fix using `composer analyze` and execute automatic fixes with `composer fix`.\n\n### Add custom checks or override default settings\n\nOn top of the default code-style rules, you are free to add any rules from [PHP-CS-Fixer] or [PHP_CodeSniffer].\nIf needed, you can also override any default settings.\n\nBelow find examples of some more opinionated checks you may want to add depending on your needs:\n\n```php\n\u003c?php declare(strict_types=1);\n\nuse Lmc\\CodingStandard\\Set\\SetList;\nuse PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\Files\\LineLengthSniff;\nuse PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitTestAnnotationFixer;\nuse Symplify\\EasyCodingStandard\\Config\\ECSConfig;\n\nreturn ECSConfig::configure()\n    /* (...) */\n    -\u003ewithSets(\n        [\n            SetList::ALMACAREER,\n        ]\n    )\n    -\u003ewithRules(\n        [\n            // PHPUnit attributes must be used over their respective PHPDoc-based annotations. (Use with PHPUnit 10+.)\n            PhpUnitAttributesFixer::class,\n            // Single-line comments must have proper spacing (one space after `//`).\n            SingleLineCommentSpacingFixer::class,\n            // Convert multiline string to heredoc or nowdoc.\n            MultilineStringToHeredocFixer::class,\n        ]\n    )\n    // Enforce line-length to 120 characters.\n    -\u003ewithConfiguredRule(LineLengthSniff::class, ['absoluteLineLimit' =\u003e 120])\n    // Tests must have @test annotation.\n    -\u003ewithConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' =\u003e 'annotation'])\n    // Specify elements separation.\n    -\u003ewithConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' =\u003e ['const' =\u003e 'none', 'method' =\u003e 'one', 'property' =\u003e 'none']])\n    /* (...) */\n```\n\nSee [EasyCodingStandard docs][ecs-docs] for more configuration options.\n\n\n### Exclude (skip) checks or files\n\nYou can configure your `ecs.php` file to entirely skip some files, disable specific checks, or suppress specific errors.\n\n```php\n\u003c?php declare(strict_types=1);\n\nuse PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\ForbiddenFunctionsSniff;\nuse PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\Arrays\\ArrayDeclarationSniff;\nuse Symplify\\EasyCodingStandard\\Config\\ECSConfig;\n\nreturn ECSConfig::configure()\n    /* (...) */\n    -\u003ewithSkip(\n        [\n            // Ignore specific check only in specific files\n            ForbiddenFunctionsSniff::class =\u003e [__DIR__ . '/src-tests/bootstrap.php'],\n            // Disable check entirely\n            ArrayDeclarationSniff::class,\n            // Skip one file\n            __DIR__ . '/file/to/be/skipped.php',\n            // Skip entire directory\n            __DIR__ . '/ignored/directory/*',\n        ]\n    )\n    /* (...) */\n```\n\nSee [EasyCodingStandard docs][ecs-docs] for more configuration options.\n\n### IDE integration\n\nFor integration with PHPStorm and other IDEs, follow instructions in [EasyCodingStandard README][ecs-readme-ide].\n\n## Changelog\nFor the latest changes, see [CHANGELOG.md](CHANGELOG.md) file. This library follows [Semantic Versioning](https://semver.org/).\n\n## License\nThis library is open-source software licensed under the [MIT license](LICENSE.md).\n\n[Alma Career]: https://www.almacareer.com/\n[PHP-CS-Fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer\n[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer\n[psr-12]: https://www.php-fig.org/psr/psr-12/\n[per-2]: https://www.php-fig.org/per/coding-style/\n[ecs]: https://github.com/easy-coding-standard/easy-coding-standard\n[ecs-docs]: https://github.com/easy-coding-standard/easy-coding-standard#configure\n[ecs-readme-ide]: https://github.com/easy-coding-standard/easy-coding-standard/blob/9.0.0/README.md#your-ide-integration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falma-oss%2Fphp-coding-standard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falma-oss%2Fphp-coding-standard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falma-oss%2Fphp-coding-standard/lists"}