Skip to content

Commit 3413928

Browse files
committed
style: apply php-cs-fixer
1 parent 27786bf commit 3413928

File tree

2 files changed

+63
-49
lines changed

2 files changed

+63
-49
lines changed

.php-cs-fixer.php

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
/** @noinspection PhpUnusedAliasInspection */
4+
35
declare(strict_types=1);
46

57
/**
@@ -19,25 +21,42 @@
1921
use Ergebnis\PhpCsFixer\Config\Factory;
2022
use Ergebnis\PhpCsFixer\Config\Fixers;
2123
use Ergebnis\PhpCsFixer\Config\Rules;
22-
use Ergebnis\PhpCsFixer\Config\RuleSet\Php80;
24+
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81;
2325
use PhpCsFixer\Finder;
2426
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
2527
use PhpCsFixerCustomFixers\Fixer\AbstractFixer;
2628

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');
3636

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+
);
3849

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+
)))
4160
->withRules(Rules::fromArray([
4261
// '@auto' => true,
4362
// '@auto:risky' => true,
@@ -47,9 +66,9 @@
4766
// '@DoctrineAnnotation' => true,
4867
// '@PHP7x4Migration' => true,
4968
// '@PHP7x4Migration:risky' => true,
50-
'@PHP8x0Migration' => true,
51-
'@PHP8x0Migration:risky' => true,
52-
// '@PHP8x1Migration' => true,
69+
// '@PHP8x0Migration' => true,
70+
// '@PHP8x0Migration:risky' => true,
71+
'@PHP8x1Migration' => true,
5372
// '@PHP8x1Migration:risky' => true,
5473
// '@PHP8x2Migration' => true,
5574
// '@PHP8x2Migration:risky' => true,
@@ -63,7 +82,9 @@
6382
// '@PhpCsFixer:risky' => true,
6483
// '@PHPUnit8x4Migration:risky' => true,
6584
// '@PHPUnit9x1Migration:risky' => true,
66-
// '@PHPUnit10x0Migration:risky' => true,
85+
'@PHPUnit10x0Migration:risky' => true,
86+
]))
87+
->withRules(Rules::fromArray([
6788
'attribute_empty_parentheses' => [
6889
'use_parentheses' => false,
6990
],
@@ -260,41 +281,34 @@
260281
],
261282
'static_lambda' => false, // pest
262283
'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)
274288
->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+
*/
275294
Finder::create()
276-
->in([
277-
__DIR__.'/benchmarks/',
278-
__DIR__.'/examples/',
279-
__DIR__.'/src/',
280-
__DIR__.'/tests/',
281-
])
295+
->in(__DIR__)
282296
->exclude([
283-
'__snapshots__',
284-
'Fixtures',
297+
'__snapshots__/',
298+
'Fixtures/',
299+
'vendor-bin/',
285300
])
301+
->notPath([
302+
// '/lang\/.*\.json$/',
303+
])
304+
->notName([
305+
'/\.blade\.php$/',
306+
])
307+
->ignoreDotFiles(false)
308+
->ignoreUnreadableDirs(false)
309+
->ignoreVCS(true)
310+
->ignoreVCSIgnored(true)
286311
->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-
),
295312
__DIR__.'/composer-updater',
296313
])
297-
)
298-
->setRiskyAllowed(true)
299-
->setUsingCache(true)
300-
->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');
314+
);

src/Support/Rectors/TransformToInternalExceptionRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private function createInternalException(Name $name): void
107107
$file = __DIR__."/../../Exceptions/{$name->getLast()}.php";
108108

109109
/** @noinspection MkdirRaceConditionInspection */
110-
is_dir($dir = \dirname($file)) or mkdir($dir, 0755, true);
110+
is_dir($dir = \dirname($file)) or mkdir($dir, 0o755, true);
111111

112112
file_put_contents(
113113
$file,

0 commit comments

Comments
 (0)