Skip to content

Commit ccdc96b

Browse files
committed
chore: add PHP CS Fixer with extended ruleset and composer scripts
1 parent e4c1e44 commit ccdc96b

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

.php-cs-fixer.php

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,89 @@
3636
],
3737
'method_argument_space' => [
3838
'on_multiline' => 'ensure_fully_multiline',
39+
'keep_multiple_spaces_after_comma' => true,
3940
],
4041
'single_trait_insert_per_statement' => true,
42+
'blank_line_after_namespace' => true,
43+
'blank_line_after_opening_tag' => true,
44+
'braces' => [
45+
'allow_single_line_anonymous_class_with_empty_body' => true,
46+
'allow_single_line_closure' => true,
47+
],
48+
'concat_space' => ['spacing' => 'one'],
49+
'declare_equal_normalize' => true,
50+
'function_typehint_space' => true,
51+
'single_line_comment_style' => ['comment_types' => ['hash']],
52+
'include' => true,
53+
'lowercase_cast' => true,
54+
'native_function_casing' => true,
55+
'new_with_braces' => true,
56+
'no_blank_lines_after_class_opening' => true,
57+
'no_blank_lines_after_phpdoc' => true,
58+
'no_blank_lines_before_namespace' => true,
59+
'no_empty_comment' => true,
60+
'no_empty_phpdoc' => true,
61+
'no_empty_statement' => true,
62+
'no_extra_blank_lines' => [
63+
'tokens' => [
64+
'curly_brace_block',
65+
'extra',
66+
'parenthesis_brace_block',
67+
'square_brace_block',
68+
'throw',
69+
'use',
70+
],
71+
],
72+
'no_leading_import_slash' => true,
73+
'no_leading_namespace_whitespace' => true,
74+
'no_mixed_echo_print' => true,
75+
'no_multiline_whitespace_around_double_arrow' => true,
76+
'no_short_bool_cast' => true,
77+
'no_singleline_whitespace_before_semicolons' => true,
78+
'no_spaces_around_offset' => true,
79+
'no_trailing_comma_in_list_call' => true,
80+
'no_trailing_comma_in_singleline_array' => true,
81+
'no_unneeded_control_parentheses' => [
82+
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
83+
],
84+
'no_whitespace_before_comma_in_array' => true,
85+
'no_whitespace_in_blank_line' => true,
86+
'normalize_index_brace' => true,
87+
'object_operator_without_whitespace' => true,
88+
'php_unit_fqcn_annotation' => true,
89+
'phpdoc_align' => [
90+
'align' => 'vertical',
91+
],
92+
'phpdoc_annotation_without_dot' => true,
93+
'phpdoc_indent' => true,
94+
'phpdoc_inline_tag_normalizer' => true,
95+
'phpdoc_no_access' => true,
96+
'phpdoc_no_alias_tag' => true,
97+
'phpdoc_no_empty_return' => true,
98+
'phpdoc_no_package' => true,
99+
'phpdoc_no_useless_inheritdoc' => true,
100+
'phpdoc_return_self_reference' => true,
101+
'phpdoc_separation' => true,
102+
'phpdoc_summary' => true,
103+
'phpdoc_to_comment' => true,
104+
'phpdoc_trim' => true,
105+
'phpdoc_types' => true,
106+
'return_type_declaration' => true,
107+
'semicolon_after_instruction' => true,
108+
'short_scalar_cast' => true,
109+
'single_blank_line_before_namespace' => true,
110+
'single_class_element_per_statement' => true,
111+
'single_quote' => true,
112+
'space_after_semicolon' => [
113+
'remove_in_empty_for_expressions' => true,
114+
],
115+
'standardize_not_equals' => true,
116+
'switch_case_semicolon_to_colon' => true,
117+
'switch_case_space' => true,
118+
'ternary_operator_spaces' => true,
119+
'visibility_required' => true,
120+
'whitespace_after_comma_in_array' => true,
41121
])
42-
->setFinder($finder);
122+
->setFinder($finder)
123+
->setRiskyAllowed(false)
124+
->setUsingCache(true);

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
"illuminate/http": "^10.0|^11.0|^12.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^10.0|^11.0",
20+
"friendsofphp/php-cs-fixer": "^3.82",
2121
"orchestra/testbench": "^8.0|^9.0|^10.0@dev",
2222
"pestphp/pest": "^2.20|^3.0@dev",
2323
"pestphp/pest-plugin-laravel": "^2.2|^3.0@dev",
24-
"phpstan/phpstan": "^1.10"
24+
"phpstan/phpstan": "^1.10",
25+
"phpunit/phpunit": "^10.0|^11.0"
2526
},
2627
"autoload": {
2728
"psr-4": {
@@ -51,6 +52,8 @@
5152
"scripts": {
5253
"test": "vendor/bin/pest",
5354
"test-coverage": "vendor/bin/pest --coverage",
54-
"phpstan": "vendor/bin/phpstan analyse"
55+
"phpstan": "vendor/bin/phpstan analyse",
56+
"cs-fix": "vendor/bin/php-cs-fixer fix",
57+
"cs-check": "vendor/bin/php-cs-fixer fix --dry-run --diff"
5558
}
56-
}
59+
}

0 commit comments

Comments
 (0)