Skip to content

Commit 9afe892

Browse files
jrfnlgrogy
authored andcommitted
PHPCS: various improvements
* Composer: update the PHPCS version used to PHPCS 3.5.0+. * PHPCS: add a PHPCS configuration file containing all the common command-line parameters. This file will be automatically picked up by PHPCS and can be overruled locally by a `[.]phpcs.xml` file. * Ant: remove the configuration CLI arguments which are now contained in the `phpcs.xml.dist` file from the `build.xml` task configuration. * Ant: add a CLI argument which will ignore CS warnings when determining the exit code, but will still _show_ warnings in the report. Using this will also allow for enabling `failonerror` for the build step. * Git: Add the `phpcs.xml.dist` file to the `.gitattributes` file to be ignored when packaging a release. * Git: Add the potential local overload files to the `.gitignore` file.
1 parent ab5e0be commit 9afe892

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.travis.yml export-ignore
55
build.xml export-ignore
66
phpunit.xml.dist export-ignore
7+
phpcs.xml.dist export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ build
22
vendor
33
composer.lock
44
phpunit.xml
5+
.phpcs.xml
6+
phpcs.xml

build.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@
5252
<target name="phpcs" depends="prepare" description="Check PHP code style">
5353
<delete file="${basedir}/build/logs/checkstyle.xml" quiet="true" />
5454

55-
<exec executable="${phpcs}">
56-
<arg line='--extensions=php' />
57-
<arg line='--standard="${basedir}/vendor/php-parallel-lint/php-code-style/ruleset.xml"' />
55+
<exec executable="${phpcs}" failonerror="true">
5856
<arg line='--report-checkstyle="${basedir}/build/logs/checkstyle.xml"' />
5957
<arg line='--report-full' />
60-
<arg line='"${basedir}/src"' />
58+
<arg line='--runtime-set ignore_warnings_on_exit 1' />
6159
</exec>
6260
</target>
6361

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"phpunit/phpunit": "^4.8.36 || ^5.0 || ^6.0 || ^7.0",
2222
"php-parallel-lint/php-parallel-lint": "^1.0",
2323
"php-parallel-lint/php-var-dump-check": "0.*",
24-
"squizlabs/php_codesniffer": "1.*",
24+
"squizlabs/php_codesniffer": "3.*",
2525
"php-parallel-lint/php-code-style": "1.0"
2626
},
2727
"replace": {

phpcs.xml.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Jakub Onderka Coding Standard">
3+
<description>A coding standard for Jakub Onderka's projects.</description>
4+
5+
<file>./src/</file>
6+
7+
<!-- Only check PHP files. -->
8+
<arg name="extensions" value="php"/>
9+
10+
<!-- Show progress, show the error codes for each message (source). -->
11+
<arg value="ps"/>
12+
13+
<!-- Strip the filepaths down to the relevant bit. -->
14+
<arg name="basepath" value="./"/>
15+
16+
<rule ref="./vendor/php-parallel-lint/php-code-style/ruleset.xml"/>
17+
18+
</ruleset>

0 commit comments

Comments
 (0)