Skip to content

Commit

Permalink
Merge pull request #45 from stickeeuk/rector-upgrade
Browse files Browse the repository at this point in the history
chore: Upgrade Rector configuration for php8.3/laravel 11
  • Loading branch information
stickeeoliver committed Jul 18, 2024
2 parents 01b657e + fed2111 commit a27aa14
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
"name": "stickee/rector-config",
"type": "library",
"require": {
"php": "^8.1",
"rector/rector": "^0.18.13",
"driftingly/rector-laravel": "^0.26.2"
"php": "^8.3",
"rector/rector": "^1.1.1",
"driftingly/rector-laravel": "^1.2.0"
},
"license": "MIT",
"authors": [
{
"name": "Paul",
"name": "Paul Tibbetts",
"email": "paul.tibbetts@stickee.co.uk"
},
{
"name": "Oliver Earl",
"email": "oliver.earl@stickee.co.uk"
}
]
}
43 changes: 19 additions & 24 deletions dist/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,28 @@

declare(strict_types=1);

use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use RectorLaravel\Set\LaravelSetList;
use RectorLaravel\Set\LaravelLevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/app'
]);

$rectorConfig->sets([
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::TYPE_DECLARATION,
LevelSetList::UP_TO_PHP_81,
return RectorConfig::configure()
->withPaths([__DIR__ . '/app'])
->withPhpSets()
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
)
->withSets([
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelLevelSetList::UP_TO_LARAVEL_90,
LaravelLevelSetList::UP_TO_LARAVEL_110,
])
->withSkip([
EncapsedStringsToSprintfRector::class, // changes "th{$is}" to sprintf('th%s', 'is')
MixedTypeRector::class, // removes docblocks
PostIncDecToPreIncDecRector::class, // changes $i++ to ++$i
]);

$rectorConfig->skip([
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, // removes @param from docblocks
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, // removes return from docblocks
\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class, // changes $i++ to ++$i
\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class, // changes "th{$is}" to sprintf('th%s', 'is')
\Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, // removes docblocks
]);

};

0 comments on commit a27aa14

Please sign in to comment.