{"id":13518630,"url":"https://github.com/magento/magento-coding-standard","last_synced_at":"2025-05-14T02:00:34.452Z","repository":{"id":38830211,"uuid":"161527394","full_name":"magento/magento-coding-standard","owner":"magento","description":"Magento Coding Standard","archived":false,"fork":false,"pushed_at":"2025-04-15T14:48:18.000Z","size":1569,"stargazers_count":365,"open_issues_count":91,"forks_count":160,"subscribers_count":351,"default_branch":"develop","last_synced_at":"2025-05-10T14:55:02.381Z","etag":null,"topics":["coding-standard","magento","php","php-codesniffer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"osl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magento.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"COPYING.txt","code_of_conduct":".github/CODE_OF_CONDUCT.md","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}},"created_at":"2018-12-12T18:15:17.000Z","updated_at":"2025-05-02T17:56:17.000Z","dependencies_parsed_at":"2024-01-12T00:27:14.341Z","dependency_job_id":"d008900e-fda7-4f3c-9e9e-8cb02a12f9b5","html_url":"https://github.com/magento/magento-coding-standard","commit_stats":{"total_commits":726,"total_committers":67,"mean_commits":"10.835820895522389","dds":0.7878787878787878,"last_synced_commit":"d7ece6da506db4fadaa63c7ae31d15f1d9ff1443"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magento%2Fmagento-coding-standard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magento%2Fmagento-coding-standard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magento%2Fmagento-coding-standard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magento%2Fmagento-coding-standard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magento","download_url":"https://codeload.github.com/magento/magento-coding-standard/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052658,"owners_count":22006716,"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":["coding-standard","magento","php","php-codesniffer"],"created_at":"2024-08-01T05:01:47.073Z","updated_at":"2025-05-14T02:00:34.417Z","avatar_url":"https://github.com/magento.png","language":"PHP","readme":"# Magento Coding Standard\n\nA set of Magento rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) tool.\n\n## Installation within a Magento 2 site\n\nTo use within your Magento 2 project you can use:\n\n```bash\ncomposer require --dev magento/magento-coding-standard\n```\n\nDue to security, when installed this way the Magento standard for phpcs cannot be added automatically.\nYou can achieve this by adding the following to your project's `composer.json`:\n\n```json\n\"scripts\": {\n    \"post-install-cmd\": [\n      \"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)\"\n    ],\n    \"post-update-cmd\": [\n      \"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)\"\n    ]\n}\n```\n\n### Installation for development\n\nYou can install Magento Coding Standard by cloning this GitHub repo:\n\n```bash\ngit clone git@github.com:magento/magento-coding-standard.git\ncd magento-coding-standard\ncomposer install\n```\n\nIt is possible also to install a standalone application via [Composer](https://getcomposer.org)\n\n```bash\ncomposer create-project magento/magento-coding-standard --stability=dev magento-coding-standard\n```\n\n### Verify installation\n\nCommand should return the list of installed coding standards including Magento2.\n\n```bash\nvendor/bin/phpcs -i\n```\n\n## Usage\n\nOnce installed, you can run `phpcs` from the command-line to analyze your code `MyAwesomeExtension`\n\n```bash\nvendor/bin/phpcs --standard=Magento2 app/code/MyAwesomeExtension\n```\n\n### Fixing issues automatically\n\nAlso, you can run `phpcbf` from the command-line to fix your code `MyAwesomeExtension` for warnings like \"PHPCBF CAN FIX THE [0-9]+ MARKED SNIFF VIOLATIONS AUTOMATICALLY\"\n\n```bash\nvendor/bin/phpcbf --standard=Magento2 app/code/MyAwesomeExtension\n```\n\n## Contribution\n\nSee the community [contribution model](https://github.com/magento/magento-coding-standard/blob/develop/.github/CONTRIBUTING.md).\n\n### Where to contribute\n\n- Documentation of existing rules. See [ExtDN PHP CodeSniffer rules for Magento 2](https://github.com/extdn/extdn-phpcs) as a good example.\n- Bug fixes and improvements of existing rules.\n- Creation of new PHP CodeSniffer rules.\n- Discussions on new rules (through periodic hangouts or discussions per GitHub issue).\n\n### How to contribute\n\n1) Start with looking into [Community Dashboard](https://github.com/magento/magento-coding-standard/projects/1). Any ticket in `Up for grabs` is a good candidate to start.\n2) Didn't satisfy your requirements? [Create one of three types of issues](https://github.com/magento/magento-coding-standard/issues/new/choose):\n   - **Bug report** - Found a bug in the code? Let us know!\n   - **Existing rule enhancement** - Know how to improve existing rules? Open an issue describe how to enhance Magento Coding Standard.\n   - **New rule proposal** - Know how to improve Magento ecosystem code quality? Do not hesitate to open a proposal.\n3) The issue will appear in the `Backlog` column of the [Community Dashboard](https://github.com/magento/magento-coding-standard/projects/1). Once it will be discussed and get `accepted` label the issue will appear in the `Up for grabs` column.\n\n## Testing\n\nAll rules should be covered by unit tests. Each `Test.php` class should be accompanied by a `Test.inc` file to allow for unit testing based upon the PHP_CodeSniffer parent class `AbstractSniffUnitTest`.\nYou can verify your code by running\n\n```bash\nvendor/bin/phpunit\n```\n\nAlso, verify that the sniffer code itself is written according to the Magento Coding Standard:\n\n```bash\nvendor/bin/phpcs --standard=Magento2 Magento2/ --extensions=php\n```\n\n### ESLint\nPrerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `\u003e=16.0.0`).\n\nYou need to run the following command to install all the necessary packages described in the `package.json` file:\n```bash\nnpm install\n```\n\nYou can execute ESLint as follows:\n```bash\nnpm run eslint -- path/to/analyze\n```\n\n### RECTOR PHP\nFrom `magento-coding-standard` project, you can execute rector php as follows:\n```bash\nvendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php\n```\nThe rules from rector that are applied are set inside the config file: `rector.php`\n\nThe option `--dry-run` displays errors found, but code is not automatically fixed.\n\nTo run rector for `magento` projects you need to:\n- Specify the magento path and the autoload file for the magento project: \n```bash\nvendor/bin/rector process MAGENTO_PATH --dry-run --autoload-file MAGENTO_AUTOLOAD_FILE\n```\nExample:\n```bash\nvendor/bin/rector process magento2ce/app/code/Magento/Cms/Model --dry-run --autoload-file magento2ce/vendor/autoload.php\n```\n\n## License\n\nEach Magento source file included in this distribution is licensed under the OSL-3.0 license.\n\nPlease see [LICENSE.txt](https://github.com/magento/magento-coding-standard/blob/master/LICENSE.txt) for the full text of the [Open Software License v. 3.0 (OSL-3.0)](https://opensource.org/licenses/osl-3.0.php).\n","funding_links":[],"categories":["PHP","Open Source Extensions","Official Resources"],"sub_categories":["Development Utilities","Other"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagento%2Fmagento-coding-standard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagento%2Fmagento-coding-standard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagento%2Fmagento-coding-standard/lists"}