|
1 | 1 | # phpMyAdmin Coding Standard
|
2 | 2 |
|
3 |
| -phpMyAdmin Coding Standard for PHP CodeSniffer. |
| 3 | +phpMyAdmin Coding Standard is a set of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules and is based on the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard). |
4 | 4 |
|
5 |
| -## Installation & Usage |
| 5 | +## Installation |
6 | 6 |
|
7 |
| -### Manual installation |
8 |
| -Before starting using our coding standard install [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). |
9 |
| - |
10 |
| -Clone or download this repo somewhere on your computer or install it with [Composer](https://getcomposer.org/). |
11 |
| -To do so, add the dependency to your `composer.json` file by running `composer require --dev phpmyadmin/coding-standard`. |
12 |
| - |
13 |
| -### Automatic installation with Composer |
14 |
| -Much easier, however, is to use Composer to install the necessary files automatically. |
15 |
| -Using the development version of phpMyAdmin from git requires using Composer, so the dependencies are already set |
16 |
| -in `composer.json` using the 'require-dev' section. Depending on your system, this will either be installed |
17 |
| -automatically unless you use `--no-dev` option or composer must be run with `--dev`. Regardless of your composer |
18 |
| -version, using `--dev` will always install the 'require-dev' dependencies, so we recomment using Composer with that |
19 |
| -option. |
20 |
| - |
21 |
| -### Final configuration |
22 |
| -Add the standards directory to PHP_CodeSniffer installed paths. You probably have to use the full/absolute path |
23 |
| -rather than a relative one, otherwise you will get an "Unexpected Value Exception": |
24 |
| - |
25 |
| -```sh |
26 |
| -$ phpcs --config-set installed_paths /var/www/html/phpmyadmin/vendor/phpmyadmin/coding-standard |
27 |
| -``` |
28 |
| - |
29 |
| -You can verify whether the standard can be found: |
30 |
| - |
31 |
| -```sh |
32 |
| -$ phpcs -i |
33 |
| -The installed coding standards are MySource, PSR1, PHPCS, Zend, Squiz, PEAR, PSR2 and PhpMyAdmin |
34 | 7 | ```
|
35 |
| - |
36 |
| -Run CodeSniffer: |
37 |
| - |
38 |
| -```sh |
39 |
| -$ phpcs --standard=PhpMyAdmin /path/to/code |
| 8 | +composer require --dev phpmyadmin/coding-standard |
40 | 9 | ```
|
41 | 10 |
|
42 |
| -You can optionally make PhpMyAdmin the default for all invocations of phpcs, then you don't need to |
43 |
| -manually specify it each time on the command line: |
| 11 | +## Usage |
44 | 12 |
|
45 |
| -```sh |
46 |
| -$ phpcs --config-set default_standard PhpMyAdmin |
47 | 13 | ```
|
48 |
| - |
49 |
| -## Using |
50 |
| - |
51 |
| -PhpMyAdmin has its tuned coding style checks, such as missing `@author`, |
52 |
| -`@copyright`, `@link` or other tags. Let's take a look at an example, checked with PhpMyAdmin: |
53 |
| - |
54 |
| -```sh |
55 |
| -$ phpcs --standard=PhpMyAdmin /path/to/code/myfile.php |
56 |
| -123 | WARNING | Line exceeds 85 characters; contains 139 characters |
57 |
| -184 | ERROR | Line indented incorrectly; expected at least 20 spaces, found |
58 |
| - | | 16 |
59 |
| -272 | ERROR | Closing parenthesis of a multi-line IF statement must be on a |
60 |
| - | | new line |
61 |
| -272 | ERROR | Multi-line IF statement not indented correctly; expected 12 |
62 |
| - | | spaces but found 9 |
| 14 | +vendor/bin/phpcs --standard=PhpMyAdmin /path/to/code |
63 | 15 | ```
|
0 commit comments