|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +/** @noinspection PhpUnusedAliasInspection */ |
| 4 | + |
3 | 5 | declare(strict_types=1); |
4 | 6 |
|
5 | 7 | /** |
|
19 | 21 | use Ergebnis\PhpCsFixer\Config\Factory; |
20 | 22 | use Ergebnis\PhpCsFixer\Config\Fixers; |
21 | 23 | use Ergebnis\PhpCsFixer\Config\Rules; |
22 | | -use Ergebnis\PhpCsFixer\Config\RuleSet\Php80; |
| 24 | +use Ergebnis\PhpCsFixer\Config\RuleSet\Php81; |
23 | 25 | use PhpCsFixer\Finder; |
24 | 26 | use PhpCsFixer\Fixer\DeprecatedFixerInterface; |
25 | 27 | use PhpCsFixerCustomFixers\Fixer\AbstractFixer; |
26 | 28 |
|
27 | | -$license = MIT::text( |
28 | | - __DIR__.'/LICENSE', |
29 | | - Range::since( |
30 | | - Year::fromString('2019'), |
31 | | - new DateTimeZone('Asia/Shanghai'), |
32 | | - ), |
33 | | - Holder:: fromString( 'guanguans<[email protected]>'), |
34 | | - Url::fromString('https://github.com/guanguans/soar-php'), |
35 | | -); |
| 29 | +require __DIR__.'/vendor/autoload.php'; |
| 30 | + |
| 31 | +// putenv('PHP_CS_FIXER_ENFORCE_CACHE=1'); |
| 32 | +// putenv('PHP_CS_FIXER_IGNORE_ENV=1'); |
| 33 | +putenv('PHP_CS_FIXER_FUTURE_MODE=1'); |
| 34 | +putenv('PHP_CS_FIXER_NON_MONOLITHIC=1'); |
| 35 | +putenv('PHP_CS_FIXER_PARALLEL=1'); |
36 | 36 |
|
37 | | -$license->save(); |
| 37 | +return Factory::fromRuleSet(Php81::create() |
| 38 | + ->withHeader( |
| 39 | + (static function (): string { |
| 40 | + $license = MIT::text( |
| 41 | + __DIR__.'/LICENSE', |
| 42 | + Range::since( |
| 43 | + Year::fromString('2019'), |
| 44 | + new DateTimeZone('Asia/Shanghai'), |
| 45 | + ), |
| 46 | + Holder:: fromString( 'guanguans<[email protected]>'), |
| 47 | + Url::fromString('https://github.com/guanguans/soar-php'), |
| 48 | + ); |
38 | 49 |
|
39 | | -$ruleSet = Php80::create() |
40 | | - ->withHeader($license->header()) |
| 50 | + $license->save(); |
| 51 | + |
| 52 | + return $license->header(); |
| 53 | + })() |
| 54 | + ) |
| 55 | + ->withCustomFixers(Fixers::fromFixers(...$phpCsFixerCustomFixers = array_filter( |
| 56 | + iterator_to_array(new PhpCsFixerCustomFixers\Fixers), |
| 57 | + static fn (AbstractFixer $fixer): bool => !$fixer instanceof DeprecatedFixerInterface |
| 58 | + && !\array_key_exists($fixer->getName(), Php81::create()->rules()->toArray()) |
| 59 | + ))) |
41 | 60 | ->withRules(Rules::fromArray([ |
42 | 61 | // '@auto' => true, |
43 | 62 | // '@auto:risky' => true, |
|
47 | 66 | // '@DoctrineAnnotation' => true, |
48 | 67 | // '@PHP7x4Migration' => true, |
49 | 68 | // '@PHP7x4Migration:risky' => true, |
50 | | - '@PHP8x0Migration' => true, |
51 | | - '@PHP8x0Migration:risky' => true, |
52 | | - // '@PHP8x1Migration' => true, |
| 69 | + // '@PHP8x0Migration' => true, |
| 70 | + // '@PHP8x0Migration:risky' => true, |
| 71 | + '@PHP8x1Migration' => true, |
53 | 72 | // '@PHP8x1Migration:risky' => true, |
54 | 73 | // '@PHP8x2Migration' => true, |
55 | 74 | // '@PHP8x2Migration:risky' => true, |
|
63 | 82 | // '@PhpCsFixer:risky' => true, |
64 | 83 | // '@PHPUnit8x4Migration:risky' => true, |
65 | 84 | // '@PHPUnit9x1Migration:risky' => true, |
66 | | - // '@PHPUnit10x0Migration:risky' => true, |
| 85 | + '@PHPUnit10x0Migration:risky' => true, |
| 86 | + ])) |
| 87 | + ->withRules(Rules::fromArray([ |
67 | 88 | 'attribute_empty_parentheses' => [ |
68 | 89 | 'use_parentheses' => false, |
69 | 90 | ], |
|
260 | 281 | ], |
261 | 282 | 'static_lambda' => false, // pest |
262 | 283 | 'static_private_method' => false, |
263 | | - ])); |
264 | | - |
265 | | -$ruleSet->withCustomFixers(Fixers::fromFixers( |
266 | | - ...array_filter( |
267 | | - iterator_to_array(new PhpCsFixerCustomFixers\Fixers), |
268 | | - static fn (AbstractFixer $fixer): bool => !$fixer instanceof DeprecatedFixerInterface |
269 | | - && !\array_key_exists($fixer->getName(), $ruleSet->rules()->toArray()) |
270 | | - ) |
271 | | -)); |
272 | | - |
273 | | -return Factory::fromRuleSet($ruleSet) |
| 284 | + ]))) |
| 285 | + ->setUsingCache(true) |
| 286 | + ->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache') |
| 287 | + ->setUnsupportedPhpVersionAllowed(true) |
274 | 288 | ->setFinder( |
| 289 | + /** |
| 290 | + * @see https://github.com/laravel/pint/blob/main/app/Commands/DefaultCommand.php |
| 291 | + * @see https://github.com/laravel/pint/blob/main/app/Factories/ConfigurationFactory.php |
| 292 | + * @see https://github.com/laravel/pint/blob/main/app/Repositories/ConfigurationJsonRepository.php |
| 293 | + */ |
275 | 294 | Finder::create() |
276 | | - ->in([ |
277 | | - __DIR__.'/benchmarks/', |
278 | | - __DIR__.'/examples/', |
279 | | - __DIR__.'/src/', |
280 | | - __DIR__.'/tests/', |
281 | | - ]) |
| 295 | + ->in(__DIR__) |
282 | 296 | ->exclude([ |
283 | | - '__snapshots__', |
284 | | - 'Fixtures', |
| 297 | + '__snapshots__/', |
| 298 | + 'Fixtures/', |
| 299 | + 'vendor-bin/', |
285 | 300 | ]) |
| 301 | + ->notPath([ |
| 302 | + // '/lang\/.*\.json$/', |
| 303 | + ]) |
| 304 | + ->notName([ |
| 305 | + '/\.blade\.php$/', |
| 306 | + ]) |
| 307 | + ->ignoreDotFiles(false) |
| 308 | + ->ignoreUnreadableDirs(false) |
| 309 | + ->ignoreVCS(true) |
| 310 | + ->ignoreVCSIgnored(true) |
286 | 311 | ->append([ |
287 | | - ...array_filter( |
288 | | - glob(__DIR__.'/{*,.*}.php', \GLOB_BRACE), |
289 | | - static fn (string $filename): bool => !\in_array($filename, [ |
290 | | - __DIR__.'/.phpstorm.meta.php', |
291 | | - // __DIR__.'/_ide_helper.php', |
292 | | - __DIR__.'/_ide_helper_models.php', |
293 | | - ], true) |
294 | | - ), |
295 | 312 | __DIR__.'/composer-updater', |
296 | 313 | ]) |
297 | | - ) |
298 | | - ->setRiskyAllowed(true) |
299 | | - ->setUsingCache(true) |
300 | | - ->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache'); |
| 314 | + ); |
0 commit comments