|
23 | 23 | use Ergebnis\PhpCsFixer\Config\RuleSet\Php81; |
24 | 24 | use PhpCsFixer\Finder; |
25 | 25 | use PhpCsFixer\Fixer\DeprecatedFixerInterface; |
26 | | -use PhpCsFixerCustomFixers\Fixer\AbstractFixer; |
| 26 | +use PhpCsFixer\Fixer\FixerInterface; |
27 | 27 |
|
28 | 28 | require __DIR__.'/vendor/autoload.php'; |
29 | 29 |
|
|
40 | 40 | __DIR__.'/LICENSE', |
41 | 41 | Range::since( |
42 | 42 | Year::fromString('2019'), |
43 | | - new \DateTimeZone('Asia/Shanghai'), |
| 43 | + new DateTimeZone('Asia/Shanghai'), |
44 | 44 | ), |
45 | 45 | Holder:: fromString( 'guanguans<[email protected]>'), |
46 | 46 | Url::fromString('https://github.com/guanguans/soar-php'), |
|
51 | 51 | return $mit->header(); |
52 | 52 | })() |
53 | 53 | ) |
54 | | - ->withCustomFixers(Fixers::fromFixers(new ForceFQCNFixer)) |
| 54 | + ->withCustomFixers(Fixers::fromFixers($forceFQCNFixer = new ForceFQCNFixer)) |
| 55 | + ->withCustomFixers(Fixers::fromFixers(...$erickSkrauchFixers = array_filter( |
| 56 | + iterator_to_array(new ErickSkrauch\PhpCsFixer\Fixers), |
| 57 | + static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface |
| 58 | + && !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray()) |
| 59 | + && !\in_array( |
| 60 | + $fixer->getName(), |
| 61 | + [ |
| 62 | + 'ErickSkrauch/align_multiline_parameters', |
| 63 | + 'ErickSkrauch/blank_line_around_class_body', |
| 64 | + ], |
| 65 | + true |
| 66 | + ) |
| 67 | + ))) |
| 68 | + ->withRules(Rules::fromArray(array_reduce( |
| 69 | + $erickSkrauchFixers, |
| 70 | + static function (array $carry, FixerInterface $fixer): array { |
| 71 | + $carry[$fixer->getName()] = true; |
| 72 | + |
| 73 | + return $carry; |
| 74 | + }, |
| 75 | + [] |
| 76 | + ))) |
55 | 77 | ->withCustomFixers(Fixers::fromFixers(...$phpCsFixerCustomFixers = array_filter( |
56 | | - iterator_to_array(new \PhpCsFixerCustomFixers\Fixers), |
57 | | - static fn (AbstractFixer $fixer): bool => !$fixer instanceof DeprecatedFixerInterface |
| 78 | + iterator_to_array(new PhpCsFixerCustomFixers\Fixers), |
| 79 | + static fn (FixerInterface $fixer): bool => !$fixer instanceof DeprecatedFixerInterface |
58 | 80 | && !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray()) |
| 81 | + && !\in_array( |
| 82 | + $fixer->getName(), |
| 83 | + [ |
| 84 | + 'PhpCsFixerCustomFixers/declare_after_opening_tag', |
| 85 | + 'PhpCsFixerCustomFixers/isset_to_array_key_exists', |
| 86 | + 'PhpCsFixerCustomFixers/no_commented_out_code', |
| 87 | + // 'PhpCsFixerCustomFixers/no_leading_slash_in_global_namespace', |
| 88 | + 'PhpCsFixerCustomFixers/phpdoc_only_allowed_annotations', |
| 89 | + 'PhpCsFixerCustomFixers/typed_class_constant', // @since 8.3 |
| 90 | + ], |
| 91 | + true |
| 92 | + ) |
| 93 | + ))) |
| 94 | + ->withRules(Rules::fromArray(array_reduce( |
| 95 | + $phpCsFixerCustomFixers, |
| 96 | + static function (array $carry, FixerInterface $fixer): array { |
| 97 | + $carry[$fixer->getName()] = true; |
| 98 | + |
| 99 | + return $carry; |
| 100 | + }, |
| 101 | + [] |
59 | 102 | ))) |
60 | 103 | ->withRules(Rules::fromArray([ |
61 | 104 | // '@auto' => true, |
|
85 | 128 | '@PHPUnit10x0Migration:risky' => true, |
86 | 129 | ])) |
87 | 130 | ->withRules(Rules::fromArray([ |
88 | | - 'AdamWojs/phpdoc_force_fqcn_fixer' => true, |
| 131 | + $forceFQCNFixer->getName() => true, |
89 | 132 | 'align_multiline_comment' => [ |
90 | 133 | 'comment_type' => 'phpdocs_only', |
91 | 134 | ], |
|
138 | 181 | // 'final_public_method_for_abstract_class' => false, |
139 | 182 | 'fully_qualified_strict_types' => [ |
140 | 183 | 'import_symbols' => false, |
141 | | - 'leading_backslash_in_global_namespace' => true, |
| 184 | + 'leading_backslash_in_global_namespace' => false, |
142 | 185 | 'phpdoc_tags' => [ |
143 | 186 | // 'param', |
144 | 187 | // 'phpstan-param', |
|
315 | 358 | ->ignoreVCSIgnored(true) |
316 | 359 | ->append([ |
317 | 360 | __DIR__.'/composer-bump', |
| 361 | + __DIR__.'/rule-doc-generator', |
318 | 362 | ]) |
319 | 363 | ); |
0 commit comments