diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..cf7999f --- /dev/null +++ b/config/config.php @@ -0,0 +1,36 @@ +ruleWithConfiguration(RemoveFuncCallArgRector::class, [ + new RemoveFuncCallArg('_imaginary_function_that_should_not_exists', 0), + ]); + + $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ + new FunctionParameterAdder('_imaginary_function_that_should_not_exists', 0, 'foo'), + ]); + + $rectorConfig->ruleWithConfiguration(ParameterPrependerRector::class, [ + new FunctionParameterPrepender('_imaginary_function_that_should_not_exists', 'foo'), + ]); +}; diff --git a/config/sets/wp-0.71.php b/config/sets/wp-0.71.php index cbe9652..a23e21f 100644 --- a/config/sets/wp-0.71.php +++ b/config/sets/wp-0.71.php @@ -5,6 +5,8 @@ use Rector\Removing\ValueObject\RemoveFuncCallArg; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('convert_chars', 1), ]); diff --git a/config/sets/wp-1.0.php b/config/sets/wp-1.0.php index 9fd6cbb..03f6922 100644 --- a/config/sets/wp-1.0.php +++ b/config/sets/wp-1.0.php @@ -2,4 +2,6 @@ use Rector\Config\RectorConfig; -return static function (RectorConfig $rectorConfig): void {}; +return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); +}; diff --git a/config/sets/wp-1.2.php b/config/sets/wp-1.2.php index a141a78..4a46cdd 100644 --- a/config/sets/wp-1.2.php +++ b/config/sets/wp-1.2.php @@ -4,6 +4,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ 'permalink_link' => 'the_permalink', ]); diff --git a/config/sets/wp-1.5.php b/config/sets/wp-1.5.php index 62ba7c0..af08880 100644 --- a/config/sets/wp-1.5.php +++ b/config/sets/wp-1.5.php @@ -5,6 +5,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_action', 0, 'retreive_password', 'retrieve_password'), new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'rewrite_rules', 'mod_rewrite_rules'), diff --git a/config/sets/wp-2.0.php b/config/sets/wp-2.0.php index aa445cb..bf3d4e9 100644 --- a/config/sets/wp-2.0.php +++ b/config/sets/wp-2.0.php @@ -4,6 +4,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ 'create_user' => 'wp_create_user', ]); diff --git a/config/sets/wp-2.1.php b/config/sets/wp-2.1.php index 95b2832..479bccc 100644 --- a/config/sets/wp-2.1.php +++ b/config/sets/wp-2.1.php @@ -1,8 +1,5 @@ import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('get_the_author', 0), new RemoveFuncCallArg('get_autotoggle', 0), @@ -17,25 +16,18 @@ new RemoveFuncCallArg('wp_set_post_cats', 0), ]); - $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ - new FunctionParameterAdder('get_autotoggle', 0, 0), - ]); - $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'links_popup_script', ]); $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ + 'get_autotoggle' => '__return_zero', 'get_link' => 'get_bookmark', 'get_settings' => 'get_option', 'wp_get_post_cats' => 'wp_get_post_categories', 'wp_set_post_cats' => 'wp_set_post_categories', ]); - $rectorConfig->ruleWithConfiguration(ReturnFirstArgumentRector::class, [ - 'get_autotoggle', - ]); - /* * TODO: these are not handled currently * diff --git a/config/sets/wp-2.2.php b/config/sets/wp-2.2.php index ce72b42..a1b33d2 100644 --- a/config/sets/wp-2.2.php +++ b/config/sets/wp-2.2.php @@ -3,6 +3,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + /* * TODO: these are not handled currently * diff --git a/config/sets/wp-2.3.php b/config/sets/wp-2.3.php index 8f866cf..1b491ed 100644 --- a/config/sets/wp-2.3.php +++ b/config/sets/wp-2.3.php @@ -6,6 +6,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('permalink_single_rss', 0), ]); diff --git a/config/sets/wp-2.5.php b/config/sets/wp-2.5.php index cf44d4d..15afc2c 100644 --- a/config/sets/wp-2.5.php +++ b/config/sets/wp-2.5.php @@ -7,6 +7,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('trackback_rdf', 0), new RemoveFuncCallArg('wp_login', 2), diff --git a/config/sets/wp-2.6.php b/config/sets/wp-2.6.php index 246e888..71df20f 100644 --- a/config/sets/wp-2.6.php +++ b/config/sets/wp-2.6.php @@ -3,6 +3,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + /* * TODO: these are not handled currently * diff --git a/config/sets/wp-2.7.php b/config/sets/wp-2.7.php index 3113b1d..5511966 100644 --- a/config/sets/wp-2.7.php +++ b/config/sets/wp-2.7.php @@ -8,6 +8,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('discover_pingback_server_uri', 1), new RemoveFuncCallArg('wp_get_http_headers', 1), diff --git a/config/sets/wp-2.8.php b/config/sets/wp-2.8.php index 5913bc0..82a42ee 100644 --- a/config/sets/wp-2.8.php +++ b/config/sets/wp-2.8.php @@ -12,6 +12,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'tagsperpage', 'edit_tags_per_page'), ]); diff --git a/config/sets/wp-2.9.php b/config/sets/wp-2.9.php index c6375be..44cbb49 100644 --- a/config/sets/wp-2.9.php +++ b/config/sets/wp-2.9.php @@ -3,6 +3,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + /* * TODO: these are not handled currently * diff --git a/config/sets/wp-3.0.php b/config/sets/wp-3.0.php index 3a147fd..b9a1f5c 100644 --- a/config/sets/wp-3.0.php +++ b/config/sets/wp-3.0.php @@ -12,6 +12,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_settings_field', 3, 'misc', 'general'), new ReplaceFuncCallArgumentDefaultValue('add_settings_section', 3, 'misc', 'general'), diff --git a/config/sets/wp-3.1.php b/config/sets/wp-3.1.php index ad74d79..56532fc 100644 --- a/config/sets/wp-3.1.php +++ b/config/sets/wp-3.1.php @@ -8,6 +8,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'tag_rewrite_rules', 'post_tag_rewrite_rules'), ]); diff --git a/config/sets/wp-3.2.php b/config/sets/wp-3.2.php index 000c168..99a9ccd 100644 --- a/config/sets/wp-3.2.php +++ b/config/sets/wp-3.2.php @@ -5,6 +5,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'favorite_actions', ]); diff --git a/config/sets/wp-3.3.php b/config/sets/wp-3.3.php index fa07335..df3d761 100644 --- a/config/sets/wp-3.3.php +++ b/config/sets/wp-3.3.php @@ -12,6 +12,8 @@ use Rector\Renaming\ValueObject\MethodCallRename; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ new FunctionParameterAdder('start_post_rel_link', 3, true), new FunctionParameterAdder('type_url_form_audio', 0, 'audio'), diff --git a/config/sets/wp-3.4.php b/config/sets/wp-3.4.php index c8f6f95..a2fcf00 100644 --- a/config/sets/wp-3.4.php +++ b/config/sets/wp-3.4.php @@ -9,6 +9,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ new FunctionParameterAdder('remove_custom_background', 0, 'custom-background'), new FunctionParameterAdder('remove_custom_image_header', 0, 'custom-header'), diff --git a/config/sets/wp-3.5.php b/config/sets/wp-3.5.php index 9dfd1c2..7ce7c6d 100644 --- a/config/sets/wp-3.5.php +++ b/config/sets/wp-3.5.php @@ -16,6 +16,8 @@ use Rector\Renaming\ValueObject\MethodCallRename; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_settings_field', 3, 'privacy', 'reading'), new ReplaceFuncCallArgumentDefaultValue('add_settings_section', 3, 'privacy', 'reading'), diff --git a/config/sets/wp-3.6.php b/config/sets/wp-3.6.php index a7220a4..e13c3d5 100644 --- a/config/sets/wp-3.6.php +++ b/config/sets/wp-3.6.php @@ -7,6 +7,8 @@ use Rector\Transform\ValueObject\MethodCallToFuncCall; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(MethodCallToFuncCallRector::class, [ new MethodCallToFuncCall('wpdb', '_weak_escape', 'esc_sql'), new MethodCallToFuncCall('wpdb', 'escape', 'esc_sql'), diff --git a/config/sets/wp-3.7.php b/config/sets/wp-3.7.php index 6e79482..07ba5e0 100644 --- a/config/sets/wp-3.7.php +++ b/config/sets/wp-3.7.php @@ -4,6 +4,8 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'the_attachment_links', ]); diff --git a/config/sets/wp-3.8.php b/config/sets/wp-3.8.php index f8ab20f..3499c4c 100644 --- a/config/sets/wp-3.8.php +++ b/config/sets/wp-3.8.php @@ -6,6 +6,8 @@ use Rector\Removing\ValueObject\RemoveFuncCallArg; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('wp_notify_postauthor', 1), ]); diff --git a/config/sets/wp-3.9.php b/config/sets/wp-3.9.php index 0010ace..3e4a985 100644 --- a/config/sets/wp-3.9.php +++ b/config/sets/wp-3.9.php @@ -5,6 +5,8 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ '_relocate_children', ]); diff --git a/config/sets/wp-4.0.php b/config/sets/wp-4.0.php index 9058ff3..12d1f39 100644 --- a/config/sets/wp-4.0.php +++ b/config/sets/wp-4.0.php @@ -11,6 +11,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('define', 0, 'FORCE_SSL_LOGIN', 'FORCE_SSL_ADMIN'), ]); diff --git a/config/sets/wp-4.1.php b/config/sets/wp-4.1.php index 421c58b..2dae36d 100644 --- a/config/sets/wp-4.1.php +++ b/config/sets/wp-4.1.php @@ -4,6 +4,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveMethodCallRector::class, [ 'add_tab' => 'WP_Customize_Image_Control', 'prepare_control' => 'WP_Customize_Image_Control', diff --git a/config/sets/wp-4.2.php b/config/sets/wp-4.2.php index 67187f3..de0a9bf 100644 --- a/config/sets/wp-4.2.php +++ b/config/sets/wp-4.2.php @@ -6,6 +6,8 @@ use Rector\Removing\ValueObject\RemoveFuncCallArg; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('iframe_header', 1), ]); diff --git a/config/sets/wp-4.3.php b/config/sets/wp-4.3.php index e8ec126..9573141 100644 --- a/config/sets/wp-4.3.php +++ b/config/sets/wp-4.3.php @@ -10,6 +10,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'htmledit_pre', 'format_for_editor'), ]); diff --git a/config/sets/wp-4.4.php b/config/sets/wp-4.4.php index 0850c70..230cdd4 100644 --- a/config/sets/wp-4.4.php +++ b/config/sets/wp-4.4.php @@ -7,6 +7,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('get_site_option', 2), new RemoveFuncCallArg('get_wp_title_rss', 0), diff --git a/config/sets/wp-4.5.php b/config/sets/wp-4.5.php index c876f15..8d1d502 100644 --- a/config/sets/wp-4.5.php +++ b/config/sets/wp-4.5.php @@ -10,6 +10,8 @@ use Rector\Transform\ValueObject\MethodCallToFuncCall; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(MethodCallToFuncCallRector::class, [ new MethodCallToFuncCall('WP_Query', 'is_comments_popup', '__return_false'), ]); diff --git a/config/sets/wp-4.6.php b/config/sets/wp-4.6.php index 06c40e0..f340dd9 100644 --- a/config/sets/wp-4.6.php +++ b/config/sets/wp-4.6.php @@ -6,6 +6,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('install_search_form', 0), new RemoveFuncCallArg('wp_embed_handler_googlevideo', 0), diff --git a/config/sets/wp-4.7.php b/config/sets/wp-4.7.php index 425cf90..e8d0244 100644 --- a/config/sets/wp-4.7.php +++ b/config/sets/wp-4.7.php @@ -15,6 +15,8 @@ use Rector\Renaming\ValueObject\MethodCallRename; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'blog_details', 'site_details'), ]); diff --git a/config/sets/wp-4.8.php b/config/sets/wp-4.8.php index cd38b2b..ea9d738 100644 --- a/config/sets/wp-4.8.php +++ b/config/sets/wp-4.8.php @@ -5,6 +5,8 @@ use Rector\Removing\ValueObject\RemoveFuncCallArg; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('get_category_parents', 4), ]); diff --git a/config/sets/wp-4.9.php b/config/sets/wp-4.9.php index 268ad85..1471506 100644 --- a/config/sets/wp-4.9.php +++ b/config/sets/wp-4.9.php @@ -9,6 +9,8 @@ use Rector\Renaming\ValueObject\MethodCallRename; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('term_description', 1), ]); diff --git a/config/sets/wp-5.0.php b/config/sets/wp-5.0.php index 9fd6cbb..03f6922 100644 --- a/config/sets/wp-5.0.php +++ b/config/sets/wp-5.0.php @@ -2,4 +2,6 @@ use Rector\Config\RectorConfig; -return static function (RectorConfig $rectorConfig): void {}; +return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); +}; diff --git a/config/sets/wp-5.1.php b/config/sets/wp-5.1.php index 92be0c4..3dd7170 100644 --- a/config/sets/wp-5.1.php +++ b/config/sets/wp-5.1.php @@ -4,6 +4,8 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'upgrade_500', ]); diff --git a/config/sets/wp-5.2.php b/config/sets/wp-5.2.php index ac48fc6..166c54d 100644 --- a/config/sets/wp-5.2.php +++ b/config/sets/wp-5.2.php @@ -5,6 +5,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'login_headertitle', 'login_headertext'), ]); diff --git a/config/sets/wp-5.3.php b/config/sets/wp-5.3.php index 951f363..43665ac 100644 --- a/config/sets/wp-5.3.php +++ b/config/sets/wp-5.3.php @@ -8,6 +8,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ new FunctionParameterAdder('wp_rel_nofollow_callback', 1, 'nofollow'), ]); diff --git a/config/sets/wp-5.4.php b/config/sets/wp-5.4.php index 0c07533..4bac342 100644 --- a/config/sets/wp-5.4.php +++ b/config/sets/wp-5.4.php @@ -4,6 +4,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ 'wp_get_user_request_data' => 'wp_get_user_request', ]); diff --git a/config/sets/wp-5.5.php b/config/sets/wp-5.5.php index 1348bc7..d783b52 100644 --- a/config/sets/wp-5.5.php +++ b/config/sets/wp-5.5.php @@ -7,6 +7,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [ new ReplaceFuncCallArgumentDefaultValue('add_action', 0, 'wp_blacklist_check', 'wp_check_comment_disallowed_list'), new ReplaceFuncCallArgumentDefaultValue('add_filter', 0, 'whitelist_options', 'allowed_options'), diff --git a/config/sets/wp-5.6.php b/config/sets/wp-5.6.php index 600ec36..06af854 100644 --- a/config/sets/wp-5.6.php +++ b/config/sets/wp-5.6.php @@ -4,6 +4,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ 'addslashes_strings_only' => 'wp_slash', ]); diff --git a/config/sets/wp-5.7.php b/config/sets/wp-5.7.php index 62a0d5b..4fe4dac 100644 --- a/config/sets/wp-5.7.php +++ b/config/sets/wp-5.7.php @@ -3,6 +3,8 @@ use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + /* * TODO: these are not handled currently * diff --git a/config/sets/wp-5.8.php b/config/sets/wp-5.8.php index c70d0a0..7ad1c9b 100644 --- a/config/sets/wp-5.8.php +++ b/config/sets/wp-5.8.php @@ -4,6 +4,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [ '_excerpt_render_inner_columns_blocks' => '_excerpt_render_inner_blocks', ]); diff --git a/config/sets/wp-5.9.php b/config/sets/wp-5.9.php index 96bbebe..bea12c9 100644 --- a/config/sets/wp-5.9.php +++ b/config/sets/wp-5.9.php @@ -8,6 +8,8 @@ use Rector\Transform\ValueObject\StaticCallToFuncCall; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [ new RemoveFuncCallArg('_load_remote_block_patterns', 0), ]); diff --git a/config/sets/wp-6.0.php b/config/sets/wp-6.0.php index 98ffa53..5585f5a 100644 --- a/config/sets/wp-6.0.php +++ b/config/sets/wp-6.0.php @@ -5,6 +5,8 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'wp_add_iframed_editor_assets_html', ]); diff --git a/config/sets/wp-6.1.php b/config/sets/wp-6.1.php index a4682c3..8abb7da 100644 --- a/config/sets/wp-6.1.php +++ b/config/sets/wp-6.1.php @@ -6,6 +6,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(RemoveFuncCallRector::class, [ 'install_global_terms', ]); diff --git a/config/sets/wp-6.2.php b/config/sets/wp-6.2.php index 17a766a..8f39aa2 100644 --- a/config/sets/wp-6.2.php +++ b/config/sets/wp-6.2.php @@ -5,6 +5,8 @@ use Rector\Transform\ValueObject\StaticCallToFuncCall; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(StaticCallToFuncCallRector::class, [ new StaticCallToFuncCall('WP_Theme_JSON_Resolver', 'theme_has_support', 'wp_theme_has_theme_json'), ]); diff --git a/config/sets/wp-6.3.php b/config/sets/wp-6.3.php index fbc54ff..6037d8c 100644 --- a/config/sets/wp-6.3.php +++ b/config/sets/wp-6.3.php @@ -9,6 +9,8 @@ use Rector\Renaming\ValueObject\MethodCallRename; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [ new MethodParameterAdder('WP_Metadata_Lazyloader', 'lazyload_comment_meta', 1, 0), new MethodParameterAdder('WP_Metadata_Lazyloader', 'lazyload_comment_meta', 2, ''), diff --git a/config/sets/wp-6.4.php b/config/sets/wp-6.4.php index ddfef34..f14b64a 100644 --- a/config/sets/wp-6.4.php +++ b/config/sets/wp-6.4.php @@ -5,6 +5,8 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; return static function (RectorConfig $rectorConfig): void { + $rectorConfig->import(__DIR__ . '/../config.php'); + $rectorConfig->ruleWithConfiguration(ConstToFuncCallRector::class, [ 'STYLESHEETPATH' => 'get_stylesheet_directory', 'TEMPLATEPATH' => 'get_template_directory', diff --git a/src/Rules/FuncCall/ParameterAdderRector.php b/src/Rules/FuncCall/ParameterAdderRector.php index b7a38b0..013042b 100644 --- a/src/Rules/FuncCall/ParameterAdderRector.php +++ b/src/Rules/FuncCall/ParameterAdderRector.php @@ -30,6 +30,8 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + $hasChanged = false; + foreach ($this->configuration as $config) { if (!$this->isName($node->name, $config->getFunction())) { continue; @@ -43,6 +45,11 @@ public function refactor(Node $node): ?Node } $node->args[$position] = $arg; + $hasChanged = true; + } + + if (!$hasChanged) { + return null; } return $node; diff --git a/src/Rules/FuncCall/ParameterPrependerRector.php b/src/Rules/FuncCall/ParameterPrependerRector.php index e9d5e86..3b449ac 100644 --- a/src/Rules/FuncCall/ParameterPrependerRector.php +++ b/src/Rules/FuncCall/ParameterPrependerRector.php @@ -30,6 +30,8 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + $hasChanged = false; + foreach ($this->configuration as $config) { if (!$this->isName($node->name, $config->getFunction())) { continue; @@ -42,6 +44,11 @@ public function refactor(Node $node): ?Node array_unshift($args, $arg); $node->args = $args; + $hasChanged = true; + } + + if (!$hasChanged) { + return null; } return $node; diff --git a/src/Rules/MethodCall/ReturnFirstArgumentRector.php b/src/Rules/MethodCall/ReturnFirstArgumentRector.php index 0865260..4c45a09 100644 --- a/src/Rules/MethodCall/ReturnFirstArgumentRector.php +++ b/src/Rules/MethodCall/ReturnFirstArgumentRector.php @@ -2,8 +2,10 @@ namespace Fsylum\RectorWordPress\Rules\MethodCall; +use PhpParser\Node\Arg; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node; +use PhpParser\Node\VariadicPlaceholder; use PHPStan\Type\ObjectType; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; @@ -26,7 +28,7 @@ public function getNodeTypes(): array /** * @param MethodCall $node */ - public function refactor(Node $node): ?Node + public function refactor(Node $node): null|Arg|VariadicPlaceholder { if (count($node->args) === 0) { return null; diff --git a/tests/Rector/Sets/Level/UpToWp64/UpToWp64Test.php b/tests/Rector/Sets/Level/UpToWp64/UpToWp64Test.php new file mode 100644 index 0000000..6fda14a --- /dev/null +++ b/tests/Rector/Sets/Level/UpToWp64/UpToWp64Test.php @@ -0,0 +1,29 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/../../../../../config/sets/level/up-to-wp-6.4.php'; + } +} diff --git a/tests/Rector/Sets/Level/UpToWp64/test_fixture.php.inc b/tests/Rector/Sets/Level/UpToWp64/test_fixture.php.inc new file mode 100644 index 0000000..3955789 --- /dev/null +++ b/tests/Rector/Sets/Level/UpToWp64/test_fixture.php.inc @@ -0,0 +1,679 @@ +print_scripts_l10n('foo'); +$foo = get_user_by_email('bar'); +$foo = get_userdatabylogin('bar'); +$foo = is_blog_user(1); +$foo = 'foo'; +$media = true; +the_editor($foo, 'bar', 'baz', false); +the_editor($foo, 'bar', 'baz', $media); + +// 3.4 +remove_custom_background(); +remove_custom_image_header(); +clean_page_cache(1); +$foo = current_theme_info(); +$foo = debug_fopen('foo', 'bar'); +$pages = [new WP_Post(new StdClass)]; +update_page_cache($pages); +debug_fclose('foo'); + +// 3.5 +add_settings_field('foo', 'bar', 'baz', 'privacy'); +add_settings_section('foo', 'bar', 'baz', 'privacy'); +register_setting('privacy', 'foo'); +unregister_setting('privacy', 'foo'); +get_default_page_to_edit(); +get_post_to_edit(1); +get_udims(32, 32); +$wpdb = new wpdb; +$wpdb->supports_collation(); +switch_to_blog(1, 'foo'); +wp_create_thumbnail('foo', 1, 'bar'); +$post = new WP_Post; +_get_post_ancestors($post); +_insert_into_post_button('foo'); +_media_button('foo', 'bar', 'baz', 'qux'); +_save_post_hook(); +ms_deprecated_blogs_file(); +wp_get_single_post(1); +get_page(1); +$foo = new Custom_Background; +$bar = $foo->attachment_fields_to_edit(['bar']); +$baz = $foo->filter_upload_tabs(['baz']); + +// 3.6 +wp_convert_bytes_to_hr(1); +wp_nav_menu_locations_meta_box(); +$wpdb = new wpdb; +$wpdb->_weak_escape('foo'); +$wpdb->escape('bar'); + +// 3.7 +foo(); +the_attachment_links(); + +// 3.8 +wp_notify_postauthor(1, 'foo'); +wp_dashboard_incoming_links(); +wp_dashboard_incoming_links_control(); +wp_dashboard_incoming_links_output(); +wp_dashboard_plugins(); +wp_dashboard_primary_control(); +wp_dashboard_recent_comments_control(); +wp_dashboard_secondary(); +wp_dashboard_secondary_control(); +wp_dashboard_secondary_output(); + +// 3.9 +foo(); +_relocate_children(1, 2); +$foo = default_topic_count_text(1); +$bar = format_to_post('bar'); +$baz = get_current_site_name(WP_Network::get_instance(1)); + +// 4.0 +delete_plugins(['foo'], 'bar'); +$bar = get_all_category_ids(); +define('FORCE_SSL_LOGIN', true); +$foo = FORCE_SSL_LOGIN; + +// 4.1 +$foo = new WP_Customize_Image_Control; +$foo->add_tab(); +$foo->prepare_control(); +$foo->print_tab_image(); +$foo->remove_tab(); +echo 'foo'; + +// 4.2 +iframe_header('foo', 'bar'); +$foo = new WP_Customize_Widgets; +$foo->prepreview_added_sidebars_widgets(); +$foo->prepreview_added_widget_instance(); +$foo->remove_prepreview_filters(); +$foo->setup_widget_addition_previews(); +echo 'bar'; + +// 4.3 +$foo = _preview_theme_stylesheet_filter(); +$bar = _preview_theme_template_filter(); +$baz = preview_theme_ob_filter_callback(['foo']); +$foo = wp_htmledit_pre('bar'); +add_filter('htmledit_pre', '__return_empty_string'); +preview_theme(); +$foo = preview_theme_ob_filter('bar'); + +// 4.4 +get_site_option('foo', 'bar', 'baz'); +get_wp_title_rss('foo'); +wp_title_rss('foo'); +force_ssl_login(); +$foo = post_permalink(); +$bar = new WP_Widget_Recent_Comments; +$bar->flush_widget_cache(); +foo(); + +// 4.5 +_wp_post_revision_fields(['foo'], 'bar'); +comments_popup_script(); +$foo = get_comments_popup_template(); +$bar = get_currentuserinfo(); +$foo = is_comments_popup(); +$query = new WP_Query(); +$foo = $query->is_comments_popup(); +$foo = $query->lazyload_comment_meta('foo', 1); +$bar = $query->lazyload_term_meta('bar', 1); + +// 4.6 +install_search_form(false); +$foo = wp_embed_handler_googlevideo('foo', 'bar', 'baz', 1); + +// 4.7 +unregister_setting('foo', 'bar', 'baz'); +get_paged_template(); +$foo = 'bar'; +$bar = wp_kses_js_entities($foo); +(new WP_Roles)->reinit(); +$baz = new WP_Roles; +$baz->reinit(); +add_filter('blog_details', '__return_empty_array'); +$class = new WP_Customize_Manager; +$class->customize_preview_base(); +$class->customize_preview_html5(); +$class->customize_preview_override_404_status(); +$class->customize_preview_signature(); +$foo = $class->remove_preview_signature('bar'); + +// 4.8 +get_category_parents(1, true, '-', 'foo', 'bar'); + +// 4.9 +term_description(1, 'foo'); +add_action('refresh_blog_details', '__return_false'); +$bar = new WP_User; +$bar->for_blog(1); +(new WP_User)->for_blog(2); + +// 5.1 +foo(); +upgrade_500(); + +// 5.2 +add_filter('login_headertitle', '__return_empty_string'); + +// 5.3 +$foo = _wp_json_prepare_data('bar'); +_wp_privacy_requests_screen_options(); +wp_rel_nofollow_callback(['foo', 'bar']); + +// 5.4 +wp_get_user_request_data(1); + +// 5.5 +$foo = _wp_register_meta_args_whitelist(['foo'], ['bar']); +$foo = add_option_whitelist(['foo'], 'bar'); +$foo = remove_option_whitelist(['foo'], 'bar'); +$foo = wp_blacklist_check('foo', 'bar', 'baz', 'foo', 'bar', 'baz'); +wp_make_content_images_responsive('foo'); +$type = 'check'; +$action = "wp_blacklist_{$type}"; +add_action($action, 'cb'); +add_filter('whitelist_options', '__return_empty_array'); + +// 5.6 +addslashes_strings_only('foo'); + +// 5.8 +$foo = ['foo']; +$bar = ['bar']; +_excerpt_render_inner_columns_blocks(['foo'], ['bar']); +_excerpt_render_inner_columns_blocks($foo, $bar); + +// 5.9 +_load_remote_block_patterns('foo'); +readonly( 'foo', true, false ); +wp_render_duotone_filter_preset(['foo', 'bar']); +$foo = WP_Theme_JSON_Resolver::get_fields_to_translate(); + +// 6.0 +$test = image_attachment_fields_to_save(['foo'], ['bar']); +wp_add_iframed_editor_assets_html(); + +// 6.1 +$foo = global_terms_enabled(); +install_global_terms(); +$foo = global_terms('foo'); +$foo = _wp_multiple_block_styles(['foo']); +$test = sync_category_tag_slugs(['foo'], 'bar'); + +// 6.2 +WP_Theme_JSON_Resolver::theme_has_support(); + +// 6.3 +$class = new WP_Metadata_Lazyloader; +$class->lazyload_comment_meta('foo'); +$class->lazyload_term_meta('foo'); +block_core_navigation_submenu_build_css_colors(['foo'], ['bar'], false); +wlwmanifest_link(); +wp_img_tag_add_loading_attr('foo', 'bar'); + +// 6.4 +print_embed_styles(); +print_emoji_styles(); +wp_admin_bar_header(); +_admin_bar_bump_cb(); +wp_img_tag_add_decoding_attr('foo', 'bar'); +$foo = TEMPLATEPATH; +$bar = STYLESHEETPATH; + +?> +----- +print_extra_script('foo'); +$foo = get_user_by('email', 'bar'); +$foo = get_user_by('login', 'bar'); +$foo = is_user_member_of_blog(get_current_user_id(), 1); +$foo = 'foo'; +$media = true; +wp_editor($foo, 'bar', ['media_buttons' => false]); +wp_editor($foo, 'bar', ['media_buttons' => $media]); + +// 3.4 +remove_theme_support('custom-background'); +remove_theme_support('custom-header'); +clean_post_cache(1); +$foo = wp_get_theme(); +$foo = __return_false(); +$pages = [new WP_Post(new StdClass)]; +update_post_cache($pages); + +// 3.5 +add_settings_field('foo', 'bar', 'baz', 'reading'); +add_settings_section('foo', 'bar', 'baz', 'reading'); +register_setting('reading', 'foo'); +unregister_setting('reading', 'foo'); +get_default_post_to_edit('page'); +get_post(1, OBJECT, 'edit'); +wp_constrain_dimensions(32, 32, 128, 96); +$wpdb = new wpdb; +$wpdb->has_cap('collation'); +switch_to_blog(1); +wp_create_thumbnail('foo', 1); +$post = new WP_Post; +get_post(1); +get_post(1); +$foo = new Custom_Background; +$bar = ['bar']; +$baz = ['baz']; + +// 3.6 +size_format(1); +$wpdb = new wpdb; +\esc_sql('foo'); +\esc_sql('bar'); + +// 3.7 +foo(); + +// 3.8 +wp_notify_postauthor(1); + +// 3.9 +foo(); +$foo = 1; +$bar = 'bar'; +$baz = WP_Network::get_instance(1); + +// 4.0 +delete_plugins(['foo']); +$bar = get_terms(['taxonomy' => 'category', 'fields' => 'ids', 'get' => 'all']); +define('FORCE_SSL_ADMIN', true); +$foo = FORCE_SSL_ADMIN; + +// 4.1 +$foo = new WP_Customize_Image_Control; +echo 'foo'; + +// 4.2 +iframe_header('foo'); +$foo = new WP_Customize_Widgets; +echo 'bar'; + +// 4.3 +$foo = __return_empty_string(); +$bar = __return_empty_string(); +$baz = __return_empty_string(); +$foo = format_for_editor('bar'); +add_filter('format_for_editor', '__return_empty_string'); +$foo = 'bar'; + +// 4.4 +get_site_option('foo', 'bar'); +get_wp_title_rss(); +wp_title_rss(); +force_ssl_admin(); +$foo = get_permalink(); +$bar = new WP_Widget_Recent_Comments; +foo(); + +// 4.5 +_wp_post_revision_fields(['foo']); +$foo = __return_empty_string(); +$bar = wp_get_current_user(); +$foo = __return_false(); +$query = new WP_Query(); +$foo = \__return_false(); +$foo = 'foo'; +$bar = 'bar'; + +// 4.6 +install_search_form(); +$foo = __return_empty_string(); + +// 4.7 +unregister_setting('foo', 'bar'); +get_query_template('paged'); +$foo = 'bar'; +$bar = preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $foo); +(new WP_Roles)->for_site(); +$baz = new WP_Roles; +$baz->for_site(); +add_filter('site_details', '__return_empty_array'); +$class = new WP_Customize_Manager; +$foo = 'bar'; + +// 4.8 +get_category_parents(1, true, '-', 'foo'); + +// 4.9 +term_description(1); +add_action('clean_site_cache', '__return_false'); +$bar = new WP_User; +$bar->for_site(1); +(new WP_User)->for_site(2); + +// 5.1 +foo(); + +// 5.2 +add_filter('login_headertext', '__return_empty_string'); + +// 5.3 +$foo = 'bar'; +wp_rel_callback(['foo', 'bar'], 'nofollow'); + +// 5.4 +wp_get_user_request(1); + +// 5.5 +$foo = _wp_register_meta_args_allowed_list(['foo'], ['bar']); +$foo = add_allowed_options(['foo'], 'bar'); +$foo = remove_allowed_options(['foo'], 'bar'); +$foo = wp_check_comment_disallowed_list('foo', 'bar', 'baz', 'foo', 'bar', 'baz'); +wp_filter_content_tags('foo'); +$type = 'check'; +$action = "wp_blacklist_{$type}"; +add_action('wp_check_comment_disallowed_list', 'cb'); +add_filter('allowed_options', '__return_empty_array'); + +// 5.6 +wp_slash('foo'); + +// 5.8 +$foo = ['foo']; +$bar = ['bar']; +_excerpt_render_inner_blocks(['foo'], ['bar']); +_excerpt_render_inner_blocks($foo, $bar); + +// 5.9 +_load_remote_block_patterns(); +wp_readonly( 'foo', true, false ); +wp_get_duotone_filter_property(['foo', 'bar']); +$foo = \__return_empty_array(); + +// 6.0 +$test = ['foo']; + +// 6.1 +$foo = __return_false(); +$foo = 'foo'; +$foo = ['foo']; +$test = ['foo']; + +// 6.2 +\wp_theme_has_theme_json(); + +// 6.3 +$class = new WP_Metadata_Lazyloader; +$class->lazyload_meta_callback('foo', 0, '', false, 'comment'); +$class->lazyload_meta_callback('foo', 0, '', false, 'term'); +block_core_navigation_link_build_css_colors(['foo'], ['bar'], false); +wp_img_tag_add_loading_optimization_attrs('foo', 'bar'); + +// 6.4 +wp_enqueue_embed_styles(); +wp_enqueue_emoji_styles(); +wp_enqueue_admin_bar_header_styles(); +wp_enqueue_admin_bar_bump_styles(); +wp_img_tag_add_loading_optimization_attrs('foo', 'bar'); +$foo = \get_template_directory(); +$bar = \get_stylesheet_directory(); + +?> diff --git a/tests/Rector/Sets/Wp21/test_fixture.php.inc b/tests/Rector/Sets/Wp21/test_fixture.php.inc index 5c9f555..0df1cc2 100644 --- a/tests/Rector/Sets/Wp21/test_fixture.php.inc +++ b/tests/Rector/Sets/Wp21/test_fixture.php.inc @@ -16,7 +16,7 @@ get_settings('foo'); lazyload_comment_meta('foo'); $class->lazyload_term_meta('foo'); -$wp_query = new WP_Query; - -$bar = ['bar']; - -$wp_query->lazyload_comment_meta('foo', 1); -$wp_query->lazyload_term_meta('foo', 1); block_core_navigation_submenu_build_css_colors(['foo'], ['bar'], false); wlwmanifest_link(); @@ -23,12 +17,6 @@ $class = new WP_Metadata_Lazyloader; $class->lazyload_meta_callback('foo', 0, '', false, 'comment'); $class->lazyload_meta_callback('foo', 0, '', false, 'term'); -$wp_query = new WP_Query; - -$bar = ['bar']; - -$wp_query->lazyload_comment_meta('foo', 1); -$wp_query->lazyload_term_meta('foo', 1); block_core_navigation_link_build_css_colors(['foo'], ['bar'], false); wp_img_tag_add_loading_optimization_attrs('foo', 'bar');