fsylum/rector-wordpress

Rector upgrades rules for WordPress

Installs: 4 847

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 0

Open Issues: 0

Type:rector-extension

0.4.0 2024-07-26 02:21 UTC

This package is auto-updated.

Last update: 2024-12-05 02:27:10 UTC


README

This package is a Rector extension developed to provide upgrades rules for WordPress.

Install

Install the rector-wordpress package as dependency:

composer require fsylum/rector-wordpress --dev

Use Sets

To add a set to your config, use Fsylum\RectorWordPress\Set\WordPressSetList class and pick one of the constants. For example, to update the codebase to WordPress 6.4, use WordPressSetList::WP_6_4.

use Fsylum\RectorWordPress\Set\WordPressSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        WordPressSetList::WP_6_4,
    ]);
};

You can also use a level set list to include all the applicable rules from the lowest version, 0.71 up to the one you specified. For example, WordPressLevelSetList::UP_TO_WP_6_4 will include all the rules from WordPress 0.71 up to 6.4. In most cases, this is the preferable way to transform your code as you only need to specify it once.

use Fsylum\RectorWordPress\Set\WordPressLevelSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        WordPressLevelSetList::UP_TO_WP_6_4,
    ]);
};