Skip to content

Commit fd352a3

Browse files
committed
chore: php cs fixer added
1 parent 5016ba7 commit fd352a3

File tree

6 files changed

+243
-3
lines changed

6 files changed

+243
-3
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/.vscode export-ignore
12
/tests export-ignore
23
/phpunit.xml export-ignore
34
.gitattributes export-ignore
4-
.gitignore export-ignore
5+
.gitignore export-ignore
6+
.php-cs-fixer.php export-ignore

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
vendor/
22
composer.lock
33
.phpunit.result.cache
4-
/phpunit.xml
4+
/phpunit.xml
5+
.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude([
5+
__DIR__ . '/vendor',
6+
])
7+
->in([
8+
__DIR__ . '/src',
9+
__DIR__ . '/tests'
10+
])
11+
->ignoreVCSIgnored(true);
12+
13+
$config = new PhpCsFixer\Config();
14+
15+
return $config
16+
->setRiskyAllowed(true)
17+
->setIndent(str_pad('', 4))
18+
->setRules([
19+
'@PSR2' => true,
20+
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
21+
'array_indentation' => true,
22+
'array_push' => true,
23+
'array_syntax' => true,
24+
'binary_operator_spaces' => [
25+
'operators' => [
26+
'=>' => 'align_single_space_minimal',
27+
// '=' => 'align_single_space_minimal',
28+
],
29+
],
30+
'method_argument_space' => [
31+
'on_multiline' => 'ensure_fully_multiline',
32+
'keep_multiple_spaces_after_comma' => false,
33+
],
34+
'blank_line_after_namespace' => true,
35+
'blank_line_after_opening_tag' => true,
36+
'blank_line_before_statement' => true,
37+
'blank_line_between_import_groups' => true,
38+
'braces' => ['allow_single_line_anonymous_class_with_empty_body' => true],
39+
'cast_spaces' => true,
40+
'class_attributes_separation' => true,
41+
'class_definition' => true,
42+
'class_reference_name_casing' => true,
43+
'clean_namespace' => true,
44+
'combine_consecutive_issets' => true,
45+
'combine_consecutive_unsets' => true,
46+
'comment_to_phpdoc' => true,
47+
'concat_space' => ['spacing' => 'one'],
48+
'constant_case' => true,
49+
'control_structure_braces' => true,
50+
'control_structure_continuation_position' => true,
51+
'curly_braces_position' => true,
52+
'dir_constant' => true,
53+
'elseif' => true,
54+
'empty_loop_body' => true,
55+
'empty_loop_condition' => true,
56+
'encoding' => true,
57+
'ereg_to_preg' => true,
58+
'explicit_indirect_variable' => true,
59+
'explicit_string_variable' => true,
60+
'function_declaration' => true,
61+
'function_to_constant' => true,
62+
'global_namespace_import' => ['import_constants' => false, 'import_functions' => false, 'import_classes' => true],
63+
'group_import' => false,
64+
'include' => true,
65+
'indentation_type' => true,
66+
'integer_literal_case' => true,
67+
'line_ending' => true,
68+
'linebreak_after_opening_tag' => true,
69+
'lowercase_cast' => true,
70+
'lowercase_keywords' => true,
71+
'lowercase_static_reference' => true,
72+
'magic_constant_casing' => true,
73+
'magic_method_casing' => true,
74+
'method_chaining_indentation' => true,
75+
'visibility_required' => true,
76+
'whitespace_after_comma_in_array' => true,
77+
'space_after_semicolon' => true,
78+
'trim_array_spaces' => true,
79+
'multiline_comment_opening_closing' => true,
80+
'multiline_whitespace_before_semicolons' => false,
81+
'no_whitespace_before_comma_in_array' => true,
82+
'native_function_casing' => true,
83+
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
84+
'new_with_braces' => true,
85+
'no_alias_language_construct_call' => true,
86+
'no_alternative_syntax' => true,
87+
'no_binary_string' => true,
88+
'no_blank_lines_after_class_opening' => true,
89+
'no_blank_lines_after_phpdoc' => true,
90+
'no_break_comment' => true,
91+
'no_closing_tag' => true,
92+
'no_empty_phpdoc' => true,
93+
'no_empty_statement' => true,
94+
'no_extra_blank_lines' => true,
95+
'no_leading_import_slash' => true,
96+
'no_leading_namespace_whitespace' => true,
97+
'no_multiple_statements_per_line' => true,
98+
'no_null_property_initialization' => true,
99+
'no_short_bool_cast' => true,
100+
'no_singleline_whitespace_before_semicolons' => true,
101+
'no_space_around_double_colon' => true,
102+
'no_spaces_after_function_name' => true,
103+
'no_spaces_around_offset' => true,
104+
'no_trailing_comma_in_singleline' => true,
105+
'no_trailing_whitespace' => true,
106+
'no_trailing_whitespace_in_comment' => true,
107+
'no_unneeded_control_parentheses' => true,
108+
'no_unneeded_curly_braces' => true,
109+
'no_unneeded_import_alias' => true,
110+
'no_unused_imports' => true,
111+
'no_useless_else' => true,
112+
'no_useless_return' => true,
113+
'no_whitespace_in_blank_line' => true,
114+
'no_spaces_inside_parenthesis' => true,
115+
'object_operator_without_whitespace' => true,
116+
'operator_linebreak' => true,
117+
'ordered_class_elements' => true,
118+
'ordered_imports' => true,
119+
'php_unit_internal_class' => true,
120+
'php_unit_method_casing' => true,
121+
'php_unit_test_class_requires_covers' => true,
122+
'phpdoc_add_missing_param_annotation' => true,
123+
'phpdoc_align' => true,
124+
'phpdoc_indent' => true,
125+
'phpdoc_line_span' => true,
126+
'phpdoc_no_package' => true,
127+
'phpdoc_no_useless_inheritdoc' => true,
128+
'phpdoc_order' => true,
129+
'phpdoc_return_self_reference' => true,
130+
'phpdoc_scalar' => true,
131+
'phpdoc_separation' => true,
132+
'phpdoc_tag_casing' => true,
133+
'phpdoc_tag_type' => true,
134+
'phpdoc_trim' => true,
135+
'phpdoc_trim_consecutive_blank_line_separation' => true,
136+
'phpdoc_types' => true,
137+
'random_api_migration' => true,
138+
'return_assignment' => true,
139+
'simplified_if_return' => true,
140+
'simplified_null_return' => true,
141+
'single_blank_line_at_eof' => true,
142+
'single_blank_line_before_namespace' => true,
143+
'single_class_element_per_statement' => true,
144+
'single_line_after_imports' => true,
145+
'single_line_comment_spacing' => true,
146+
'single_line_comment_style' => true,
147+
'single_line_throw' => true,
148+
'single_quote' => true,
149+
'single_space_after_construct' => true,
150+
'standardize_increment' => true,
151+
'standardize_not_equals' => true,
152+
'statement_indentation' => true,
153+
'switch_continue_to_break' => true,
154+
'ternary_operator_spaces' => true,
155+
])
156+
->setFinder($finder);

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"junstyle.php-cs-fixer",
4+
"bmewburn.vscode-intelephense-client",
5+
"esbenp.prettier-vscode",
6+
"stylelint.vscode-stylelint",
7+
"sainoba.px-to-rem"
8+
]
9+
}

.vscode/settings.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"php-cs-fixer.onsave": true,
3+
"php-cs-fixer.executablePath": "${workspaceFolder}/vendor/bin/php-cs-fixer",
4+
"php-cs-fixer.documentFormattingProvider": true,
5+
"php-cs-fixer.executablePathWindows": "${workspaceFolder}\\vendor\\bin\\php-cs-fixer.bat",
6+
"php-cs-fixer.config": ".php-cs-fixer.php",
7+
"search.useGlobalIgnoreFiles": false,
8+
"search.useParentIgnoreFiles": false,
9+
"prettier.enable": true,
10+
"editor.defaultFormatter": "esbenp.prettier-vscode",
11+
"editor.formatOnSave": true,
12+
"stylelint.snippet": ["css", "scss"],
13+
"stylelint.validate": ["css", "scss", "postcss"],
14+
"files.eol": "\n",
15+
"search.exclude": {
16+
"**/.git": true,
17+
"**/.github": true,
18+
"**/.nuxt": true,
19+
"**/.output": true,
20+
"**/.pnpm": true,
21+
"**/.vscode": true,
22+
"**/.yarn": true,
23+
"**/bower_components": true,
24+
"**/dist/**": true,
25+
"**/logs": true,
26+
"**/node_modules": true,
27+
"**/out/**": true,
28+
"**/package-lock.json": true,
29+
"**/pnpm-lock.yaml": true,
30+
"**/tmp": true,
31+
"**/yarn.lock": true,
32+
"**/vendor": true,
33+
"**/tests/__libs": true
34+
},
35+
"typescript.tsdk": "node_modules\\typescript\\lib",
36+
"css.lint.validProperties": ["composes"],
37+
"cSpell.words": [
38+
"ABSPATH",
39+
"antd",
40+
"autoload",
41+
"bitapps",
42+
"bitappspi",
43+
"commitlint",
44+
"compat",
45+
"cssinjs",
46+
"dealerdirect",
47+
"friendsofphp",
48+
"immer",
49+
"incstr",
50+
"intelephense",
51+
"lefthook",
52+
"Lucide",
53+
"phpcodesniffer",
54+
"phpcompatibility",
55+
"phpcs",
56+
"phpunit",
57+
"pnpm",
58+
"Popconfirm",
59+
"Sider",
60+
"sirbrillig",
61+
"stylelint",
62+
"testdox",
63+
"yoast"
64+
],
65+
"[typescript, javascript, typescriptreact, json, css]": {
66+
"editor.defaultFormatter": "esbenp.prettier-vscode"
67+
},
68+
"[php]": {
69+
"editor.defaultFormatter": "junstyle.php-cs-fixer"
70+
}
71+
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"require-dev": {
4444
"pestphp/pest": "3.x-dev",
4545
"squizlabs/php_codesniffer": "*",
46-
"phpcompatibility/php-compatibility": "*"
46+
"phpcompatibility/php-compatibility": "*",
47+
"friendsofphp/php-cs-fixer": "dev-master"
4748
},
4849
"minimum-stability": "dev",
4950
"config": {

0 commit comments

Comments
 (0)