fsylum / rector-wordpress
Rector upgrades rules for WordPress
Installs: 6 474
Dependents: 0
Suggesters: 0
Security: 0
Stars: 22
Watchers: 3
Forks: 4
Open Issues: 1
Type:rector-extension
pkg:composer/fsylum/rector-wordpress
Requires
- php: >=8.2
- rector/rector: ^2.0
- webmozart/assert: ^1.11
Requires (Dev)
- ergebnis/composer-normalize: ^2.41
- laravel/pint: ^1.25
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^10.5
README
This package is a Rector extension developed to provide upgrade rules for WordPress.
Requirements
- PHP 8.2 or higher
- Rector 2.0 or higher
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.8, use WordPressSetList::WP_6_8.
use Fsylum\RectorWordPress\Set\WordPressSetList; use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { $rectorConfig->sets([ WordPressSetList::WP_6_8, ]); };
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_8 will include all the rules from WordPress 0.71 up to 6.8. 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_8, ]); };
Supported WordPress Versions
This package provides upgrade rules for WordPress versions from 0.71 to 6.8, covering:
- WordPress 0.71, 1.0, 1.2, 1.5
- WordPress 2.x (2.0 through 2.9)
- WordPress 3.x (3.0 through 3.9)
- WordPress 4.x (4.0 through 4.9)
- WordPress 5.x (5.0 through 5.9)
- WordPress 6.x (6.0 through 6.8)