Skip to content

Commit 7c9cfe4

Browse files
authored
Install phpcs using Composer (WordPress#1022)
1 parent ccbb343 commit 7c9cfe4

File tree

6 files changed

+152
-30
lines changed

6 files changed

+152
-30
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010

11-
[{package.json,.travis.yml}]
11+
[{*.json,*.yml}]
1212
indent_style = space
1313
indent_size = 2
1414

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ before_script:
4444
fi
4545
- |
4646
if [[ "$TRAVISCI" == "phpcs" ]] ; then
47-
composer global require wp-coding-standards/wpcs
48-
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
47+
composer install
4948
fi
5049
5150
script:
@@ -58,7 +57,7 @@ script:
5857
fi
5958
- |
6059
if [[ "$TRAVISCI" == "phpcs" ]] ; then
61-
phpcs
60+
./vendor/bin/phpcs
6261
fi
6362
- |
6463
if [[ "$TRAVISCI" == "js" ]] ; then

composer.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"require-dev": {
3+
"squizlabs/php_codesniffer": "2.9.x",
4+
"wp-coding-standards/wpcs": "^0.11.0"
5+
},
6+
"scripts": {
7+
"post-install-cmd": [
8+
"phpcs --config-set installed_paths ../../wp-coding-standards/wpcs/"
9+
]
10+
}
11+
}

composer.lock

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/coding-guidelines.md

+4-25
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,7 @@ When making any changes to the PHP code in this project, it's recommended to
9292
install and run `phpcs` on your computer. This is a step in our Travis CI
9393
build as well, but it is better to catch errors locally.
9494

95-
You will need to install `phpcs` version 2.9.x, because the 3.x versions are
96-
not yet compatible with the WordPress coding standards. For more information see
97-
[this issue](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/718).
98-
99-
The easiest way to get `phpcs` is to download the .phar archive from the latest
100-
2.9.x release on GitHub:
101-
[PHP\_CodeSniffer releases](https://github.com/squizlabs/PHP_CodeSniffer/releases).
102-
103-
For example:
104-
105-
```sh
106-
wget \
107-
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.1/phpcs.phar \
108-
-O ~/bin/phpcs
109-
chmod +x ~/bin/phpcs
110-
```
111-
112-
(If `~/bin` is not in your `$PATH`, pick another directory that is.)
113-
114-
Then you must install the `WordPress-Coding-Standards` repository and tell
115-
`phpcs` where it lives. See instructions here:
116-
117-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#standalone
118-
119-
You should now be able to run `phpcs` from the root directory of this project.
95+
The easiest way to do this is using `composer`.
96+
[Install `composer`](https://getcomposer.org/download/)
97+
on your computer, then run `composer install`. This will install `phpcs` and
98+
`WordPress-Coding-Standards` which you can the run via `vendor/bin/phpcs`.

vendor/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.js
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)