Skip to content

Commit efc16f9

Browse files
authored
Add php-cs-fixer & fix code-style
Add php-cs-fixer & fix code-style
2 parents 62a8371 + 81c83fb commit efc16f9

File tree

8 files changed

+875
-34
lines changed

8 files changed

+875
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor
2+
/.php_cs.cache

.php_cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__.DIRECTORY_SEPARATOR.'src')
5+
;
6+
7+
return PhpCsFixer\Config::create()
8+
->setRiskyAllowed(true)
9+
->setRules([
10+
'@PHP71Migration' => true,
11+
'@Symfony' => true,
12+
'array_syntax' => ['syntax' => 'short'],
13+
'no_superfluous_elseif' => true,
14+
'no_superfluous_phpdoc_tags' => true,
15+
'no_unreachable_default_argument_value' => true,
16+
'no_useless_else' => true,
17+
'no_useless_return' => true,
18+
'ordered_imports' => [
19+
'importsOrder' => null,
20+
'sortAlgorithm' => 'alpha',
21+
],
22+
'phpdoc_order' => true,
23+
'yoda_style' => null,
24+
// risky -->
25+
'strict_param' => true,
26+
])
27+
->setFinder($finder)
28+
;

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"require-dev": {
99
"phpunit/phpunit": "^7.0",
1010
"phpstan/phpstan-phpunit": "^0.10",
11-
"phpstan/phpstan": "^0.10.3"
11+
"phpstan/phpstan": "^0.10.3",
12+
"friendsofphp/php-cs-fixer": "^2.13"
1213
},
1314
"autoload": {
1415
"psr-4": {
@@ -28,9 +29,12 @@
2829
}
2930
],
3031
"scripts": {
32+
"check-cs": "php-cs-fixer fix --dry-run --diff",
33+
"fix-cs": "php-cs-fixer fix",
3134
"tests": "phpunit",
3235
"stan": "phpstan analyse -l max -c ./phpstan.neon ./src ./tests",
3336
"check": [
37+
"@check-cs",
3438
"@tests",
3539
"@stan"
3640
]

0 commit comments

Comments
 (0)