Skip to content

Commit 0730277

Browse files
committed
Add Composer scripts for code sniffing and autofixing
There now are the following new Composer scripts: - `ci`: run all CI-related Composer scripts - `ci:static` run the static code analysis - `ci:php:sniff` run PHP_CodeSniffer - `fix:php` fix the autofixable PHP code warnings - `fix:php:sniff` fix the autofixable PHP_CodeSniffer warnings For starters, we have a sniff that checks for the PSR-12 standard. (The CI builds do not run this check as the files are not PSR-12 compliant yet at this point.)
1 parent 2a2a167 commit 0730277

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
/.github/ export-ignore
33
/.gitignore export-ignore
44
/Doxyfile export-ignore
5+
/phive.xml
6+
/phpcs.xml export-ignore
57
/phpunit.xml export-ignore
68
/tests export-ignore
9+
/tools/ export-ignore binary

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/.php_cs.cache
12
/composer.lock
3+
/tools/*
24
/vendor/

composer.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,18 @@
1717
},
1818
"autoload": {
1919
"psr-4": { "Sabberworm\\CSS\\": "lib/Sabberworm/CSS/" }
20+
},
21+
"scripts": {
22+
"ci": [
23+
"@ci:static"
24+
],
25+
"ci:php:sniff": "@php ./tools/phpcs.phar lib tests",
26+
"ci:static": [
27+
"@ci:php:sniff"
28+
],
29+
"fix:php": [
30+
"@fix:php:sniff"
31+
],
32+
"fix:php:sniff": "@php ./tools/phpcbf.phar lib tests"
2033
}
2134
}

phive.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="phpcbf" version="^3.6.0" location="./tools/phpcbf.phar" copy="false" installed="3.6.0"/>
4+
<phar name="phpcs" version="^3.6.0" location="./tools/phpcs.phar" copy="false" installed="3.6.0"/>
5+
</phive>

phpcs.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="phpList Coding Standard">
3+
<description>
4+
This standard requires PHP_CodeSniffer >= 3.6.0.
5+
</description>
6+
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
10+
<!-- The complete PSR-12 ruleset -->
11+
<rule ref="PSR12">
12+
<!-- Exclude a rule that requires PHP >= 7.1. -->
13+
<exclude name="PSR12.Properties.ConstantVisibility"/>
14+
</rule>
15+
</ruleset>

0 commit comments

Comments
 (0)