Skip to content

Commit

Permalink
[CS] Added rectorphp/rector
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Dec 28, 2024
1 parent 16f7f5f commit afd9c4c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
39 changes: 39 additions & 0 deletions build/phprectorconfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
use Rector\Set\ValueObject\SetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/../examples',
__DIR__ . '/../make',
__DIR__ . '/../src',
__DIR__ . '/../tests',
])
->withSkip([
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
])
->withPhp73Sets()
->withSets([
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
])
->withConfiguredRule(EncapsedStringsToSprintfRector::class, [
'always' => true,
])
->withRules([
RenamePropertyToMatchTypeRector::class,
RenameParamToMatchTypeRector::class,
RenameVariableToMatchNewTypeRector::class,
])
->withTypeCoverageLevel(0);
15 changes: 5 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
"require-dev": {
"nette/php-generator": "*",
"pdepend/pdepend": "^2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpdocumentor/reflection-docblock": "^5",
"phploc/phploc": "^7",
"phpmd/phpmd": "^2",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan": "^1|^2",
"phpunit/phpunit": "^9",
"rector/rector": "*",
"sebastian/phpcpd": "^6",
"squizlabs/php_codesniffer": "^3"
},
Expand Down Expand Up @@ -75,13 +76,7 @@
"vendor/bin/phpstan analyze -c build/phpstan.neon --autoload-file=vendor/autoload.php --no-interaction --no-progress --error-format=checkstyle > build/logs/checkstyle_phpstan.xml",
"vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml --exclude src/entities/ src"
],
"gitco": [
"@testsreal @no_additional_args",
"@phpcbf @no_additional_args",
"@checkstyle @no_additional_args",
"git add . @no_additional_args",
"git commit -m",
"git push @no_additional_args"
]
"rector": "vendor/bin/rector --config=./build/phprectorconfig.php",
"lint": "php -r 'echo PHP_VERSION_ID >= 80100 ? \"new\" : \"old\";' | xargs -I % sh -c 'if [ \"%\" = \"old\" ]; then find . \\( \\( -path \"./src*/*\" -not -path \"*codelistsenum*\" -not -path \"*codes*\" \\) -o -path \"./tests*/*\" \\) -type f -name \"*.php\" -exec php -l {} \\; ; else find . \\( \\( -path \"./src*/*\" -not -path \"*codes*\" \\) -o -path \"./tests*/*\" \\) -type f -name \"*.php\" -exec php -l {} \\; ; fi'"
}
}

0 comments on commit afd9c4c

Please sign in to comment.