Skip to content

Commit 2eb96e1

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 50ecb4b commit 2eb96e1

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/.gitattributes export-ignore
22
/.github/ export-ignore
33
/.gitignore export-ignore
4+
/.phive/
45
/Doxyfile export-ignore
6+
/phpcs.xml export-ignore
57
/phpunit.xml export-ignore
68
/tests export-ignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
/.phive/*
2+
/.php_cs.cache
13
/composer.lock
24
/vendor/
5+
!/.phive/phars.xml

.phive/phars.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="./.phive/phpcbf.phar" copy="false" installed="3.6.0"/>
4+
<phar name="phpcs" version="^3.6.0" location="./.phive/phpcs.phar" copy="false" installed="3.6.0"/>
5+
</phive>

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 ./.phive/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 ./.phive/phpcbf.phar lib tests"
2033
}
2134
}

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)