├── .gitignore
├── NeutronRuleset
└── ruleset.xml
├── README.md
└── composer.json
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | composer.lock
3 |
--------------------------------------------------------------------------------
/NeutronRuleset/ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Neutron Ruleset.
4 |
5 |
6 |
7 |
8 |
9 | 0
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 0
20 |
21 |
22 | 0
23 |
24 |
25 | 0
26 |
27 |
28 | 0
29 |
30 |
31 | 0
32 |
33 |
34 | 0
35 |
36 |
37 | 0
38 |
39 |
40 | 0
41 |
42 |
43 | 0
44 |
45 |
46 | 0
47 |
48 |
49 | 0
50 |
51 |
52 | warning
53 |
54 |
55 | warning
56 |
57 |
58 | 0
59 |
60 |
61 | error
62 |
63 |
64 | error
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | error
73 |
74 |
75 | 0
76 |
77 |
78 | error
79 |
80 |
81 | 0
82 |
83 |
84 | warning
85 |
86 |
87 | 0
88 |
89 |
90 | 0
91 |
92 |
93 | 0
94 |
95 |
96 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Neutron PHP Ruleset
2 |
3 | These are a set of modern (PHP >7) linting guidelines for WordPress development. Because of the newer PHP version, it is not suitable for work on Core WordPress, but may be useful for those who are not bound by PHP 5.2.
4 |
5 |
6 | > **Warning**
7 | >
8 | > **IMPORTANT NOTE:** This project is no longer actively developed. At Automattic we've switched to using the [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) + [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis).
9 |
10 | -----
11 |
12 | These guidelines are being developed primarily for a team within [Automattic](https://automattic.com/), but anyone is free to use them, suggest changes, or report bugs.
13 |
14 | This project is a [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) "standard" (a collection of rules or "sniffs") that can be included in any project.
15 |
16 | This is a meta-project in that it's just a collection of rules defined in these packages with certain modifications:
17 |
18 | - [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards)
19 | - [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis)
20 | - [NeutronStandard](https://github.com/Automattic/phpcs-neutron-standard)
21 | - [ImportDetection](https://github.com/sirbrillig/phpcs-import-detection)
22 |
23 | ## Installation
24 |
25 | To use these rules in a project which is set up using [composer](https://href.li/?https://getcomposer.org/), we recommend using the [phpcodesniffer-composer-installer library](https://href.li/?https://github.com/DealerDirect/phpcodesniffer-composer-installer) which will automatically use all installed standards in the current project with the composer type `phpcodesniffer-standard` when you run phpcs.
26 |
27 | ```
28 | composer require --dev squizlabs/php_codesniffer dealerdirect/phpcodesniffer-composer-installer
29 | composer require --dev automattic/phpcs-neutron-ruleset
30 | ```
31 |
32 | ## Configuration
33 |
34 | When installing sniff standards in a project, you edit a `phpcs.xml` file with the `rule` tag inside the `ruleset` tag. The `ref` attribute of that tag should specify a standard, category, sniff, or error code to enable. It’s also possible to use these tags to disable or modify certain rules. The [official annotated file](https://href.li/?https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) explains how to do this.
35 |
36 | The following configuration will enable all the sniffs in this ruleset.
37 |
38 | ```xml
39 |
40 |
41 | My library.
42 |
43 |
44 | ```
45 |
46 | ## Usage
47 |
48 | Most editors have a phpcs plugin available, but you can also run phpcs manually. To run phpcs on a file in your project, just use the command-line as follows (the `-s` causes the sniff code to be shown, which is very important for learning about an error).
49 |
50 | ```
51 | vendor/bin/phpcs -s src/MyProject/MyClass.php
52 | ```
53 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automattic/phpcs-neutron-ruleset",
3 | "type": "phpcodesniffer-standard",
4 | "keywords": [ "phpcs", "static analysis" ],
5 | "description": "A PHPCS meta-ruleset for WordPress development",
6 | "license": "MIT",
7 | "require": {
8 | "php": "^7.0 || ^8.0",
9 | "automattic/phpcs-neutron-standard": "^1.5.3",
10 | "sirbrillig/phpcs-import-detection": "^1.1.4",
11 | "sirbrillig/phpcs-variable-analysis": "^2.6.1",
12 | "wp-coding-standards/wpcs": "^2.1.0"
13 | },
14 | "require-dev": {
15 | "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
16 | "squizlabs/php_codesniffer": "^3.4.2"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------