Skip to content

Add Composer scripts for code sniffing and autofixing #218

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

Merged
merged 1 commit into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.phive/
/Doxyfile export-ignore
/phpcs.xml export-ignore
/phpunit.xml export-ignore
/tests export-ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.phive/*
/.php_cs.cache
/composer.lock
/vendor/
!/.phive/phars.xml
5 changes: 5 additions & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpcbf" version="^3.6.0" location="./.phive/phpcbf.phar" copy="false" installed="3.6.0"/>
<phar name="phpcs" version="^3.6.0" location="./.phive/phpcs.phar" copy="false" installed="3.6.0"/>
</phive>
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,18 @@
},
"autoload": {
"psr-4": { "Sabberworm\\CSS\\": "lib/Sabberworm/CSS/" }
},
"scripts": {
"ci": [
"@ci:static"
],
"ci:php:sniff": "@php ./.phive/phpcs.phar lib tests",
"ci:static": [
"@ci:php:sniff"
],
"fix:php": [
"@fix:php:sniff"
],
"fix:php:sniff": "@php ./.phive/phpcbf.phar lib tests"
}
}
15 changes: 15 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="phpList Coding Standard">
<description>
This standard requires PHP_CodeSniffer >= 3.6.0.
</description>

<arg name="colors"/>
<arg name="extensions" value="php"/>

<!-- The complete PSR-12 ruleset -->
<rule ref="PSR12">
Comment on lines +9 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be useful to add the PHPCompatibility sniffs to make sure that PHP 5.6 features are used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably will be a bit more work to get those to run with a PHIVE-based installation. Please let's do this in a separate PR. (I can do that.)

<!-- Exclude a rule that requires PHP >= 7.1. -->
<exclude name="PSR12.Properties.ConstantVisibility"/>
</rule>
</ruleset>