|
1 | 1 | # Magento Coding Standard
|
2 | 2 |
|
3 |
| -A set of Magento rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) tool. |
| 3 | +A set of Magento rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) tool. |
4 | 4 |
|
5 |
| -## Goals |
| 5 | +### Installation |
| 6 | +For development puposes you can install Magento Coding Standard by cloning this GitHub repo |
| 7 | +``` |
| 8 | +$ git clone [email protected]:magento/magento-coding-standard.git |
| 9 | +$ cd magento-coding-standard |
| 10 | +$ composer install |
| 11 | +``` |
| 12 | +It is possible also to install a standalone application via [Composer](https://getcomposer.org) |
| 13 | +``` |
| 14 | +$ composer create-project magento/magento-coding-standard --stability=dev magento-coding-standard |
| 15 | +``` |
| 16 | +Or require `magento/magento-coding-standard` inside your project using `composer require` command. |
6 | 17 |
|
7 |
| -1. Make it easier to run static checks for core project contributors and extensions developers. |
8 |
| -2. Store all Magento 2 sniffs in one place. |
9 |
| -3. Make static check consistent. |
| 18 | +#### Verify installation |
| 19 | +Command should return the list of installed coding standards including Magento. |
| 20 | +``` |
| 21 | +$ bin/phpcs -i |
| 22 | +``` |
| 23 | +### Usage |
| 24 | +Once installed, you can run `phpcs` from the command-line to analyse your code `MyAwesomeExtension` |
| 25 | +``` |
| 26 | +$ bin/phpcs --standard=Magento app/code/MyAwesomeExtension |
| 27 | +``` |
| 28 | +## Where to contribute |
| 29 | +- Documentation of existing rules. See [ExtDN PHP CodeSniffer rules for Magento 2](https://github.com/extdn/extdn-phpcs) as a good example. |
| 30 | +- Bug fixes and improvements of existing rules. |
| 31 | +- Creation of new PHP CodeSniffer rules. |
| 32 | +- Discussions on new rules (through periodic hangouts or discussions per GitHub issue). |
| 33 | + |
| 34 | +## How to contribute |
| 35 | +1) 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. |
| 36 | +2) Didn't satisfy your requirements? [Create one of three types of issues](https://github.com/magento/magento-coding-standard/issues/new/choose): |
| 37 | + - **Bug report** - Found a bug in the code? Let us know! |
| 38 | + - **Existing rule enhancement** - Know how to improve existing rules? Open an issue describe how to enhance Magento Coding Standard. |
| 39 | + - **New rule proposal** - Know how to improve Magento ecosystem code quality? Do not hesitate to open a proposal. |
| 40 | +3) 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. |
| 41 | + |
| 42 | +## Testing |
| 43 | +All 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`. |
| 44 | +You can verify your code by running |
| 45 | +``` |
| 46 | +$ bin/phpunit |
| 47 | +``` |
0 commit comments