Skip to content

Commit

Permalink
[cs] Make use of new ECS config (#5445)
Browse files Browse the repository at this point in the history
* [cs] Make use of new ECS config

* apply cs

* cs
  • Loading branch information
TomasVotruba committed Jan 8, 2024
1 parent e3ccf17 commit 08ac19c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 7 additions & 15 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,22 @@
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',
__DIR__ . '/rules-tests',
__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/*',
Expand All @@ -39,5 +31,5 @@
],

SelfAccessorFixer::class => ['*/*Rector.php'],
]);
};
])
->withRootFiles();
6 changes: 2 additions & 4 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
'#^Symplify\\\\RuleDocGenerator#',
'#^Symfony\\\\Polyfill#',
],
'exclude-files' => [
...$polyfillsBootstraps,
],
'exclude-files' => [...$polyfillsBootstraps],

// expose
'expose-classes' => ['Normalizer'],
Expand All @@ -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),

Expand Down
2 changes: 1 addition & 1 deletion src/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Rector\NodeTypeResolver;

use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch;
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/Testing/Fixture/FixtureFileUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Testing/Fixture/FixtureSplitter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Rector\Testing\Fixture;
Expand Down
4 changes: 3 additions & 1 deletion src/Testing/Fixture/FixtureTempFileDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ final class FixtureTempFileDumper
public static function dump(string $fileContents, string $suffix = 'php'): string
{
// the "php" suffix is important, because that will hook into \Rector\Application\FileProcessor\PhpFileProcessor
$temporaryFileName = sys_get_temp_dir() . self::TEMP_FIXTURE_DIRECTORY . '/' . md5($fileContents) . '.' . $suffix;
$temporaryFileName = sys_get_temp_dir() . self::TEMP_FIXTURE_DIRECTORY . '/' . md5(
$fileContents
) . '.' . $suffix;
FileSystem::write($temporaryFileName, $fileContents);

return $temporaryFileName;
Expand Down
7 changes: 2 additions & 5 deletions tests/Issues/ChangeSwitchTernary/config/configured_rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

declare(strict_types=1);

use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\CodeQuality\Rector\Expression\TernaryFalseExpressionToIfRector;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
ChangeSwitchToMatchRector::class,
TernaryFalseExpressionToIfRector::class
]);
$rectorConfig->rules([ChangeSwitchToMatchRector::class, TernaryFalseExpressionToIfRector::class]);
};

0 comments on commit 08ac19c

Please sign in to comment.