From 08ac19c956c2608188bca81044034bc2590a8d55 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Jan 2024 16:15:31 +0100 Subject: [PATCH] [cs] Make use of new ECS config (#5445) * [cs] Make use of new ECS config * apply cs * cs --- composer.json | 2 +- ecs.php | 22 ++++++------------- scoper.php | 6 ++--- src/NodeTypeResolver/NodeTypeResolver.php | 2 +- src/Testing/Fixture/FixtureFileUpdater.php | 6 ++--- src/Testing/Fixture/FixtureSplitter.php | 1 + src/Testing/Fixture/FixtureTempFileDumper.php | 4 +++- .../config/configured_rule.php | 7 ++---- 8 files changed, 19 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index c196275aaf6..bb41da2742c 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "rector/rector-generator": "^0.7", "spatie/enum": "^3.13", "symplify/easy-ci": "^11.3", - "symplify/easy-coding-standard": "^12.0", + "symplify/easy-coding-standard": "^12.1", "symplify/phpstan-extensions": "^11.4", "symplify/phpstan-rules": "^12.2", "symplify/rule-doc-generator": "^12.1", diff --git a/ecs.php b/ecs.php index f19edcf4a5c..9bf39828179 100644 --- a/ecs.php +++ b/ecs.php @@ -3,15 +3,12 @@ declare(strict_types=1); use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer; -use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; -use Symplify\EasyCodingStandard\ValueObject\Set\SetList; -return static function (ECSConfig $ecsConfig): void { - $ecsConfig->sets([SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE, SetList::PSR_12]); - - $ecsConfig->paths([ +return ECSConfig::configure() + ->withPreparedSets(symplify: true, common: true, psr12: true) + ->withPaths([ __DIR__ . '/bin', __DIR__ . '/src', __DIR__ . '/rules', @@ -19,14 +16,9 @@ __DIR__ . '/tests', __DIR__ . '/utils', __DIR__ . '/config', - __DIR__ . '/ecs.php', - __DIR__ . '/rector.php', __DIR__ . '/build/build-preload.php', - ]); - - $ecsConfig->rules([FunctionTypehintSpaceFixer::class]); - - $ecsConfig->skip([ + ]) + ->withSkip([ '*/Source/*', '*/Fixture/*', '*/Expected/*', @@ -39,5 +31,5 @@ ], SelfAccessorFixer::class => ['*/*Rector.php'], - ]); -}; + ]) + ->withRootFiles(); diff --git a/scoper.php b/scoper.php index 6159709369f..a5f9080552b 100644 --- a/scoper.php +++ b/scoper.php @@ -43,9 +43,7 @@ '#^Symplify\\\\RuleDocGenerator#', '#^Symfony\\\\Polyfill#', ], - 'exclude-files' => [ - ...$polyfillsBootstraps, - ], + 'exclude-files' => [...$polyfillsBootstraps], // expose 'expose-classes' => ['Normalizer'], @@ -60,7 +58,7 @@ $content ), - static fn(string $filePath, string $prefix, string $content): string => + static fn (string $filePath, string $prefix, string $content): string => // comment out str_replace('\\' . $prefix . '\trigger_deprecation(', '// \trigger_deprecation(', $content), diff --git a/src/NodeTypeResolver/NodeTypeResolver.php b/src/NodeTypeResolver/NodeTypeResolver.php index 5ad14a2df62..d41651e020b 100644 --- a/src/NodeTypeResolver/NodeTypeResolver.php +++ b/src/NodeTypeResolver/NodeTypeResolver.php @@ -4,7 +4,6 @@ namespace Rector\NodeTypeResolver; -use PhpParser\Node\Expr\NullsafeMethodCall; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayDimFetch; @@ -13,6 +12,7 @@ use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\New_; +use PhpParser\Node\Expr\NullsafeMethodCall; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\Ternary; use PhpParser\Node\Name; diff --git a/src/Testing/Fixture/FixtureFileUpdater.php b/src/Testing/Fixture/FixtureFileUpdater.php index 04fb25fba29..b846e7d54f5 100644 --- a/src/Testing/Fixture/FixtureFileUpdater.php +++ b/src/Testing/Fixture/FixtureFileUpdater.php @@ -25,10 +25,8 @@ public static function updateFixtureContent( FileSystem::write($fixtureFilePath, $newOriginalContent); } - private static function resolveNewFixtureContent( - string $originalContent, - string $changedContent - ): string { + private static function resolveNewFixtureContent(string $originalContent, string $changedContent): string + { if ($originalContent === $changedContent) { return $originalContent; } diff --git a/src/Testing/Fixture/FixtureSplitter.php b/src/Testing/Fixture/FixtureSplitter.php index 2504a2308c4..123abbe3cf2 100644 --- a/src/Testing/Fixture/FixtureSplitter.php +++ b/src/Testing/Fixture/FixtureSplitter.php @@ -1,4 +1,5 @@ rules([ - ChangeSwitchToMatchRector::class, - TernaryFalseExpressionToIfRector::class - ]); + $rectorConfig->rules([ChangeSwitchToMatchRector::class, TernaryFalseExpressionToIfRector::class]); };