Skip to content

Commit 16074fe

Browse files
committed
Fixed missing .php_cs configuration file
1 parent 85d0900 commit 16074fe

File tree

1 file changed

+224
-0
lines changed

1 file changed

+224
-0
lines changed

.php_cs

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->files()
5+
->in([
6+
__DIR__ . '/src',
7+
__DIR__ . '/tests'
8+
])
9+
->notName('*.phpt');
10+
11+
if (!\file_exists(__DIR__ . '/var')) {
12+
\mkdir(__DIR__ . '/var');
13+
}
14+
15+
/**
16+
* This configuration was taken from https://github.com/sebastianbergmann/phpunit/blob/master/.php_cs.dist
17+
* and slightly adjusted.
18+
*/
19+
return PhpCsFixer\Config::create()
20+
->setRiskyAllowed(true)
21+
->setCacheFile(__DIR__.'/var/.php_cs.cache')
22+
->setRules([
23+
'align_multiline_comment' => true,
24+
'array_indentation' => true,
25+
'array_syntax' => ['syntax' => 'short'],
26+
'blank_line_after_namespace' => true,
27+
'blank_line_before_statement' => [
28+
'statements' => [
29+
'break',
30+
'continue',
31+
'declare',
32+
'default',
33+
'die',
34+
'do',
35+
'exit',
36+
'for',
37+
'foreach',
38+
'goto',
39+
'if',
40+
'include',
41+
'include_once',
42+
'require',
43+
'require_once',
44+
'return',
45+
'switch',
46+
'throw',
47+
'try',
48+
'while',
49+
],
50+
],
51+
'braces' => true,
52+
'cast_spaces' => true,
53+
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
54+
'combine_consecutive_issets' => true,
55+
'combine_consecutive_unsets' => true,
56+
'compact_nullable_typehint' => true,
57+
'concat_space' => ['spacing' => 'one'],
58+
'constant_case' => true,
59+
'declare_equal_normalize' => ['space' => 'none'],
60+
'declare_strict_types' => true,
61+
'dir_constant' => true,
62+
'elseif' => true,
63+
'encoding' => true,
64+
'explicit_indirect_variable' => true,
65+
'explicit_string_variable' => true,
66+
'full_opening_tag' => true,
67+
'fully_qualified_strict_types' => true,
68+
'function_typehint_space' => true,
69+
'function_declaration' => true,
70+
'global_namespace_import' => [
71+
'import_classes' => false,
72+
'import_constants' => false,
73+
'import_functions' => false,
74+
],
75+
'heredoc_to_nowdoc' => true,
76+
'increment_style' => [
77+
'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
78+
],
79+
'indentation_type' => true,
80+
'is_null' => true,
81+
'line_ending' => true,
82+
'list_syntax' => ['syntax' => 'short'],
83+
'logical_operators' => true,
84+
'lowercase_keywords' => true,
85+
'lowercase_static_reference' => true,
86+
'magic_constant_casing' => true,
87+
'magic_method_casing' => true,
88+
'method_argument_space' => ['ensure_fully_multiline' => true],
89+
'modernize_types_casting' => false,
90+
'multiline_comment_opening_closing' => true,
91+
'multiline_whitespace_before_semicolons' => true,
92+
'native_constant_invocation' => false,
93+
'native_function_casing' => false,
94+
'native_function_invocation' => true,
95+
'native_function_type_declaration_casing' => true,
96+
'new_with_braces' => false,
97+
'no_alias_functions' => true,
98+
'no_alternative_syntax' => true,
99+
'no_blank_lines_after_class_opening' => true,
100+
'no_blank_lines_after_phpdoc' => true,
101+
'no_blank_lines_before_namespace' => false,
102+
'no_closing_tag' => true,
103+
'no_empty_comment' => true,
104+
'no_empty_phpdoc' => true,
105+
'no_empty_statement' => true,
106+
'no_extra_blank_lines' => true,
107+
'no_homoglyph_names' => true,
108+
'no_leading_import_slash' => true,
109+
'no_leading_namespace_whitespace' => true,
110+
'no_mixed_echo_print' => ['use' => 'print'],
111+
'no_multiline_whitespace_around_double_arrow' => true,
112+
'no_null_property_initialization' => true,
113+
'no_php4_constructor' => true,
114+
'no_short_bool_cast' => true,
115+
'no_short_echo_tag' => true,
116+
'no_singleline_whitespace_before_semicolons' => true,
117+
'no_spaces_after_function_name' => true,
118+
'no_spaces_around_offset' => true,
119+
'no_spaces_inside_parenthesis' => true,
120+
'no_superfluous_elseif' => true,
121+
'no_superfluous_phpdoc_tags' => false,
122+
'no_trailing_comma_in_list_call' => true,
123+
'no_trailing_comma_in_singleline_array' => true,
124+
'no_trailing_whitespace' => true,
125+
'no_trailing_whitespace_in_comment' => true,
126+
'no_unneeded_control_parentheses' => true,
127+
'no_unneeded_curly_braces' => true,
128+
'no_unneeded_final_method' => true,
129+
'no_unreachable_default_argument_value' => true,
130+
'no_unset_on_property' => true,
131+
'no_unused_imports' => true,
132+
'no_useless_else' => true,
133+
'no_useless_return' => true,
134+
'no_whitespace_before_comma_in_array' => true,
135+
'no_whitespace_in_blank_line' => true,
136+
'non_printable_character' => true,
137+
'normalize_index_brace' => true,
138+
'object_operator_without_whitespace' => true,
139+
'ordered_class_elements' => [
140+
'order' => [
141+
'use_trait',
142+
'constant_public',
143+
'constant_protected',
144+
'constant_private',
145+
'property_public_static',
146+
'property_protected_static',
147+
'property_private_static',
148+
'property_public',
149+
'property_protected',
150+
'property_private',
151+
'construct',
152+
'method_public_static',
153+
'destruct',
154+
'magic',
155+
'phpunit',
156+
'method_public',
157+
'method_protected',
158+
'method_private',
159+
'method_protected_static',
160+
'method_private_static',
161+
],
162+
],
163+
'ordered_imports' => [
164+
'imports_order' => [
165+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
166+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
167+
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
168+
]
169+
],
170+
'ordered_interfaces' => [
171+
'direction' => 'ascend',
172+
'order' => 'alpha',
173+
],
174+
'phpdoc_add_missing_param_annotation' => false,
175+
'phpdoc_align' => ['align' => 'left'],
176+
'phpdoc_annotation_without_dot' => true,
177+
'phpdoc_indent' => true,
178+
'phpdoc_no_access' => true,
179+
'phpdoc_no_empty_return' => true,
180+
'phpdoc_no_package' => true,
181+
'phpdoc_order' => true,
182+
'phpdoc_return_self_reference' => true,
183+
'phpdoc_scalar' => true,
184+
'phpdoc_separation' => true,
185+
'phpdoc_single_line_var_spacing' => true,
186+
'phpdoc_summary' => true,
187+
'phpdoc_to_comment' => false,
188+
'phpdoc_trim' => true,
189+
'phpdoc_trim_consecutive_blank_line_separation' => true,
190+
'phpdoc_types' => ['groups' => ['simple', 'meta']],
191+
'phpdoc_types_order' => true,
192+
'phpdoc_var_without_name' => true,
193+
'pow_to_exponentiation' => true,
194+
'protected_to_private' => true,
195+
'return_assignment' => true,
196+
'return_type_declaration' => ['space_before' => 'one'],
197+
'self_accessor' => true,
198+
'self_static_accessor' => true,
199+
'semicolon_after_instruction' => true,
200+
'set_type_to_cast' => true,
201+
'short_scalar_cast' => true,
202+
'simple_to_complex_string_variable' => true,
203+
'simplified_null_return' => false,
204+
'single_blank_line_at_eof' => true,
205+
'single_import_per_statement' => true,
206+
'single_line_after_imports' => true,
207+
'single_quote' => true,
208+
'standardize_not_equals' => true,
209+
'strict_param' => true,
210+
'ternary_to_null_coalescing' => true,
211+
'trailing_comma_in_multiline_array' => true,
212+
'trim_array_spaces' => true,
213+
'unary_operator_spaces' => true,
214+
'visibility_required' => [
215+
'elements' => [
216+
'const',
217+
'method',
218+
'property',
219+
],
220+
],
221+
'void_return' => true,
222+
'whitespace_after_comma_in_array' => true,
223+
])
224+
->setFinder($finder);

0 commit comments

Comments
 (0)