Skip to content

Commit 2c91c13

Browse files
committed
build: #2 phpcs and phpmd
1 parent 3b0d078 commit 2c91c13

File tree

5 files changed

+730
-2
lines changed

5 files changed

+730
-2
lines changed

.git-pre-commit

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
4+
FILES=$(git diff --diff-filter=d --name-only HEAD | { grep '.php$' || true; })
5+
for file in $FILES; do
6+
./vendor/bin/phpcs --extensions=php --standard=PSR12 "$file"
7+
./vendor/bin/phpmd "$file" text phpmd.xml
8+
done
9+
./vendor/bin/phpunit tests/

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.phpunit.result.cache
2+
coverage.xml
3+
/.idea/
4+
/vendor/

composer.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@
99
},
1010
"require-dev": {
1111
"fakerphp/faker": "^1.16",
12-
"phpunit/phpunit": "^9.5"
12+
"phpmd/phpmd": "^2.10",
13+
"phpunit/phpunit": "^9.5",
14+
"squizlabs/php_codesniffer": "^3.6"
1315
},
1416
"license": "Apache-2.0",
1517
"autoload": {
1618
"psr-4": { "Coding\\": "src/" }
1719
},
1820
"autoload-dev": {
1921
"psr-4": { "Coding\\Tests\\": "tests/" }
22+
},
23+
"scripts": {
24+
"post-install-cmd": [
25+
"php -r \"if (is_dir('.git/hooks/')) {copy('.git-pre-commit', '.git/hooks/pre-commit'); chmod('.git/hooks/pre-commit', 0755);}\""
26+
]
2027
}
2128
}

0 commit comments

Comments
 (0)