-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphp-cs-fixer.php
More file actions
130 lines (115 loc) · 6.35 KB
/
php-cs-fixer.php
File metadata and controls
130 lines (115 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = (new Finder())
->in([__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/examples'])
->name('*.php')
->notPath('vendor');
return (new Config())
->setRiskyAllowed(true)
->setUsingCache(true)
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache')
->setRules([
// ── Rulesets ──────────────────────────────────────────────
'@PER-CS' => true,
'@PER-CS:risky' => true,
'@PHP82Migration' => true,
'@PHP82Migration:risky' => true,
// ── Strict types ──────────────────────────────────────────
'declare_strict_types' => true,
'strict_param' => true,
'strict_comparison' => true,
// ── Imports ───────────────────────────────────────────────
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
// ── Arrays ────────────────────────────────────────────────
'array_syntax' => ['syntax' => 'short'],
'trailing_comma_in_multiline' => [
'elements' => ['arrays', 'arguments', 'parameters', 'match'],
],
'no_multiline_whitespace_around_double_arrow' => true,
'normalize_index_brace' => true,
// ── Classes ───────────────────────────────────────────────
'ordered_class_elements' => [
'order' => [
'use_trait',
'case',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
],
'no_blank_lines_after_class_opening' => true,
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
'trait_import' => 'none',
'case' => 'none',
],
],
'final_class' => false, // we have deliberate non-final classes
'self_accessor' => true,
'self_static_accessor' => true,
// ── Functions & Closures ──────────────────────────────────
'use_arrow_functions' => true,
'static_lambda' => true,
'no_useless_return' => true,
// ── Strings ───────────────────────────────────────────────
'single_quote' => ['strings_containing_single_quote_chars' => false],
'explicit_string_variable' => true,
'heredoc_to_nowdoc' => true,
// ── Control flow ──────────────────────────────────────────
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'simplified_if_return' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
// ── Types ─────────────────────────────────────────────────
'phpdoc_to_return_type' => true,
'phpdoc_to_property_type' => true,
'phpdoc_to_param_type' => true,
'nullable_type_declaration_for_default_null_value' => true,
'nullable_type_declaration' => ['syntax' => 'union'],
// ── PHPDoc ────────────────────────────────────────────────
'phpdoc_order' => true,
'phpdoc_separation' => true,
'phpdoc_trim' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_scalar' => true,
'phpdoc_var_without_name' => true,
'no_superfluous_phpdoc_tags' => ['remove_inheritdoc' => false],
// ── Whitespace / Formatting ───────────────────────────────
'concat_space' => ['spacing' => 'one'],
'binary_operator_spaces' => ['default' => 'single_space'],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'],
// ── Misc ──────────────────────────────────────────────────
'mb_str_functions' => true,
'modernize_strpos' => true,
'get_class_to_class_keyword' => true,
'no_alias_functions' => true,
'random_api_migration' => true,
'pow_to_exponentiation' => true,
])
->setFinder($finder);