Skip to content

Commit d31ea16

Browse files
authored
Use kubawerlos/php-cs-fixer-config (#296)
1 parent a00dc60 commit d31ea16

File tree

103 files changed

+964
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+964
-325
lines changed

.php_cs

Lines changed: 10 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ declare(strict_types=1);
55
/*
66
* This file is part of PHP CS Fixer: custom fixers.
77
*
8-
* (c) Kuba Werłos <werlos@gmail.com>
8+
* (c) 2018-2020 Kuba Werłos
99
*
1010
* For the full copyright and license information, please view
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14-
$header = \trim('
15-
This file is part of PHP CS Fixer: custom fixers.
14+
require_once __DIR__ . '/dev-tools/vendor/autoload.php';
15+
$rules = (new PhpCsFixerConfig\Rules\LibraryRules('PHP CS Fixer: custom fixers', 'Kuba Werłos', 2018))->getRules();
1616

17-
(c) Kuba Werłos <werlos@gmail.com>
17+
// PhpCsFixerCustomFixersDev\Fixer\OrderedClassElementsInternalFixer will handle this
18+
unset($rules['ordered_class_elements']);
19+
unset($rules['ordered_interfaces']);
1820

19-
For the full copyright and license information, please view
20-
the LICENSE file that was distributed with this source code.
21-
');
21+
foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
22+
$rules[$fixer->getName()] = true;
23+
}
2224

2325
return PhpCsFixer\Config::create()
2426
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
@@ -37,166 +39,4 @@ return PhpCsFixer\Config::create()
3739
__FILE__,
3840
])
3941
)
40-
->setRules([
41-
'@PHP71Migration' => true,
42-
'@PHP71Migration:risky' => true,
43-
'@PHPUnit60Migration:risky' => true,
44-
'@Symfony' => true,
45-
'@Symfony:risky' => true,
46-
'align_multiline_comment' => [
47-
'comment_type' => 'all_multiline',
48-
],
49-
'array_indentation' => true,
50-
'array_syntax' => [
51-
'syntax' => 'short',
52-
],
53-
'binary_operator_spaces' => true,
54-
'class_attributes_separation' => ['elements' => ['method', 'property']],
55-
'class_definition' => [
56-
'multiLineExtendsEachSingleLine' => true,
57-
'singleItemSingleLine' => true,
58-
],
59-
'combine_consecutive_issets' => true,
60-
'combine_consecutive_unsets' => true,
61-
'comment_to_phpdoc' => true,
62-
'compact_nullable_typehint' => true,
63-
'concat_space' => [
64-
'spacing' => 'one',
65-
],
66-
'explicit_indirect_variable' => true,
67-
'explicit_string_variable' => true,
68-
'final_class' => true,
69-
'final_internal_class' => true,
70-
'final_public_method_for_abstract_class' => true,
71-
'final_static_access' => true,
72-
'fully_qualified_strict_types' => true,
73-
'function_to_constant' => [
74-
'functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi'],
75-
],
76-
'header_comment' => ['header' => $header],
77-
'heredoc_to_nowdoc' => true,
78-
'increment_style' => [
79-
'style' => 'post',
80-
],
81-
'linebreak_after_opening_tag' => true,
82-
'list_syntax' => [
83-
'syntax' => 'long',
84-
],
85-
'logical_operators' => true,
86-
'method_argument_space' => [
87-
'on_multiline' => 'ensure_fully_multiline',
88-
],
89-
'method_chaining_indentation' => true,
90-
'multiline_comment_opening_closing' => true,
91-
'multiline_whitespace_before_semicolons' => true,
92-
'native_function_invocation' => [
93-
'include' => ['@all'],
94-
],
95-
'no_alternative_syntax' => true,
96-
'no_binary_string' => true,
97-
'no_extra_blank_lines' => [
98-
'tokens' => [
99-
'continue',
100-
'curly_brace_block',
101-
'extra',
102-
'parenthesis_brace_block',
103-
'return',
104-
'square_brace_block',
105-
'throw',
106-
'use',
107-
'use_trait',
108-
],
109-
],
110-
'no_null_property_initialization' => true,
111-
'no_php4_constructor' => true,
112-
'no_superfluous_elseif' => true,
113-
'no_unreachable_default_argument_value' => true,
114-
'no_unset_on_property' => true,
115-
'no_useless_else' => true,
116-
'no_useless_return' => true,
117-
'ordered_imports' => [
118-
'sortAlgorithm' => 'alpha',
119-
],
120-
'php_unit_internal_class' => true,
121-
'php_unit_ordered_covers' => true,
122-
'php_unit_set_up_tear_down_visibility' => true,
123-
'php_unit_strict' => true,
124-
'php_unit_test_annotation' => true,
125-
'php_unit_test_case_static_method_calls' => [
126-
'call_type' => 'self',
127-
],
128-
'php_unit_test_class_requires_covers' => true,
129-
'phpdoc_line_span' => ['property' => 'single'],
130-
'phpdoc_order' => true,
131-
'phpdoc_trim_consecutive_blank_line_separation' => true,
132-
'phpdoc_types_order' => true,
133-
'return_assignment' => true,
134-
'static_lambda' => true,
135-
'strict_comparison' => true,
136-
'strict_param' => true,
137-
'string_line_ending' => true,
138-
'unary_operator_spaces' => false,
139-
'visibility_required' => [
140-
'elements' => [
141-
'const',
142-
'property',
143-
'method',
144-
],
145-
],
146-
'yoda_style' => [
147-
'equal' => false,
148-
'identical' => false,
149-
'less_and_greater' => false,
150-
],
151-
] + \array_reduce(
152-
\iterator_to_array(new PhpCsFixerCustomFixers\Fixers()),
153-
static function (array $carry, PhpCsFixer\Fixer\DefinedFixerInterface $fixer): array {
154-
if ($fixer instanceof PhpCsFixer\Fixer\DeprecatedFixerInterface) {
155-
return $carry;
156-
}
157-
158-
if ($fixer instanceof PhpCsFixerCustomFixers\Fixer\NoNullableBooleanTypeFixer) {
159-
return $carry;
160-
}
161-
162-
if ($fixer instanceof PhpCsFixerCustomFixers\Fixer\NoReferenceInFunctionDefinitionFixer) {
163-
return $carry;
164-
}
165-
166-
if ($fixer instanceof PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer) {
167-
$carry[$fixer->getName()] = ['allow_preventing_trailing_spaces' => true];
168-
169-
return $carry;
170-
}
171-
172-
if ($fixer instanceof PhpCsFixerCustomFixers\Fixer\PhpdocOnlyAllowedAnnotationsFixer) {
173-
$carry[$fixer->getName()] = ['elements' => [
174-
'covers',
175-
'coversNothing',
176-
'dataProvider',
177-
'deprecated',
178-
'implements',
179-
'internal',
180-
'param',
181-
'requires',
182-
'return',
183-
'var',
184-
]];
185-
186-
return $carry;
187-
}
188-
189-
$carry[$fixer->getName()] = true;
190-
191-
return $carry;
192-
},
193-
[]
194-
) + \array_reduce(
195-
\iterator_to_array(new PhpCsFixerCustomFixersDev\Fixers()),
196-
static function (array $carry, PhpCsFixer\Fixer\FixerInterface $fixer): array {
197-
$carry[$fixer->getName()] = true;
198-
199-
return $carry;
200-
},
201-
[]
202-
));
42+
->setRules($rules);

dev-tools/composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"require-dev": {
66
"ergebnis/composer-normalize": "^2.5.1",
77
"infection/infection": "^0.16.3",
8+
"kubawerlos/php-cs-fixer-config": "^1.0.0",
89
"kubawerlos/types-checker": "^2.0.0",
910
"maglnet/composer-require-checker": "^2.1.0",
1011
"mi-schi/phpmd-extension": "^4.3.0",
@@ -14,10 +15,16 @@
1415
"squizlabs/php_codesniffer": "^3.5.5",
1516
"vimeo/psalm": "^3.11.2"
1617
},
18+
"autoload": {
19+
"psr-4": {
20+
"PhpCsFixerCustomFixers\\": "../src"
21+
}
22+
},
1723
"scripts": {
1824
"analyse": [
1925
"composer validate --strict --working-dir=..",
2026
"composer normalize --dry-run ../composer.json",
27+
"composer normalize --dry-run",
2128
"composer-require-checker check ../composer.json",
2229
"phpcs",
2330
"types-checker --autoloader=../vendor/autoload.php ./src ../src ../tests",
@@ -27,6 +34,7 @@
2734
],
2835
"fix": [
2936
"composer normalize ../composer.json",
37+
"composer normalize",
3038
"phpcbf || exit 0"
3139
],
3240
"infection": [

0 commit comments

Comments
 (0)