Skip to content

Commit

Permalink
Merge pull request #20 from philbates35/fix-rector
Browse files Browse the repository at this point in the history
Fix Rector
  • Loading branch information
philbates35 authored Feb 15, 2024
2 parents 42b0ba6 + c9d1908 commit 7b71bab
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
use Rector\Config\RectorConfig;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use RectorLaravel\Set\LaravelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/app',
__DIR__ . '/bootstrap',
__DIR__ . '/config',
__DIR__ . '/public',
__DIR__ . '/resources',
__DIR__ . '/routes',
__DIR__ . '/tests',
]);

$rectorConfig->skip([
__DIR__ . '/bootstrap/cache',
]);

])
->withRootFiles()
// Larastan's bootstrap file doesn't run when Rector boots PHPStan, so we need to include it manually. See:
// * https://github.com/rectorphp/rector/issues/8006
// * https://github.com/larastan/larastan/issues/1664#issuecomment-1637152828
$rectorConfig->bootstrapFiles([__DIR__ . '/vendor/larastan/larastan/bootstrap.php']);
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon.dist');

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_83,

SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::STRICT_BOOLEANS,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,

->withBootstrapFiles([__DIR__ . '/vendor/larastan/larastan/bootstrap.php'])
// All extensions except PHPStan bleeding edge. See:
// * https://github.com/rectorphp/rector/issues/8492#issuecomment-1944428821
->withPHPStanConfigs([
__DIR__ . '/vendor/larastan/larastan/extension.neon',
__DIR__ . '/vendor/phpstan/phpstan-mockery/extension.neon',
__DIR__ . '/vendor/phpstan/phpstan-phpunit/extension.neon',
__DIR__ . '/vendor/phpstan/phpstan-phpunit/rules.neon',
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
])
->withPhpSets()
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
privatization: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true,
)
->withSets([
LaravelSetList::LARAVEL_100,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES,
Expand All @@ -50,15 +50,11 @@
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);

$rectorConfig->skip([
// Enforcing final on everything doesn't really offer much value, and stops up from
// mocking a concrete class, in the rare occasion we need to do so.
FinalizeClassesWithoutChildrenRector::class,
])
->withSkip([
__DIR__ . '/bootstrap/cache',

// TODO Stop skipping this rule as soon as phpcs supports typed const
// See: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/106
AddTypeToConstRector::class,
]);
};

0 comments on commit 7b71bab

Please sign in to comment.