Skip to content

Commit e7408af

Browse files
committed
support php-cs-fixer
1 parent 62db1ae commit e7408af

File tree

4 files changed

+219
-2
lines changed

4 files changed

+219
-2
lines changed

.php-cs-fixer.php

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return (new PhpCsFixer\Config())
6+
->setRiskyAllowed(true)
7+
->setRules([
8+
'@PSR2' => true,
9+
'@Symfony' => true,
10+
'@DoctrineAnnotation' => true,
11+
'@PhpCsFixer' => true,
12+
'global_namespace_import' => [
13+
'import_classes' => true,
14+
'import_constants' => true,
15+
'import_functions' => null,
16+
],
17+
'array_indentation' => true,
18+
'array_syntax' => ['syntax' => 'short'],
19+
'binary_operator_spaces' => [
20+
'default' => 'single_space',
21+
],
22+
'blank_line_after_namespace' => true,
23+
'blank_line_after_opening_tag' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => [
26+
'continue',
27+
'return',
28+
],
29+
],
30+
'blank_lines_before_namespace' => true,
31+
'control_structure_braces' => true,
32+
'control_structure_continuation_position' => [
33+
'position' => 'same_line',
34+
],
35+
'curly_braces_position' => [
36+
'control_structures_opening_brace' => 'same_line',
37+
'functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
38+
'anonymous_functions_opening_brace' => 'same_line',
39+
'classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
40+
'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
41+
'allow_single_line_empty_anonymous_classes' => false,
42+
'allow_single_line_anonymous_functions' => false,
43+
],
44+
'cast_spaces' => true,
45+
'class_attributes_separation' => [
46+
'elements' => [
47+
'const' => 'one',
48+
'method' => 'one',
49+
'property' => 'one',
50+
'trait_import' => 'none',
51+
],
52+
],
53+
'class_definition' => [
54+
'multi_line_extends_each_single_line' => true,
55+
'single_item_single_line' => true,
56+
'single_line' => true,
57+
],
58+
'clean_namespace' => true,
59+
'compact_nullable_typehint' => true,
60+
'concat_space' => [
61+
'spacing' => 'one',
62+
],
63+
'constant_case' => ['case' => 'lower'],
64+
'declare_equal_normalize' => true,
65+
'declare_parentheses' => true,
66+
'elseif' => true,
67+
'encoding' => true,
68+
'full_opening_tag' => true,
69+
'fully_qualified_strict_types' => true,
70+
'function_declaration' => true,
71+
'general_phpdoc_tag_rename' => true,
72+
'heredoc_to_nowdoc' => true,
73+
'include' => true,
74+
'increment_style' => ['style' => 'post'],
75+
'indentation_type' => true,
76+
'integer_literal_case' => true,
77+
'lambda_not_used_import' => true,
78+
'linebreak_after_opening_tag' => true,
79+
'line_ending' => true,
80+
'list_syntax' => true,
81+
'lowercase_cast' => true,
82+
'lowercase_keywords' => true,
83+
'lowercase_static_reference' => true,
84+
'magic_method_casing' => true,
85+
'magic_constant_casing' => true,
86+
'method_argument_space' => [
87+
'on_multiline' => 'ignore',
88+
],
89+
'method_chaining_indentation' => true,
90+
'multiline_whitespace_before_semicolons' => [
91+
'strategy' => 'no_multi_line',
92+
],
93+
'native_function_casing' => true,
94+
'native_function_type_declaration_casing' => true,
95+
'no_alias_functions' => true,
96+
'no_alias_language_construct_call' => true,
97+
'no_alternative_syntax' => true,
98+
'no_binary_string' => true,
99+
'no_blank_lines_after_class_opening' => true,
100+
'no_blank_lines_after_phpdoc' => true,
101+
'no_closing_tag' => true,
102+
'no_empty_phpdoc' => true,
103+
'no_empty_statement' => true,
104+
'no_extra_blank_lines' => [
105+
'tokens' => [
106+
'extra',
107+
'throw',
108+
'use',
109+
],
110+
],
111+
'no_leading_import_slash' => true,
112+
'no_leading_namespace_whitespace' => true,
113+
'no_mixed_echo_print' => [
114+
'use' => 'echo',
115+
],
116+
'no_multiline_whitespace_around_double_arrow' => true,
117+
'no_multiple_statements_per_line' => true,
118+
'no_short_bool_cast' => true,
119+
'no_singleline_whitespace_before_semicolons' => true,
120+
'no_spaces_after_function_name' => true,
121+
'no_space_around_double_colon' => true,
122+
'no_spaces_around_offset' => [
123+
'positions' => ['inside', 'outside'],
124+
],
125+
'no_spaces_inside_parenthesis' => true,
126+
'no_superfluous_phpdoc_tags' => [
127+
'allow_mixed' => true,
128+
'allow_unused_params' => true,
129+
],
130+
'no_trailing_comma_in_singleline' => true,
131+
'no_trailing_whitespace' => true,
132+
'no_trailing_whitespace_in_comment' => true,
133+
'no_unneeded_control_parentheses' => [
134+
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
135+
],
136+
'no_unneeded_curly_braces' => true,
137+
'no_unset_cast' => true,
138+
'no_unused_imports' => true,
139+
'no_unreachable_default_argument_value' => true,
140+
'no_useless_return' => true,
141+
'no_whitespace_before_comma_in_array' => true,
142+
'no_whitespace_in_blank_line' => true,
143+
'normalize_index_brace' => true,
144+
'not_operator_with_successor_space' => true,
145+
'nullable_type_declaration' => true,
146+
'nullable_type_declaration_for_default_null_value' => [
147+
'use_nullable_type_declaration' => false,
148+
],
149+
'object_operator_without_whitespace' => true,
150+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
151+
'psr_autoloading' => false,
152+
'phpdoc_indent' => true,
153+
'phpdoc_inline_tag_normalizer' => true,
154+
'phpdoc_no_access' => true,
155+
'phpdoc_no_package' => true,
156+
'phpdoc_no_useless_inheritdoc' => true,
157+
'phpdoc_order' => [
158+
'order' => ['param', 'return', 'throws'],
159+
],
160+
'phpdoc_scalar' => true,
161+
'phpdoc_separation' => [
162+
'groups' => [
163+
['deprecated', 'link', 'see', 'since'],
164+
['author', 'copyright', 'license'],
165+
['category', 'package', 'subpackage'],
166+
['property', 'property-read', 'property-write'],
167+
['param', 'return'],
168+
],
169+
],
170+
'phpdoc_single_line_var_spacing' => true,
171+
'phpdoc_summary' => false,
172+
'phpdoc_to_comment' => false,
173+
'phpdoc_tag_type' => [
174+
'tags' => [
175+
'inheritdoc' => 'inline',
176+
],
177+
],
178+
'phpdoc_trim' => true,
179+
'phpdoc_types' => true,
180+
'phpdoc_var_without_name' => true,
181+
'return_type_declaration' => ['space_before' => 'none'],
182+
'self_accessor' => false,
183+
'self_static_accessor' => true,
184+
'short_scalar_cast' => true,
185+
'simplified_null_return' => false,
186+
'single_blank_line_at_eof' => true,
187+
'single_class_element_per_statement' => [
188+
'elements' => ['const', 'property'],
189+
],
190+
'single_import_per_statement' => true,
191+
'single_line_after_imports' => true,
192+
'single_line_comment_style' => [
193+
'comment_types' => ['hash'],
194+
],
195+
'single_quote' => true,
196+
'single_space_around_construct' => true,
197+
'space_after_semicolon' => true,
198+
'standardize_not_equals' => true,
199+
'statement_indentation' => true,
200+
'switch_case_semicolon_to_colon' => true,
201+
'switch_case_space' => true,
202+
'ternary_operator_spaces' => true,
203+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
204+
'trim_array_spaces' => true,
205+
'type_declaration_spaces' => true,
206+
'types_spaces' => true,
207+
'unary_operator_spaces' => true,
208+
'visibility_required' => [
209+
'elements' => ['method', 'property'],
210+
],
211+
'whitespace_after_comma_in_array' => true,
212+
]);

app/Controller/Index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

33
declare(strict_types=1);
4+
45
namespace App\Controller;
6+
57
use MicroPHP\Framework\Controller;
68
use MicroPHP\Framework\Http\Response;
79
use MicroPHP\Framework\Http\ServerRequest;
@@ -12,4 +14,4 @@ public function index(ServerRequest $request): Response
1214
{
1315
return $this->json('Hello World');
1416
}
15-
}
17+
}

app/Middleware/NothingMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
1515
{
1616
return $handler->handle($request);
1717
}
18-
}
18+
}

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"php": ">=8.0",
1717
"microphp/framework": "dev-master"
1818
},
19+
"require-dev": {
20+
"friendsofphp/php-cs-fixer": "^3.22.0"
21+
},
1922
"minimum-stability": "dev",
2023
"prefer-stable": true
2124
}

0 commit comments

Comments
 (0)