Skip to content

Commit fec02b3

Browse files
committed
style: apply php-cs-fixer
1 parent 9fff097 commit fec02b3

19 files changed

+75
-559
lines changed

.php-cs-fixer-custom.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
'.chglog/CHANGELOG.tpl.md',
105105
'CHANGELOG.md',
106106
// 'composer.json',
107+
'README-zh_CN.md',
107108
'README.md',
108109
])
109110
->name($fixers->extensionPatterns())
@@ -119,6 +120,9 @@
119120
->ignoreUnreadableDirs(false)
120121
->ignoreVCS(true)
121122
->ignoreVCSIgnored(true)
123+
/** @see \Symfony\Component\Finder\Iterator\SortableIterator::__construct() */
124+
// ->sortByExtension()
125+
->sort(static fn (SplFileInfo $a, SplFileInfo $b): int => strnatcmp($a->getExtension(), $b->getExtension()))
122126
)
123127
->setCacheFile(\sprintf('%s/.build/php-cs-fixer/%s.cache', __DIR__, pathinfo(__FILE__, \PATHINFO_FILENAME)))
124128
// ->setParallelConfig(ParallelConfigFactory::sequential())

.php-cs-fixer.dist.php

Lines changed: 4 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* @see https://github.com/guanguans/soar-php
1212
*/
1313

14-
use AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer;
1514
use Ergebnis\License\Holder;
1615
use Ergebnis\License\Range;
1716
use Ergebnis\License\Type\MIT;
@@ -22,17 +21,9 @@
2221
use Ergebnis\PhpCsFixer\Config\Rules;
2322
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81;
2423
use PhpCsFixer\Finder;
25-
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
26-
use PhpCsFixer\Fixer\FixerInterface;
2724

2825
require __DIR__.'/vendor/autoload.php';
2926

30-
// putenv('PHP_CS_FIXER_ENFORCE_CACHE=1');
31-
// putenv('PHP_CS_FIXER_IGNORE_ENV=1');
32-
putenv('PHP_CS_FIXER_FUTURE_MODE=1');
33-
putenv('PHP_CS_FIXER_NON_MONOLITHIC=1');
34-
putenv('PHP_CS_FIXER_PARALLEL=1');
35-
3627
return Factory::fromRuleSet(Php81::create()
3728
->withHeader(
3829
(static function (): string {
@@ -51,298 +42,16 @@
5142
return $mit->header();
5243
})()
5344
)
54-
->withCustomFixers(Fixers::fromFixers($forceFQCNFixer = new ForceFQCNFixer))
55-
->withRules(Rules::fromArray([
56-
$forceFQCNFixer->getName() => true,
57-
]))
58-
->withCustomFixers(Fixers::fromFixers(...$erickSkrauchFixers = array_filter(
59-
iterator_to_array(new ErickSkrauch\PhpCsFixer\Fixers),
60-
static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface
61-
&& !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray())
62-
&& !\in_array(
63-
$fixer->getName(),
64-
[
65-
'ErickSkrauch/align_multiline_parameters',
66-
'ErickSkrauch/blank_line_around_class_body',
67-
],
68-
true
69-
)
70-
)))
71-
->withRules(Rules::fromArray(array_reduce(
72-
$erickSkrauchFixers,
73-
static function (array $carry, FixerInterface $fixer): array {
74-
$carry[$fixer->getName()] = true;
75-
76-
return $carry;
77-
},
78-
[]
79-
)))
80-
->withCustomFixers(Fixers::fromFixers(...$phpCsFixerCustomFixers = array_filter(
81-
iterator_to_array(new PhpCsFixerCustomFixers\Fixers),
82-
static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface
83-
&& !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray())
84-
&& !\in_array(
85-
$fixer->getName(),
86-
[
87-
'PhpCsFixerCustomFixers/declare_after_opening_tag',
88-
'PhpCsFixerCustomFixers/isset_to_array_key_exists',
89-
'PhpCsFixerCustomFixers/no_commented_out_code',
90-
// 'PhpCsFixerCustomFixers/no_leading_slash_in_global_namespace',
91-
'PhpCsFixerCustomFixers/no_nullable_boolean_type',
92-
'PhpCsFixerCustomFixers/phpdoc_only_allowed_annotations',
93-
'PhpCsFixerCustomFixers/typed_class_constant', // @since 8.3
94-
],
95-
true
96-
)
97-
)))
98-
->withRules(Rules::fromArray(array_reduce(
99-
$phpCsFixerCustomFixers,
100-
static function (array $carry, FixerInterface $fixer): array {
101-
$carry[$fixer->getName()] = true;
102-
103-
return $carry;
104-
},
105-
[]
106-
)))
107-
->withRules(Rules::fromArray([
108-
// '@auto' => true,
109-
// '@auto:risky' => true,
110-
// '@autoPHPMigration' => true,
111-
// '@autoPHPMigration:risky' => true,
112-
// '@autoPHPUnitMigration:risky' => true,
113-
// '@DoctrineAnnotation' => true,
114-
// '@PHP7x4Migration' => true,
115-
// '@PHP7x4Migration:risky' => true,
116-
// '@PHP8x0Migration' => true,
117-
// '@PHP8x0Migration:risky' => true,
118-
'@PHP8x1Migration' => true,
119-
// '@PHP8x1Migration:risky' => true,
120-
// '@PHP8x2Migration' => true,
121-
// '@PHP8x2Migration:risky' => true,
122-
// '@PHP8x3Migration' => true,
123-
// '@PHP8x3Migration:risky' => true,
124-
// '@PHP8x4Migration' => true,
125-
// '@PHP8x4Migration:risky' => true,
126-
// '@PHP8x5Migration' => true,
127-
// '@PHP8x5Migration:risky' => true,
128-
// '@PhpCsFixer' => true,
129-
// '@PhpCsFixer:risky' => true,
130-
// '@PHPUnit8x4Migration:risky' => true,
131-
// '@PHPUnit9x1Migration:risky' => true,
132-
'@PHPUnit10x0Migration:risky' => true,
133-
]))
45+
->withCustomFixers(Fixers::fromFixers(... require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/custom-fixers.php'))
46+
->withRules(Rules::fromArray(require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/custom-rules.php'))
47+
->withRules(Rules::fromArray(require __DIR__.'/vendor/guanguans/php-cs-fixer-custom-fixers/config/rules.php'))
13448
->withRules(Rules::fromArray([
135-
'align_multiline_comment' => [
136-
'comment_type' => 'phpdocs_only',
137-
],
138-
'attribute_empty_parentheses' => [
139-
'use_parentheses' => false,
140-
],
141-
'blank_line_before_statement' => [
142-
'statements' => [
143-
'break',
144-
// 'case',
145-
'continue',
146-
'declare',
147-
// 'default',
148-
'do',
149-
'exit',
150-
'for',
151-
'foreach',
152-
'goto',
153-
'if',
154-
'include',
155-
'include_once',
156-
'phpdoc',
157-
'require',
158-
'require_once',
159-
'return',
160-
'switch',
161-
'throw',
162-
'try',
163-
'while',
164-
'yield',
165-
'yield_from',
166-
],
167-
],
168-
'class_definition' => [
169-
'inline_constructor_arguments' => false,
170-
'multi_line_extends_each_single_line' => false,
171-
'single_item_single_line' => false,
172-
'single_line' => false,
173-
'space_before_parenthesis' => false,
174-
],
175-
'concat_space' => [
176-
'spacing' => 'none',
177-
],
178-
'empty_loop_condition' => [
179-
'style' => 'for',
180-
],
181-
'explicit_string_variable' => false,
182-
'final_class' => false,
183-
// 'final_internal_class' => false,
184-
// 'final_public_method_for_abstract_class' => false,
185-
'fully_qualified_strict_types' => [
186-
'import_symbols' => false,
187-
'leading_backslash_in_global_namespace' => false,
188-
'phpdoc_tags' => [
189-
// 'param',
190-
// 'phpstan-param',
191-
// 'phpstan-property',
192-
// 'phpstan-property-read',
193-
// 'phpstan-property-write',
194-
// 'phpstan-return',
195-
// 'phpstan-var',
196-
// 'property',
197-
// 'property-read',
198-
// 'property-write',
199-
// 'psalm-param',
200-
// 'psalm-property',
201-
// 'psalm-property-read',
202-
// 'psalm-property-write',
203-
// 'psalm-return',
204-
// 'psalm-var',
205-
// 'return',
206-
// 'see',
207-
// 'throws',
208-
// 'var',
209-
],
210-
],
211-
'logical_operators' => false,
212-
'mb_str_functions' => false,
213-
'native_function_invocation' => [
214-
'exclude' => [],
215-
'include' => ['@compiler_optimized', 'is_scalar'],
216-
'scope' => 'all',
217-
'strict' => true,
218-
],
219-
'new_with_parentheses' => [
220-
'anonymous_class' => false,
221-
'named_class' => false,
222-
],
223-
'no_extra_blank_lines' => [
224-
'tokens' => [
225-
'attribute',
226-
'break',
227-
'case',
228-
// 'comma',
229-
'continue',
230-
'curly_brace_block',
231-
'default',
232-
'extra',
233-
'parenthesis_brace_block',
234-
'return',
235-
'square_brace_block',
236-
'switch',
237-
'throw',
238-
'use',
239-
],
240-
],
241-
'ordered_traits' => [
242-
'case_sensitive' => true,
243-
],
244-
'php_unit_data_provider_name' => [
245-
'prefix' => 'provide',
246-
'suffix' => 'Cases',
247-
],
248-
'phpdoc_align' => [
249-
'align' => 'left',
250-
'spacing' => 1,
251-
'tags' => [
252-
'method',
253-
'param',
254-
'property',
255-
'property-read',
256-
'property-write',
257-
'return',
258-
'throws',
259-
'type',
260-
'var',
261-
],
262-
],
263-
'phpdoc_line_span' => [
264-
'const' => 'single',
265-
'method' => 'multi',
266-
'property' => 'single',
267-
],
268-
'phpdoc_no_alias_tag' => [
269-
'replacements' => [
270-
'link' => 'see',
271-
// 'property-read' => 'property',
272-
// 'property-write' => 'property',
273-
'type' => 'var',
274-
],
275-
],
276-
'phpdoc_order' => [
277-
'order' => [
278-
'noinspection',
279-
'phan-suppress',
280-
'phpcsSuppress',
281-
'phpstan-ignore',
282-
'psalm-suppress',
283-
284-
'deprecated',
285-
'internal',
286-
'covers',
287-
'uses',
288-
'dataProvider',
289-
'param',
290-
'throws',
291-
'return',
292-
],
293-
],
294-
'phpdoc_order_by_value' => [
295-
'annotations' => [
296-
'author',
297-
'covers',
298-
'coversNothing',
299-
'dataProvider',
300-
'depends',
301-
'group',
302-
'internal',
303-
// 'method',
304-
'mixin',
305-
'property',
306-
'property-read',
307-
'property-write',
308-
'requires',
309-
'throws',
310-
'uses',
311-
],
312-
],
313-
'phpdoc_to_param_type' => [
314-
'scalar_types' => true,
315-
'types_map' => [],
316-
'union_types' => true,
317-
],
318-
'phpdoc_to_property_type' => [
319-
'scalar_types' => true,
320-
'types_map' => [],
321-
'union_types' => true,
322-
],
323-
'phpdoc_to_return_type' => [
324-
'scalar_types' => true,
325-
'types_map' => [],
326-
'union_types' => true,
327-
],
328-
'simplified_if_return' => true,
329-
'simplified_null_return' => true,
330-
'single_line_empty_body' => true,
331-
'statement_indentation' => [
332-
'stick_comment_to_next_continuous_control_statement' => true,
333-
],
334-
'static_lambda' => false, // pest
335-
'static_private_method' => false,
49+
'@autoPHPUnitMigration:risky' => true,
33650
])))
33751
->setUsingCache(true)
33852
->setCacheFile(\sprintf('%s/.build/php-cs-fixer/%s.cache', __DIR__, pathinfo(__FILE__, \PATHINFO_FILENAME)))
33953
->setUnsupportedPhpVersionAllowed(true)
34054
->setFinder(
341-
/**
342-
* @see https://github.com/laravel/pint/blob/main/app/Commands/DefaultCommand.php
343-
* @see https://github.com/laravel/pint/blob/main/app/Factories/ConfigurationFactory.php
344-
* @see https://github.com/laravel/pint/blob/main/app/Repositories/ConfigurationJsonRepository.php
345-
*/
34655
Finder::create()
34756
->in(__DIR__)
34857
->exclude([

.zhlintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"caseIgnores": [
77
":+1:",
88
":bangbang:",
9+
":camera_flash:",
910
":cn:",
1011
":eyes:",
1112
":heart:",
1213
":heavy_exclamation_mark:",
1314
":mail:",
15+
":monocle_face:",
1416
":no_entry_sign:",
1517
":smile:",
1618
":tada:",

baselines/callable.nonCallable.neon

Lines changed: 0 additions & 8 deletions
This file was deleted.

baselines/loader.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# total 8 errors
1+
# total 7 errors
22

33
includes:
44
- assign.propertyType.neon
5-
- callable.nonCallable.neon
65
- complexity.functionLike.neon
76
- disallowed.function.neon
87
- new.static.neon

composer-bump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ final class ComposerBump
140140
}
141141

142142
/**
143-
* @noinspection LongLine
144-
*
145143
* @throws \JsonException
144+
*
145+
* @noinspection LongLine
146146
*/
147147
private function outdatedDecodedComposerJson(): array
148148
{

0 commit comments

Comments
 (0)