10up / wp-scaffold

10up WordPress project scaffold.
MIT License
204 stars 48 forks source link

Add support for Rector #237

Open claytoncollie opened 1 month ago

claytoncollie commented 1 month ago

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

tobeycodes commented 1 week ago

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

<?php
/**
 * Rector configuration.
 *
 * @package XXX
 */

declare(strict_types=1);

use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
use Rector\Config\RectorConfig;
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php80\Rector\Identical\StrEndsWithRector;
use Rector\Php80\Rector\Identical\StrStartsWithRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
    ->withPaths(
        [
            __DIR__ . '/client-mu-plugins/xxx',
            __DIR__ . '/client-mu-plugins/xxx',
            __DIR__ . '/client-mu-plugins/xxx',
            __DIR__ . '/client-mu-plugins/xx',
            __DIR__ . '/themes/xxx',
        ]
    )
    ->withSkip(
        [
            __DIR__ . '/**/node_modules/**',
            __DIR__ . '/**/vendor/**',
            OptionalParametersAfterRequiredRector::class,
            LongArrayToShortArrayRector::class,
            TernaryToNullCoalescingRector::class,
            ClosureToArrowFunctionRector::class,
            StrEndsWithRector::class,
            ChangeSwitchToMatchRector::class,
            NullToStrictStringFuncCallArgRector::class,
            FirstClassCallableRector::class,
            AddOverrideAttributeToOverriddenMethodsRector::class,
            StringClassNameToClassConstantRector::class,
            TernaryToElvisRector::class,
            RemoveExtraParametersRector::class,
            ThisCallOnStaticMethodToStaticCallRector::class,
            ClassPropertyAssignToConstructorPromotionRector::class,
            IfIssetToCoalescingRector::class,
            ReadOnlyPropertyRector::class,
            StrContainsRector::class,
            AddClosureVoidReturnTypeWhereNoReturnRector::class,
            MixedTypeRector::class,
            StrStartsWithRector::class,
            StringifyStrNeedlesRector::class,
        ]
    )
    ->withPhpSets( php83: true )
    ->withTypeCoverageLevel( 0 );