Skip to content

Commit 5f075e1

Browse files
committed
Install and configure php-cs-fixer
1 parent 656f9df commit 5f075e1

File tree

14 files changed

+2602
-558
lines changed

14 files changed

+2602
-558
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.php_cs.cache
33
/build
44
.phpunit.result.cache
5+
.php-cs.cache

.php-cs-fixer.dist.php

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->exclude(['var', 'vendor'])
6+
;
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@PSR12' => true,
11+
'@PHP80Migration' => true,
12+
'@DoctrineAnnotation' => true,
13+
'align_multiline_comment' => true,
14+
'array_indentation' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'binary_operator_spaces' => true,
17+
'blank_line_after_opening_tag' => true,
18+
'blank_line_before_statement' => true,
19+
'cast_spaces' => ['space' => 'single'],
20+
'class_attributes_separation' => true,
21+
'combine_consecutive_issets' => true,
22+
'combine_consecutive_unsets' => true,
23+
'compact_nullable_typehint' => true,
24+
'concat_space' => ['spacing' => 'none'],
25+
'declare_equal_normalize' => ['space' => 'none'],
26+
'declare_strict_types' => true,
27+
'dir_constant' => true,
28+
'ereg_to_preg' => true,
29+
'explicit_indirect_variable' => true,
30+
'explicit_string_variable' => true,
31+
'final_internal_class' => true,
32+
'fully_qualified_strict_types' => true,
33+
'function_to_constant' => true,
34+
'function_typehint_space' => true,
35+
'include' => true,
36+
'is_null' => true,
37+
'linebreak_after_opening_tag' => true,
38+
'list_syntax' => ['syntax' => 'short'],
39+
'lowercase_cast' => true,
40+
'lowercase_static_reference' => true,
41+
'magic_constant_casing' => true,
42+
'magic_method_casing' => true,
43+
'mb_str_functions' => false,
44+
'method_chaining_indentation' => true,
45+
'multiline_comment_opening_closing' => true,
46+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
47+
'modernize_types_casting' => true,
48+
'native_constant_invocation' => ['scope' => 'all'],
49+
'native_function_casing' => true,
50+
'native_function_invocation' => ['include' => ['@all']],
51+
'new_with_braces' => true,
52+
'no_alias_functions' => true,
53+
'no_alternative_syntax' => true,
54+
'no_binary_string' => true,
55+
'no_blank_lines_after_class_opening' => true,
56+
'no_blank_lines_after_phpdoc' => true,
57+
'no_empty_comment' => true,
58+
'no_empty_phpdoc' => true,
59+
'no_empty_statement' => true,
60+
'no_leading_import_slash' => true,
61+
'no_mixed_echo_print' => ['use' => 'echo'],
62+
'no_multiline_whitespace_around_double_arrow' => true,
63+
'no_null_property_initialization' => false,
64+
'no_short_bool_cast' => true,
65+
'no_singleline_whitespace_before_semicolons' => true,
66+
'no_spaces_after_function_name' => true,
67+
'no_spaces_around_offset' => true,
68+
'no_spaces_inside_parenthesis' => true,
69+
'no_superfluous_elseif' => true,
70+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
71+
'no_trailing_comma_in_list_call' => true,
72+
'no_trailing_comma_in_singleline_array' => true,
73+
'no_unneeded_control_parentheses' => true,
74+
'no_unneeded_curly_braces' => true,
75+
'no_unneeded_final_method' => true,
76+
'no_unreachable_default_argument_value' => false,
77+
'no_unused_imports' => true,
78+
'no_useless_else' => true,
79+
'no_useless_return' => true,
80+
'no_whitespace_before_comma_in_array' => true,
81+
'no_whitespace_in_blank_line' => true,
82+
'non_printable_character' => false,
83+
'object_operator_without_whitespace' => true,
84+
'ordered_class_elements' => true,
85+
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
86+
'phpdoc_no_access' => true,
87+
'phpdoc_no_empty_return' => true,
88+
'phpdoc_no_package' => true,
89+
'phpdoc_no_useless_inheritdoc' => true,
90+
'phpdoc_return_self_reference' => true,
91+
'phpdoc_scalar' => true,
92+
'phpdoc_single_line_var_spacing' => true,
93+
'phpdoc_to_comment' => false,
94+
'phpdoc_types' => true,
95+
'phpdoc_var_without_name' => true,
96+
'increment_style' => ['style' => 'post'],
97+
'return_type_declaration' => true,
98+
'semicolon_after_instruction' => true,
99+
'short_scalar_cast' => true,
100+
'single_blank_line_before_namespace' => true,
101+
'single_line_comment_style' => false,
102+
'single_quote' => true,
103+
'space_after_semicolon' => true,
104+
'standardize_not_equals' => true,
105+
'static_lambda' => true,
106+
'strict_comparison' => true,
107+
'strict_param' => true,
108+
'ternary_operator_spaces' => true,
109+
'trim_array_spaces' => true,
110+
'unary_operator_spaces' => true,
111+
'void_return' => true,
112+
'whitespace_after_comma_in_array' => true,
113+
])
114+
->setRiskyAllowed(true)
115+
->setUsingCache(true)
116+
->setCacheFile(__DIR__.'/.php-cs.cache')
117+
->setIndent(' ')
118+
->setLineEnding("\n")
119+
->setFinder($finder)
120+
;

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
],
1212
"require": {
1313
"php": "^8.0",
14-
"react/http": "^0.8.1"
14+
"react/http": "^0.8.1",
15+
"friendsofphp/php-cs-fixer": "^3.8"
1516
},
1617
"require-dev": {
1718
"phpunit/phpunit": "^9.5",
@@ -32,8 +33,8 @@
3233
"@check-cs",
3334
"@tests"
3435
],
35-
"fix-cs": "vendor/bin/ecs check src tests --fix --config=coding-standard.neon",
36-
"check-cs": "vendor/bin/ecs check src tests --config=coding-standard.neon",
36+
"fix-cs": "php-cs-fixer fix --diff --ansi",
37+
"check-cs": "php-cs-fixer fix --dry-run --diff --ansi",
3738
"phpstan": "vendor/bin/phpstan analyse src tests --level=max",
3839
"tests": "vendor/bin/phpunit"
3940
}

0 commit comments

Comments
 (0)