Skip to content

Commit cc06c53

Browse files
committed
feat: add PHP-CS-Fixer configuration and update composer.json for code style fixes
1 parent f4a9e14 commit cc06c53

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ clover.xml
2323

2424
# Ignore PHPUnit cache file
2525
.phpunit.result.cache
26+
27+
# Ignore PHP-CS-Fixer cache file
28+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__)
5+
->exclude('vendor')
6+
->path('lib')
7+
->path('init.php')
8+
->path('build.php');
9+
10+
$config = new PhpCsFixer\Config();
11+
return $config->setRules([
12+
'@PSR12' => true,
13+
'strict_param' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
'no_unused_imports' => true,
16+
])
17+
->setFinder($finder);

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "~5.7 || ~9.5",
25-
"squizlabs/php_codesniffer": "~3.6"
25+
"squizlabs/php_codesniffer": "~3.6",
26+
"friendsofphp/php-cs-fixer": "^3.75"
2627
},
2728
"autoload": {
2829
"psr-4": { "Payjp\\" : "lib/" }
@@ -36,6 +37,9 @@
3637
"test": [
3738
"phpcs --standard=PSR2 -n lib tests *.php",
3839
"phpunit"
40+
],
41+
"fix": [
42+
"PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --allow-risky=yes"
3943
]
4044
}
4145
}

0 commit comments

Comments
 (0)