-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Rector #237
Labels
Comments
I did a upgrade to php8.3 last week and this is the config I used. The rules that I disabled were good rules but they changed a lot of the codebase for things that were using new PHP features not fixing deprecated/breaking changes. I'd love to see all these rules enabled though by default in wp-scaffold
|
@tobeycodes Here is the config I am using for new sites. <?php
/**
* Rector Rules
*
* @see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md
*/
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;
use Rector\Set\ValueObject\SetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
return static function ( RectorConfig $rectorConfig ): void {
$rectorConfig->paths(
[
__DIR__ . '/themes/theme-name',
__DIR__ . '/mu-plugins/plugin-name'
]
);
$rectorConfig->skip(
[
__DIR__ . '/**/dist/**',
__DIR__ . '/**/node_modules/**',
__DIR__ . '/**/vendor/**',
DisallowedEmptyRuleFixerRector::class,
SimplifyEmptyArrayCheckRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,
NewlineAfterStatementRector::class,
RenameParamToMatchTypeRector::class,
TernaryToElvisRector::class,
RemoveExtraParametersRector::class,
ClosureToArrowFunctionRector::class,
FirstClassCallableRector::class,
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
RemoveUselessReturnTagRector::class,
RenamePropertyToMatchTypeRector::class,
ExplicitBoolCompareRector::class,
RemoveUselessVarTagRector::class,
RenameVariableToMatchMethodCallReturnTypeRector::class,
]
);
$rectorConfig->autoloadPaths(
[
__DIR__ . '/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php',
]
);
$rectorConfig->phpstanConfigs(
[
__DIR__ . '/phpstan.neon',
]
);
$rectorConfig->sets(
[
SetList::STRICT_BOOLEANS,
SetList::GMAGICK_TO_IMAGICK,
SetList::NAMING,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::PHP_82,
LevelSetList::UP_TO_PHP_82,
]
);
$rectorConfig->phpVersion( PhpVersion::PHP_82 );
}; |
@claytoncollie Thanks for sharing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your enhancement related to a problem? Please describe.
Similar to #201 but this ticket is specific to adding support for Rector.
This might even be an open feature branch similar to #133
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: