Skip to content

Commit 86ad0b6

Browse files
committed
add php-cs-fixer config
1 parent fee391a commit 86ad0b6

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
composer.phar
66
phpunit.phar
77
composer.lock
8+
.php_cs.cache
89

910
/conf
1011
/.settings

.php_cs

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
3+
// Provided by Laravel Shift: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
8+
$rules = [
9+
'array_syntax' => ['syntax' => 'short'],
10+
'binary_operator_spaces' => [
11+
'default' => 'single_space',
12+
'operators' => ['=>' => null],
13+
],
14+
'blank_line_after_namespace' => true,
15+
'blank_line_after_opening_tag' => true,
16+
'blank_line_before_statement' => [
17+
'statements' => ['return'],
18+
],
19+
'braces' => true,
20+
'cast_spaces' => true,
21+
'class_attributes_separation' => [
22+
'elements' => ['method'],
23+
],
24+
'class_definition' => true,
25+
'concat_space' => [
26+
'spacing' => 'none',
27+
],
28+
'declare_equal_normalize' => true,
29+
'elseif' => true,
30+
'encoding' => true,
31+
'full_opening_tag' => true,
32+
'fully_qualified_strict_types' => true, // added by Shift
33+
'function_declaration' => true,
34+
'function_typehint_space' => true,
35+
'heredoc_to_nowdoc' => true,
36+
'include' => true,
37+
'increment_style' => ['style' => 'post'],
38+
'indentation_type' => true,
39+
'linebreak_after_opening_tag' => true,
40+
'line_ending' => true,
41+
'lowercase_cast' => true,
42+
'lowercase_constants' => true,
43+
'lowercase_keywords' => true,
44+
'lowercase_static_reference' => true, // added from Symfony
45+
'magic_method_casing' => true, // added from Symfony
46+
'magic_constant_casing' => true,
47+
'method_argument_space' => true,
48+
'native_function_casing' => true,
49+
'no_alias_functions' => true,
50+
'no_extra_blank_lines' => [
51+
'tokens' => [
52+
'extra',
53+
'throw',
54+
'use',
55+
'use_trait',
56+
],
57+
],
58+
'no_blank_lines_after_class_opening' => true,
59+
'no_blank_lines_after_phpdoc' => true,
60+
'no_closing_tag' => true,
61+
'no_empty_phpdoc' => true,
62+
'no_empty_statement' => true,
63+
'no_leading_import_slash' => true,
64+
'no_leading_namespace_whitespace' => true,
65+
'no_mixed_echo_print' => [
66+
'use' => 'echo',
67+
],
68+
'no_multiline_whitespace_around_double_arrow' => true,
69+
'multiline_whitespace_before_semicolons' => [
70+
'strategy' => 'no_multi_line',
71+
],
72+
'no_short_bool_cast' => true,
73+
'no_singleline_whitespace_before_semicolons' => true,
74+
'no_spaces_after_function_name' => true,
75+
'no_spaces_around_offset' => true,
76+
'no_spaces_inside_parenthesis' => true,
77+
'no_trailing_comma_in_list_call' => true,
78+
'no_trailing_comma_in_singleline_array' => true,
79+
'no_trailing_whitespace' => true,
80+
'no_trailing_whitespace_in_comment' => true,
81+
'no_unneeded_control_parentheses' => true,
82+
'no_unreachable_default_argument_value' => true,
83+
'no_useless_return' => true,
84+
'no_whitespace_before_comma_in_array' => true,
85+
'no_whitespace_in_blank_line' => true,
86+
'normalize_index_brace' => true,
87+
'not_operator_with_successor_space' => true,
88+
'object_operator_without_whitespace' => true,
89+
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
90+
'phpdoc_indent' => true,
91+
'phpdoc_inline_tag' => true,
92+
'phpdoc_no_access' => true,
93+
'phpdoc_no_package' => true,
94+
'phpdoc_no_useless_inheritdoc' => true,
95+
'phpdoc_scalar' => true,
96+
'phpdoc_single_line_var_spacing' => true,
97+
'phpdoc_summary' => true,
98+
'phpdoc_to_comment' => true,
99+
'phpdoc_trim' => true,
100+
'phpdoc_types' => true,
101+
'phpdoc_var_without_name' => true,
102+
'psr4' => true,
103+
'self_accessor' => true,
104+
'short_scalar_cast' => true,
105+
'simplified_null_return' => false, // disabled by Shift
106+
'single_blank_line_at_eof' => true,
107+
'single_blank_line_before_namespace' => true,
108+
'single_class_element_per_statement' => true,
109+
'single_import_per_statement' => true,
110+
'single_line_after_imports' => true,
111+
'single_line_comment_style' => [
112+
'comment_types' => ['hash'],
113+
],
114+
'single_quote' => true,
115+
'space_after_semicolon' => true,
116+
'standardize_not_equals' => true,
117+
'switch_case_semicolon_to_colon' => true,
118+
'switch_case_space' => true,
119+
'ternary_operator_spaces' => true,
120+
'trailing_comma_in_multiline_array' => true,
121+
'trim_array_spaces' => true,
122+
'unary_operator_spaces' => true,
123+
'visibility_required' => [
124+
'elements' => ['method', 'property'],
125+
],
126+
'whitespace_after_comma_in_array' => true,
127+
];
128+
129+
$project_path = getcwd();
130+
$finder = Finder::create()
131+
->in([
132+
$project_path.'/src',
133+
$project_path.'/config',
134+
$project_path.'/database',
135+
$project_path.'/stubs',
136+
$project_path.'/tests',
137+
])
138+
->name('*.php')
139+
->notName('*.blade.php')
140+
->ignoreDotFiles(true)
141+
->ignoreVCS(true);
142+
143+
return Config::create()
144+
->setFinder($finder)
145+
->setRules($rules)
146+
->setRiskyAllowed(true)
147+
->setUsingCache(true);

0 commit comments

Comments
 (0)