Skip to content

Commit e8f1ee4

Browse files
committed
use PSR-2 coding standard (for now) #4
* require squizlabs/php_codesniffer * add .phpcs.xml * update README.md * add composer scripts for validations * ignore .phpcs.xml on git export
1 parent 1a4da8d commit e8f1ee4

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
.gitattributes export-ignore
33
.github export-ignore
44
.gitignore export-ignore
5+
.phpcs.xml export-ignore
56
composer.* export-ignore
67
README.md export-ignore

.phpcs.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PSR2" namespace="PHP-SAP\Standards">
3+
<description>PHP/SAP PSR2 programming standard</description>
4+
<!-- display progress -->
5+
<arg value="p"/>
6+
<arg value="n"/>
7+
<!-- directories and files to check -->
8+
<file>./src</file>
9+
<!-- Use PSR2 as a standard -->
10+
<rule ref="PSR2">
11+
</rule>
12+
</ruleset>

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44

55
This repository defines interfaces for implementing the [PHP/SAP][phpsap] API.
66

7+
## Coding standards
8+
9+
This project uses [PSR-2] coding standard and [PHP_CodeSniffer] for validations.
10+
In order to validate before a commit, call `vendor/bin/phpcs`.
11+
712
[phpsap]: https://php-sap.github.io
813
[license-mit]: https://img.shields.io/badge/license-MIT-blue.svg
14+
[PSR-2]: https://www.php-fig.org/psr/psr-2/
15+
[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,16 @@
2828
"psr-4": {
2929
"phpsap\\interfaces\\": "src/"
3030
}
31+
},
32+
"require-dev": {
33+
"squizlabs/php_codesniffer": "^3.7"
34+
},
35+
"scripts": {
36+
"phpcs": "vendor/bin/phpcs",
37+
"phpcbf": "vendor/bin/phpcbf"
38+
},
39+
"scripts-descriptions": {
40+
"phpcs": "Run PHP CodeSniffer validations.",
41+
"phpcbf": "Fix errors found by PHP CodeSniffer."
3142
}
3243
}

0 commit comments

Comments
 (0)