Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install phpcs using Composer #1022

Merged
merged 9 commits into from
Jun 6, 2017
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,.travis.yml}]
[{*.json,*.yml}]
indent_style = space
indent_size = 2

Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ before_script:
fi
- |
if [[ "$TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
composer install
fi

script:
Expand All @@ -58,7 +57,7 @@ script:
fi
- |
if [[ "$TRAVISCI" == "phpcs" ]] ; then
phpcs
./vendor/bin/phpcs
fi
- |
if [[ "$TRAVISCI" == "js" ]] ; then
Expand Down
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"require-dev": {
"squizlabs/php_codesniffer": "2.9.x",
"wp-coding-standards/wpcs": "^0.11.0"
},
"scripts": {
"post-install-cmd": [
"phpcs --config-set installed_paths ../../wp-coding-standards/wpcs/"
]
}
}
132 changes: 132 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 4 additions & 25 deletions docs/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,7 @@ When making any changes to the PHP code in this project, it's recommended to
install and run `phpcs` on your computer. This is a step in our Travis CI
build as well, but it is better to catch errors locally.

You will need to install `phpcs` version 2.9.x, because the 3.x versions are
not yet compatible with the WordPress coding standards. For more information see
[this issue](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/718).

The easiest way to get `phpcs` is to download the .phar archive from the latest
2.9.x release on GitHub:
[PHP\_CodeSniffer releases](https://github.com/squizlabs/PHP_CodeSniffer/releases).

For example:

```sh
wget \
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.1/phpcs.phar \
-O ~/bin/phpcs
chmod +x ~/bin/phpcs
```

(If `~/bin` is not in your `$PATH`, pick another directory that is.)

Then you must install the `WordPress-Coding-Standards` repository and tell
`phpcs` where it lives. See instructions here:

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#standalone

You should now be able to run `phpcs` from the root directory of this project.
The easiest way to do this is using `composer`.
[Install `composer`](https://getcomposer.org/download/)
on your computer, then run `composer install`. This will install `phpcs` and
`WordPress-Coding-Standards` which you can the run via `vendor/bin/phpcs`.
3 changes: 2 additions & 1 deletion vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.js
*
!.gitignore