Skip to content

Commit

Permalink
Build/PHPCS: Rename PHPCS configuration file
Browse files Browse the repository at this point in the history
This rename has two functions:
1. Using a `.dist` extension allows for individual developers to overload the `phpcs.xml.dist` with a local `phpcs.xml` file. This file can include the `dist` file as a base ruleset using `<rule ref="./phpcs.xml.dist"/>`.
2. Since [PHPCS 3.1.0](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.1.0) allows for config files to start with a `.`.
    We can use this feature to have a separate ruleset for the Free and the Premium plugin.
    The loading order of the files is `.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist`, `phpcs.xml.dist` (as of [PHPCS 3.1.1](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.1.1)).
    By naming the config file for WPSEO Free `phpcs.xml.dist`, we can automatically overrule that config in the Premium plugin by having the Premium PHPCS config be called `.phpcs.xml.dist`.

To facilitate (1), the typical file names for the overloaded PHPCS config files have been added to the `.gitignore` and `.gitattributes` files.
  • Loading branch information
jrfnl committed Dec 21, 2018
1 parent fbf8c1c commit ba8ce19
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ webpack export-ignore
.travis.yml export-ignore
Gruntfile.js export-ignore
package.json export-ignore
.phpcs.xml export-ignore
phpcs.xml export-ignore
.phpcs.xml.dist export-ignore
phpcs.xml.dist export-ignore
phpdoc.xml export-ignore
phpdoc.dist.xml export-ignore
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ nbproject/
node_modules/
bower_components/
premium/node_modules/
phpcs.xml
.phpcs.xml

############
## OSes
Expand Down
2 changes: 1 addition & 1 deletion grunt/config/phpcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
plugin: {
options: {
bin: "vendor/bin/phpcs",
standard: "phpcs.xml",
standard: "phpcs.xml.dist",
extensions: "php",
},
dir: [
Expand Down
File renamed without changes.

0 comments on commit ba8ce19

Please sign in to comment.