From e50c65caf4999b11eb396ceaf6649b9818fab47f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 29 Nov 2022 15:49:49 +0000 Subject: [PATCH] Coding Standards: Always use parentheses when instantiating an object. Note: This will be enforced by WPCS 3.0.0. Props jrf. See #56791. git-svn-id: https://develop.svn.wordpress.org/trunk@54891 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/customize.php | 2 +- src/wp-admin/includes/ajax-actions.php | 2 +- src/wp-admin/includes/bookmark.php | 2 +- .../includes/class-language-pack-upgrader.php | 2 +- .../includes/class-wp-automatic-updater.php | 4 ++-- .../class-wp-site-health-auto-updates.php | 4 ++-- src/wp-admin/includes/image-edit.php | 4 ++-- src/wp-admin/includes/nav-menu.php | 8 ++++---- src/wp-admin/includes/post.php | 2 +- src/wp-admin/includes/privacy-tools.php | 2 +- src/wp-admin/includes/schema.php | 2 +- src/wp-admin/includes/template.php | 2 +- src/wp-admin/includes/translation-install.php | 4 ++-- src/wp-admin/includes/update-core.php | 2 +- src/wp-admin/includes/update.php | 4 ++-- src/wp-admin/includes/upgrade.php | 2 +- src/wp-admin/includes/user.php | 2 +- src/wp-admin/user-edit.php | 2 +- src/wp-includes/admin-bar.php | 2 +- src/wp-includes/capabilities.php | 2 +- src/wp-includes/category-template.php | 4 ++-- src/wp-includes/class-wp-admin-bar.php | 2 +- src/wp-includes/class-wp-editor.php | 2 +- src/wp-includes/class-wp-http.php | 2 +- src/wp-includes/class-wp-oembed.php | 4 ++-- .../class-wp-text-diff-renderer-table.php | 2 +- src/wp-includes/class-wp-user.php | 2 +- src/wp-includes/comment-template.php | 2 +- src/wp-includes/comment.php | 6 +++--- src/wp-includes/functions.php | 2 +- src/wp-includes/l10n.php | 2 +- src/wp-includes/ms-load.php | 4 ++-- src/wp-includes/nav-menu-template.php | 2 +- src/wp-includes/nav-menu.php | 2 +- src/wp-includes/pluggable.php | 2 +- src/wp-includes/post-template.php | 4 ++-- src/wp-includes/post.php | 4 ++-- src/wp-includes/rest-api.php | 18 +++++++++--------- .../rest-api/class-wp-rest-response.php | 2 +- .../class-wp-rest-attachments-controller.php | 4 ++-- .../class-wp-rest-comments-controller.php | 4 ++-- .../class-wp-rest-terms-controller.php | 2 +- .../class-wp-rest-users-controller.php | 2 +- .../class-wp-rest-widget-types-controller.php | 2 +- .../class-wp-rest-widgets-controller.php | 2 +- src/wp-includes/theme.php | 2 +- src/wp-includes/update.php | 12 ++++++------ src/wp-includes/user.php | 2 +- src/xmlrpc.php | 2 +- .../includes/testcase-rest-controller.php | 2 +- tests/phpunit/tests/adminbar.php | 4 ++-- tests/phpunit/tests/blocks/editor.php | 2 +- tests/phpunit/tests/cache.php | 4 ++-- tests/phpunit/tests/dependencies.php | 16 ++++++++-------- tests/phpunit/tests/dependencies/jquery.php | 4 ++-- tests/phpunit/tests/dependencies/scripts.php | 4 ++-- .../tests/formatting/sanitizeTextField.php | 2 +- .../tests/formatting/stripslashesDeep.php | 6 +++--- tests/phpunit/tests/formatting/wpSlash.php | 2 +- tests/phpunit/tests/functions.php | 8 ++++---- tests/phpunit/tests/import/parser.php | 12 ++++++------ tests/phpunit/tests/media.php | 2 +- .../tests/menu/wpExpandNavMenuPostData.php | 10 +++++----- tests/phpunit/tests/meta.php | 2 +- tests/phpunit/tests/oembed/controller.php | 2 +- tests/phpunit/tests/pomo/mo.php | 2 +- tests/phpunit/tests/pomo/noopTranslations.php | 2 +- tests/phpunit/tests/pomo/translations.php | 2 +- tests/phpunit/tests/post.php | 4 ++-- tests/phpunit/tests/post/meta.php | 2 +- tests/phpunit/tests/post/types.php | 2 +- tests/phpunit/tests/query.php | 2 +- tests/phpunit/tests/query/generatePostdata.php | 2 +- tests/phpunit/tests/query/setupPostdata.php | 2 +- .../rest-api/rest-block-type-controller.php | 12 ++++++------ .../rest-api/rest-categories-controller.php | 2 +- .../rest-api/rest-comments-controller.php | 4 ++-- .../tests/rest-api/rest-post-meta-fields.php | 4 ++-- .../rest-api/rest-post-statuses-controller.php | 8 ++++---- .../rest-api/rest-post-types-controller.php | 8 ++++---- .../tests/rest-api/rest-schema-setup.php | 2 +- .../tests/rest-api/rest-tags-controller.php | 2 +- .../rest-api/rest-taxonomies-controller.php | 8 ++++---- .../tests/rest-api/rest-term-meta-fields.php | 4 ++-- .../tests/rest-api/rest-users-controller.php | 4 ++-- .../rest-api/rest-widget-types-controller.php | 14 +++++++------- 86 files changed, 166 insertions(+), 166 deletions(-) diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php index 0df5d81ae571a..cd2550c1a85ca 100644 --- a/src/wp-admin/customize.php +++ b/src/wp-admin/customize.php @@ -97,7 +97,7 @@ } $registered = $wp_scripts->registered; -$wp_scripts = new WP_Scripts; +$wp_scripts = new WP_Scripts(); $wp_scripts->registered = $registered; add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 ); diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 6ca6a0217ac1e..995433eaba27a 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1570,7 +1570,7 @@ function wp_ajax_add_menu_item() { 'before' => '', 'link_after' => '', 'link_before' => '', - 'walker' => new $walker_class_name, + 'walker' => new $walker_class_name(), ); echo walk_nav_menu_tree( $menu_items, 0, (object) $args ); diff --git a/src/wp-admin/includes/bookmark.php b/src/wp-admin/includes/bookmark.php index 8d26e27a5eb2b..abb068319c8e3 100644 --- a/src/wp-admin/includes/bookmark.php +++ b/src/wp-admin/includes/bookmark.php @@ -59,7 +59,7 @@ function edit_link( $link_id = 0 ) { * @return stdClass Default link object. */ function get_default_link_to_edit() { - $link = new stdClass; + $link = new stdClass(); if ( isset( $_GET['linkurl'] ) ) { $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) ); } else { diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index c21999956946d..0d6961ab22e9f 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -62,7 +62,7 @@ public static function async_upgrade( $upgrader = false ) { * Avoid messing with VCS installations, at least for now. * Noted: this is not the ideal way to accomplish this. */ - $check_vcs = new WP_Automatic_Updater; + $check_vcs = new WP_Automatic_Updater(); if ( $check_vcs->is_vcs_checkout( WP_CONTENT_DIR ) ) { return; } diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index 2d62527a98bc1..083a6dcc36844 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -139,7 +139,7 @@ public function is_vcs_checkout( $context ) { */ public function should_update( $type, $item, $context ) { // Used to see if WP_Filesystem is set up to allow unattended updates. - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); if ( $this->is_disabled() ) { return false; @@ -305,7 +305,7 @@ protected function send_core_update_notification_email( $item ) { * @return null|WP_Error */ public function update( $type, $item ) { - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); switch ( $type ) { case 'core': diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index e3c02d062071c..541bbd1f23cf5 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -280,7 +280,7 @@ public function test_check_wp_filesystem_method() { require_once ABSPATH . 'wp-admin/includes/file.php'; } - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); $success = $skin->request_filesystem_credentials( false, ABSPATH ); if ( ! $success ) { @@ -313,7 +313,7 @@ public function test_all_files_writable() { require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); $success = $skin->request_filesystem_credentials( false, ABSPATH ); if ( ! $success ) { diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index e814fc47e78e1..746c0bafbd46c 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -739,7 +739,7 @@ function wp_restore_image( $post_id ) { $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); $old_backup_sizes = $backup_sizes; $restored = false; - $msg = new stdClass; + $msg = new stdClass(); if ( ! is_array( $backup_sizes ) ) { $msg->error = __( 'Cannot load image metadata.' ); @@ -827,7 +827,7 @@ function wp_restore_image( $post_id ) { function wp_save_image( $post_id ) { $_wp_additional_image_sizes = wp_get_additional_image_sizes(); - $return = new stdClass; + $return = new stdClass(); $success = false; $delete = false; $scaled = false; diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 0e09d31148ef3..8dd05ba533185 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -32,7 +32,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) { } if ( 'markup' === $response_format ) { - $args['walker'] = new Walker_Nav_Menu_Checklist; + $args['walker'] = new Walker_Nav_Menu_Checklist(); } if ( 'get-post-item' === $type ) { @@ -429,14 +429,14 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) { } // @todo Transient caching of these results with proper invalidation on updating of a post of this type. - $get_posts = new WP_Query; + $get_posts = new WP_Query(); $posts = $get_posts->query( $args ); // Only suppress and insert when more than just suppression pages available. if ( ! $get_posts->post_count ) { if ( ! empty( $suppress_page_ids ) ) { unset( $args['post__not_in'] ); - $get_posts = new WP_Query; + $get_posts = new WP_Query(); $posts = $get_posts->query( $args ); } else { echo '

' . __( 'No items.' ) . '

'; @@ -1059,7 +1059,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) { $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); if ( class_exists( $walker_class_name ) ) { - $walker = new $walker_class_name; + $walker = new $walker_class_name(); } else { return new WP_Error( 'menu_walker_not_exist', diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 65b36c4836878..b72134d421d9d 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -716,7 +716,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); } } else { - $post = new stdClass; + $post = new stdClass(); $post->ID = 0; $post->post_author = ''; $post->post_date = ''; diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index f974ea8a5da64..9682e94fcf2ff 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -535,7 +535,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { wp_delete_file( $archive_pathname ); } - $zip = new ZipArchive; + $zip = new ZipArchive(); if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) { if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) { $error = __( 'Unable to archive the personal data export file (JSON format).' ); diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 57ffe69054e01..79fb80c205e79 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -1050,7 +1050,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam * created. */ if ( ! is_multisite() ) { - $current_site = new stdClass; + $current_site = new stdClass(); $current_site->domain = $domain; $current_site->path = $path; $current_site->site_name = ucfirst( $domain ); diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index deecc92c507f3..7de1a07431213 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -104,7 +104,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) { $parsed_args = wp_parse_args( $params, $defaults ); if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) { - $walker = new Walker_Category_Checklist; + $walker = new Walker_Category_Checklist(); } else { $walker = $parsed_args['walker']; } diff --git a/src/wp-admin/includes/translation-install.php b/src/wp-admin/includes/translation-install.php index dc7cb89a05682..01c61bbb7b820 100644 --- a/src/wp-admin/includes/translation-install.php +++ b/src/wp-admin/includes/translation-install.php @@ -237,7 +237,7 @@ function wp_download_language_pack( $download ) { $translation = (object) $translation; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); $upgrader = new Language_Pack_Upgrader( $skin ); $translation->type = 'core'; $result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) ); @@ -263,7 +263,7 @@ function wp_can_install_language_pack() { } require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $skin = new Automatic_Upgrader_Skin; + $skin = new Automatic_Upgrader_Skin(); $upgrader = new Language_Pack_Upgrader( $skin ); $upgrader->init(); diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 20a73901496da..c240fb0ee613a 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1395,7 +1395,7 @@ function update_core( $from, $to ) { // If a error occurs partway through this final step, keep the error flowing through, but keep process going. if ( is_wp_error( $_result ) ) { if ( ! is_wp_error( $result ) ) { - $result = new WP_Error; + $result = new WP_Error(); } $result->add( diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index 8661af75b59ea..530406bc28176 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -93,7 +93,7 @@ function find_core_auto_update() { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $auto_update = false; - $upgrader = new WP_Automatic_Updater; + $upgrader = new WP_Automatic_Updater(); foreach ( $updates->updates as $update ) { if ( 'autoupdate' !== $update->response ) { continue; @@ -235,7 +235,7 @@ function core_update_footer( $msg = '' ) { $cur = get_preferred_from_update_core(); if ( ! is_object( $cur ) ) { - $cur = new stdClass; + $cur = new stdClass(); } if ( ! isset( $cur->current ) ) { diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 94d9d335f3028..63580cceb044d 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -2617,7 +2617,7 @@ function maybe_convert_table_to_utf8mb4( $table ) { */ function get_alloptions_110() { global $wpdb; - $all_options = new stdClass; + $all_options = new stdClass(); $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); if ( $options ) { foreach ( $options as $option ) { diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index 134da30514716..1df2739d48a3a 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -29,7 +29,7 @@ function add_user() { */ function edit_user( $user_id = 0 ) { $wp_roles = wp_roles(); - $user = new stdClass; + $user = new stdClass(); $user_id = (int) $user_id; if ( $user_id ) { $update = true; diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 681c7354f8c51..edcdfb1ac59e3 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -104,7 +104,7 @@ if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) { $new_email = get_user_meta( $current_user->ID, '_new_email', true ); if ( $new_email && hash_equals( $new_email['hash'], $_GET['newuseremail'] ) ) { - $user = new stdClass; + $user = new stdClass(); $user->ID = $current_user->ID; $user->user_email = esc_html( trim( $new_email['newemail'] ) ); if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 19322a3451f11..784153ebf0ec6 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -41,7 +41,7 @@ function _wp_admin_bar_init() { */ $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); if ( class_exists( $admin_bar_class ) ) { - $wp_admin_bar = new $admin_bar_class; + $wp_admin_bar = new $admin_bar_class(); } else { return false; } diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index d06887a2bb621..2b16174666f44 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -975,7 +975,7 @@ function user_can( $user, $capability, ...$args ) { if ( empty( $user ) ) { // User is logged out, create anonymous user object. $user = new WP_User( 0 ); - $user->init( new stdClass ); + $user->init( new stdClass() ); } return $user->has_cap( $capability, ...$args ); diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index dc0dfe7ef0d20..b35c17170d129 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -1110,7 +1110,7 @@ function _wp_object_count_sort_cb( $a, $b ) { function walk_category_tree( ...$args ) { // The user's options are the third parameter. if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { - $walker = new Walker_Category; + $walker = new Walker_Category(); } else { /** * @var Walker $walker @@ -1136,7 +1136,7 @@ function walk_category_tree( ...$args ) { function walk_category_dropdown_tree( ...$args ) { // The user's options are the third parameter. if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { - $walker = new Walker_CategoryDropdown; + $walker = new Walker_CategoryDropdown(); } else { /** * @var Walker $walker diff --git a/src/wp-includes/class-wp-admin-bar.php b/src/wp-includes/class-wp-admin-bar.php index 406d76459be01..dc6ea0993c555 100644 --- a/src/wp-includes/class-wp-admin-bar.php +++ b/src/wp-includes/class-wp-admin-bar.php @@ -41,7 +41,7 @@ public function __get( $name ) { * @since 3.1.0 */ public function initialize() { - $this->user = new stdClass; + $this->user = new stdClass(); if ( is_user_logged_in() ) { /* Populate settings we need for the menu based on the current user. */ diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 41f379a8384b1..16805f7a167c4 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -1799,7 +1799,7 @@ public static function wp_link_query( $args = array() ) { $query = apply_filters( 'wp_link_query_args', $query ); // Do main query. - $get_posts = new WP_Query; + $get_posts = new WP_Query(); $posts = $get_posts->query( $query ); // Build results. diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php index 3d4e8798aa73e..3d90085e4943f 100644 --- a/src/wp-includes/class-wp-http.php +++ b/src/wp-includes/class-wp-http.php @@ -581,7 +581,7 @@ private function _dispatch_request( $url, $args ) { // Transport claims to support request, instantiate it and give it a whirl. if ( empty( $transports[ $class ] ) ) { - $transports[ $class ] = new $class; + $transports[ $class ] = new $class(); } $response = $transports[ $class ]->request( $url, $args ); diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php index 8b24cf752b207..e177223435969 100644 --- a/src/wp-includes/class-wp-oembed.php +++ b/src/wp-includes/class-wp-oembed.php @@ -639,7 +639,7 @@ private function _parse_xml_body( $response_body ) { return false; } - $dom = new DOMDocument; + $dom = new DOMDocument(); $success = $dom->loadXML( $response_body ); if ( ! $success ) { return false; @@ -660,7 +660,7 @@ private function _parse_xml_body( $response_body ) { return false; } - $return = new stdClass; + $return = new stdClass(); foreach ( $xml as $key => $value ) { $return->$key = (string) $value; } diff --git a/src/wp-includes/class-wp-text-diff-renderer-table.php b/src/wp-includes/class-wp-text-diff-renderer-table.php index a74b8019f4eb8..dbbf867c74587 100644 --- a/src/wp-includes/class-wp-text-diff-renderer-table.php +++ b/src/wp-includes/class-wp-text-diff-renderer-table.php @@ -269,7 +269,7 @@ public function _changed( $orig, $final ) { foreach ( $orig_matches as $o => $f ) { if ( is_numeric( $o ) && is_numeric( $f ) ) { $text_diff = new Text_Diff( 'auto', array( array( $orig[ $o ] ), array( $final[ $f ] ) ) ); - $renderer = new $this->inline_diff_renderer; + $renderer = new $this->inline_diff_renderer(); $diff = $renderer->render( $text_diff ); // If they're too different, don't include any or 's. diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index b190960009575..ecfa1a5920479 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -156,7 +156,7 @@ public function __construct( $id = 0, $name = '', $site_id = '' ) { if ( $data ) { $this->init( $data, $site_id ); } else { - $this->data = new stdClass; + $this->data = new stdClass(); } } diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 63614663de818..44eddaec86270 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -2238,7 +2238,7 @@ function wp_list_comments( $args = array(), $comments = null ) { wp_queue_comments_for_comment_meta_lazyload( $_comments ); if ( empty( $parsed_args['walker'] ) ) { - $walker = new Walker_Comment; + $walker = new Walker_Comment(); } else { $walker = $parsed_args['walker']; } diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index bf646a2a27f36..a52edf84f4df6 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -171,7 +171,7 @@ function get_approved_comments( $post_id, $args = array() ) { ); $parsed_args = wp_parse_args( $args, $defaults ); - $query = new WP_Comment_Query; + $query = new WP_Comment_Query(); return $query->query( $parsed_args ); } @@ -240,7 +240,7 @@ function get_comment( $comment = null, $output = OBJECT ) { * @return WP_Comment[]|int[]|int List of comments or number of found comments if `$count` argument is true. */ function get_comments( $args = '' ) { - $query = new WP_Comment_Query; + $query = new WP_Comment_Query(); return $query->query( $args ); } @@ -1023,7 +1023,7 @@ function get_comment_pages_count( $comments = null, $per_page = null, $threaded } if ( $threaded ) { - $walker = new Walker_Comment; + $walker = new Walker_Comment(); $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page ); } else { $count = ceil( count( $comments ) / $per_page ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 8cb36f5e39f68..b2baae9a5195a 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -4302,7 +4302,7 @@ function _wp_json_sanity_check( $data, $depth ) { } } } elseif ( is_object( $data ) ) { - $output = new stdClass; + $output = new stdClass(); foreach ( $data as $id => $el ) { if ( is_string( $id ) ) { $clean_id = _wp_json_convert_string( $id ); diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index 40c653fdbe5ca..d7642c7038052 100644 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -1306,7 +1306,7 @@ function get_translations_for_domain( $domain ) { static $noop_translations = null; if ( null === $noop_translations ) { - $noop_translations = new NOOP_Translations; + $noop_translations = new NOOP_Translations(); } return $noop_translations; diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php index 35942df0f861e..c7f74167f43dd 100644 --- a/src/wp-includes/ms-load.php +++ b/src/wp-includes/ms-load.php @@ -297,7 +297,7 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) // If the network is defined in wp-config.php, we can simply use that. if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) { - $current_site = new stdClass; + $current_site = new stdClass(); $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1; $current_site->domain = DOMAIN_CURRENT_SITE; $current_site->path = PATH_CURRENT_SITE; @@ -387,7 +387,7 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) // During activation of a new subdomain, the requested site does not yet exist. if ( empty( $current_blog ) && wp_installing() ) { - $current_blog = new stdClass; + $current_blog = new stdClass(); $current_blog->blog_id = 1; $blog_id = 1; $current_blog->public = 1; diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index 0673bf36ed44f..893727c44c24a 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -617,7 +617,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { * @return string The HTML list content for the menu items. */ function walk_nav_menu_tree( $items, $depth, $args ) { - $walker = ( empty( $args->walker ) ) ? new Walker_Nav_Menu : $args->walker; + $walker = ( empty( $args->walker ) ) ? new Walker_Nav_Menu() : $args->walker; return $walker->walk( $items, $depth, $args ); } diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 3ef281f643dd0..87b51182e328b 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -1010,7 +1010,7 @@ function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_ $object_id = (int) $object_id; $menu_item_ids = array(); - $query = new WP_Query; + $query = new WP_Query(); $menu_items = $query->query( array( 'meta_key' => '_menu_item_object_id', diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 2852e23a9310c..27e5d91b20233 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -105,7 +105,7 @@ function get_user_by( $field, $value ) { return false; } - $user = new WP_User; + $user = new WP_User(); $user->init( $userdata ); return $user; diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index 03178a3dd5d8a..3ce819c2b0de5 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -1546,7 +1546,7 @@ function wp_page_menu( $args = array() ) { */ function walk_page_tree( $pages, $depth, $current_page, $args ) { if ( empty( $args['walker'] ) ) { - $walker = new Walker_Page; + $walker = new Walker_Page(); } else { /** * @var Walker $walker @@ -1578,7 +1578,7 @@ function walk_page_tree( $pages, $depth, $current_page, $args ) { */ function walk_page_dropdown_tree( ...$args ) { if ( empty( $args[2]['walker'] ) ) { // The user's options are the third parameter. - $walker = new Walker_PageDropdown; + $walker = new Walker_PageDropdown(); } else { /** * @var Walker $walker diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 185d2d5a08c55..1163d023cdea8 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -2410,7 +2410,7 @@ function get_posts( $args = null ) { $parsed_args['ignore_sticky_posts'] = true; $parsed_args['no_found_rows'] = true; - $get_posts = new WP_Query; + $get_posts = new WP_Query(); return $get_posts->query( $parsed_args ); } @@ -3013,7 +3013,7 @@ function wp_count_posts( $type = 'post', $perm = '' ) { global $wpdb; if ( ! post_type_exists( $type ) ) { - return new stdClass; + return new stdClass(); } $cache_key = _count_posts_cache_key( $type, $perm ); diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index b611745ebd661..3953b74392e29 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -255,15 +255,15 @@ function create_initial_rest_routes() { } // Post types. - $controller = new WP_REST_Post_Types_Controller; + $controller = new WP_REST_Post_Types_Controller(); $controller->register_routes(); // Post statuses. - $controller = new WP_REST_Post_Statuses_Controller; + $controller = new WP_REST_Post_Statuses_Controller(); $controller->register_routes(); // Taxonomies. - $controller = new WP_REST_Taxonomies_Controller; + $controller = new WP_REST_Taxonomies_Controller(); $controller->register_routes(); // Terms. @@ -278,7 +278,7 @@ function create_initial_rest_routes() { } // Users. - $controller = new WP_REST_Users_Controller; + $controller = new WP_REST_Users_Controller(); $controller->register_routes(); // Application Passwords @@ -286,7 +286,7 @@ function create_initial_rest_routes() { $controller->register_routes(); // Comments. - $controller = new WP_REST_Comments_Controller; + $controller = new WP_REST_Comments_Controller(); $controller->register_routes(); $search_handlers = array( @@ -318,15 +318,15 @@ function create_initial_rest_routes() { $controller->register_routes(); // Global Styles. - $controller = new WP_REST_Global_Styles_Controller; + $controller = new WP_REST_Global_Styles_Controller(); $controller->register_routes(); // Settings. - $controller = new WP_REST_Settings_Controller; + $controller = new WP_REST_Settings_Controller(); $controller->register_routes(); // Themes. - $controller = new WP_REST_Themes_Controller; + $controller = new WP_REST_Themes_Controller(); $controller->register_routes(); // Plugins. @@ -562,7 +562,7 @@ function rest_get_server() { * @param string $class_name The name of the server class. Default 'WP_REST_Server'. */ $wp_rest_server_class = apply_filters( 'wp_rest_server_class', 'WP_REST_Server' ); - $wp_rest_server = new $wp_rest_server_class; + $wp_rest_server = new $wp_rest_server_class(); /** * Fires when preparing to serve a REST API request. diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php index cb890f5b0bae1..c6ea11be83ee3 100644 --- a/src/wp-includes/rest-api/class-wp-rest-response.php +++ b/src/wp-includes/rest-api/class-wp-rest-response.php @@ -227,7 +227,7 @@ public function as_error() { return null; } - $error = new WP_Error; + $error = new WP_Error(); if ( is_array( $this->get_data() ) ) { $data = $this->get_data(); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index ff3c1dc42ffa5..98c0a1bb642bd 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -766,7 +766,7 @@ public function prepare_item_for_response( $item, $request ) { // Ensure empty details is an empty object. if ( empty( $data['media_details'] ) ) { - $data['media_details'] = new stdClass; + $data['media_details'] = new stdClass(); } elseif ( ! empty( $data['media_details']['sizes'] ) ) { foreach ( $data['media_details']['sizes'] as $size => &$size_data ) { @@ -797,7 +797,7 @@ public function prepare_item_for_response( $item, $request ) { ); } } else { - $data['media_details']['sizes'] = new stdClass; + $data['media_details']['sizes'] = new stdClass(); } } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 42919b7dc247f..6fecfd3961fe0 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -274,7 +274,7 @@ public function get_items( $request ) { */ $prepared_args = apply_filters( 'rest_comment_query', $prepared_args, $request ); - $query = new WP_Comment_Query; + $query = new WP_Comment_Query(); $query_result = $query->query( $prepared_args ); $comments = array(); @@ -295,7 +295,7 @@ public function get_items( $request ) { // Out-of-bounds, run the query again without LIMIT for total count. unset( $prepared_args['number'], $prepared_args['offset'] ); - $query = new WP_Comment_Query; + $query = new WP_Comment_Query(); $prepared_args['count'] = true; $total_comments = $query->query( $prepared_args ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 4ef48fa366331..4fda654746181 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php @@ -807,7 +807,7 @@ public function delete_item( $request ) { * @return object Term object. */ public function prepare_item_for_database( $request ) { - $prepared_term = new stdClass; + $prepared_term = new stdClass(); $schema = $this->get_item_schema(); if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 52e8fcf0cdb08..62b9bc7e5d14e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -1121,7 +1121,7 @@ protected function prepare_links( $user ) { * @return object User object. */ protected function prepare_item_for_database( $request ) { - $prepared_user = new stdClass; + $prepared_user = new stdClass(); $schema = $this->get_item_schema(); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php index d721c32d64c4d..1868050573349 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php @@ -529,7 +529,7 @@ public function encode_form_data( $request ) { if ( ! empty( $widget_object->widget_options['show_instance_in_rest'] ) ) { // Use new stdClass so that JSON result is {} and not []. - $response['instance']['raw'] = empty( $instance ) ? new stdClass : $instance; + $response['instance']['raw'] = empty( $instance ) ? new stdClass() : $instance; } return rest_ensure_response( $response ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index e6ac11cf88afc..596e78aecfa85 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -715,7 +715,7 @@ public function prepare_item_for_response( $item, $request ) { if ( ! empty( $widget_object->widget_options['show_instance_in_rest'] ) ) { // Use new stdClass so that JSON result is {} and not []. - $prepared['instance']['raw'] = empty( $instance ) ? new stdClass : $instance; + $prepared['instance']['raw'] = empty( $instance ) ? new stdClass() : $instance; } } } diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 61d5c13284a10..47fe9cb1628ab 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -1331,7 +1331,7 @@ function _get_random_header_data() { } if ( empty( $headers ) ) { - return new stdClass; + return new stdClass(); } $_wp_random_header = (object) $headers[ array_rand( $headers ) ]; diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index f352cab7c25e9..5136912037e7a 100644 --- a/src/wp-includes/update.php +++ b/src/wp-includes/update.php @@ -44,7 +44,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { } if ( ! is_object( $current ) ) { - $current = new stdClass; + $current = new stdClass(); $current->updates = array(); $current->version_checked = $wp_version; } @@ -327,10 +327,10 @@ function wp_update_plugins( $extra_stats = array() ) { $current = get_site_transient( 'update_plugins' ); if ( ! is_object( $current ) ) { - $current = new stdClass; + $current = new stdClass(); } - $updates = new stdClass; + $updates = new stdClass(); $updates->last_checked = time(); $updates->response = array(); $updates->translations = array(); @@ -595,7 +595,7 @@ function wp_update_themes( $extra_stats = array() ) { $last_update = get_site_transient( 'update_themes' ); if ( ! is_object( $last_update ) ) { - $last_update = new stdClass; + $last_update = new stdClass(); } $themes = array(); @@ -734,7 +734,7 @@ function wp_update_themes( $extra_stats = array() ) { return; } - $new_update = new stdClass; + $new_update = new stdClass(); $new_update->last_checked = time(); $new_update->checked = $checked; @@ -846,7 +846,7 @@ function wp_maybe_auto_update() { include_once ABSPATH . 'wp-admin/includes/admin.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $upgrader = new WP_Automatic_Updater; + $upgrader = new WP_Automatic_Updater(); $upgrader->run(); } diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 9c17d1583e7c2..cc128c26e4ab6 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -951,7 +951,7 @@ function get_blogs_of_user( $user_id, $all = false ) { if ( ! is_multisite() ) { $site_id = get_current_blog_id(); - $sites = array( $site_id => new stdClass ); + $sites = array( $site_id => new stdClass() ); $sites[ $site_id ]->userblog_id = $site_id; $sites[ $site_id ]->blogname = get_option( 'blogname' ); $sites[ $site_id ]->domain = ''; diff --git a/src/xmlrpc.php b/src/xmlrpc.php index ecac4c7c7a1bd..3f358155253c6 100644 --- a/src/xmlrpc.php +++ b/src/xmlrpc.php @@ -81,7 +81,7 @@ * @param string $class The name of the XML-RPC server class. */ $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' ); -$wp_xmlrpc_server = new $wp_xmlrpc_server_class; +$wp_xmlrpc_server = new $wp_xmlrpc_server_class(); // Fire off the request. $wp_xmlrpc_server->serve_request(); diff --git a/tests/phpunit/includes/testcase-rest-controller.php b/tests/phpunit/includes/testcase-rest-controller.php index 67a7970b66943..9a4c2a0b61b2c 100644 --- a/tests/phpunit/includes/testcase-rest-controller.php +++ b/tests/phpunit/includes/testcase-rest-controller.php @@ -9,7 +9,7 @@ public function set_up() { add_filter( 'rest_url', array( $this, 'filter_rest_url_for_leading_slash' ), 10, 2 ); /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); } diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 228063e911b5c..cec80d0cae027 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -37,7 +37,7 @@ public function test_content_post_type() { register_post_type( 'content', array( 'show_in_admin_bar' => true ) ); - $admin_bar = new WP_Admin_Bar; + $admin_bar = new WP_Admin_Bar(); wp_admin_bar_new_content_menu( $admin_bar ); @@ -54,7 +54,7 @@ public function test_content_post_type() { public function test_merging_existing_meta_values() { wp_set_current_user( self::$editor_id ); - $admin_bar = new WP_Admin_Bar; + $admin_bar = new WP_Admin_Bar(); $admin_bar->add_node( array( diff --git a/tests/phpunit/tests/blocks/editor.php b/tests/phpunit/tests/blocks/editor.php index 076b3026fa0ea..e3a4fdccfc051 100644 --- a/tests/phpunit/tests/blocks/editor.php +++ b/tests/phpunit/tests/blocks/editor.php @@ -31,7 +31,7 @@ public function set_up() { $post = self::factory()->post->create_and_get( $args ); global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); } diff --git a/tests/phpunit/tests/cache.php b/tests/phpunit/tests/cache.php index f65096c5976d0..faf64de5a0be8 100644 --- a/tests/phpunit/tests/cache.php +++ b/tests/phpunit/tests/cache.php @@ -230,7 +230,7 @@ public function test_wp_cache_flush_group() { // Make sure objects are cloned going to and from the cache. public function test_object_refs() { $key = __FUNCTION__ . '_1'; - $object_a = new stdClass; + $object_a = new stdClass(); $object_a->foo = 'alpha'; $this->cache->set( $key, $object_a ); $object_a->foo = 'bravo'; @@ -240,7 +240,7 @@ public function test_object_refs() { $this->assertSame( 'bravo', $object_a->foo ); $key = __FUNCTION__ . '_2'; - $object_a = new stdClass; + $object_a = new stdClass(); $object_a->foo = 'alpha'; $this->cache->add( $key, $object_a ); $object_a->foo = 'bravo'; diff --git a/tests/phpunit/tests/dependencies.php b/tests/phpunit/tests/dependencies.php index 0087a0c143d63..cdd8e8b529143 100644 --- a/tests/phpunit/tests/dependencies.php +++ b/tests/phpunit/tests/dependencies.php @@ -5,7 +5,7 @@ */ class Tests_Dependencies extends WP_UnitTestCase { public function test_add() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -18,7 +18,7 @@ public function test_add() { } public function test_remove() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -31,7 +31,7 @@ public function test_remove() { } public function test_enqueue() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -47,7 +47,7 @@ public function test_enqueue() { } public function test_dequeue() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -67,7 +67,7 @@ public function test_dequeue() { } public function test_enqueue_args() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -85,7 +85,7 @@ public function test_enqueue_args() { } public function test_dequeue_args() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertTrue( $dep->add( 'two', '' ) ); @@ -112,7 +112,7 @@ public function test_dequeue_args() { * @ticket 21741 */ public function test_query_and_registered_enqueued() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertTrue( $dep->add( 'one', '' ) ); $this->assertInstanceOf( '_WP_Dependency', $dep->query( 'one' ) ); @@ -138,7 +138,7 @@ public function test_query_and_registered_enqueued() { } function test_enqueue_before_register() { - $dep = new WP_Dependencies; + $dep = new WP_Dependencies(); $this->assertArrayNotHasKey( 'one', $dep->registered ); diff --git a/tests/phpunit/tests/dependencies/jquery.php b/tests/phpunit/tests/dependencies/jquery.php index 62243fe58149e..aa44b0047a638 100644 --- a/tests/phpunit/tests/dependencies/jquery.php +++ b/tests/phpunit/tests/dependencies/jquery.php @@ -10,7 +10,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { * @covers WP_Scripts::query */ public function test_location_of_jquery() { - $scripts = new WP_Scripts; + $scripts = new WP_Scripts(); wp_default_scripts( $scripts ); if ( SCRIPT_DEBUG ) { @@ -106,7 +106,7 @@ public function test_wp_script_is_dep_enqueued() { * @covers WP_Scripts::do_items */ public function test_jquery_in_footer() { - $scripts = new WP_Scripts; + $scripts = new WP_Scripts(); $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) ); $scripts->add( 'jquery-core', '/jquery.js', array() ); $scripts->add( 'jquery-migrate', '/jquery-migrate.js', array() ); diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index b64edfeff9e2d..3897c6aa25f94 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -276,7 +276,7 @@ public function test_wp_enqueue_script_footer_alias() { * @covers WP_Dependencies::do_items */ public function test_group_mismatch_in_deps() { - $scripts = new WP_Scripts; + $scripts = new WP_Scripts(); $scripts->add( 'one', 'one', array(), 'v1', 1 ); $scripts->add( 'two', 'two', array( 'one' ) ); $scripts->add( 'three', 'three', array( 'two' ), 'v1', 1 ); @@ -295,7 +295,7 @@ public function test_group_mismatch_in_deps() { $this->assertContains( 'two', $scripts->done ); $this->assertContains( 'three', $scripts->done ); - $scripts = new WP_Scripts; + $scripts = new WP_Scripts(); $scripts->add( 'one', 'one', array(), 'v1', 1 ); $scripts->add( 'two', 'two', array( 'one' ), 'v1', 1 ); $scripts->add( 'three', 'three', array( 'one' ) ); diff --git a/tests/phpunit/tests/formatting/sanitizeTextField.php b/tests/phpunit/tests/formatting/sanitizeTextField.php index 15e903ac95cf8..240f38850b98d 100644 --- a/tests/phpunit/tests/formatting/sanitizeTextField.php +++ b/tests/phpunit/tests/formatting/sanitizeTextField.php @@ -105,7 +105,7 @@ public function data_sanitize_text_field() { '', ), array( - new WP_Query, + new WP_Query(), '', ), array( diff --git a/tests/phpunit/tests/formatting/stripslashesDeep.php b/tests/phpunit/tests/formatting/stripslashesDeep.php index 76f9e8b019f67..ea2c9139545be 100644 --- a/tests/phpunit/tests/formatting/stripslashesDeep.php +++ b/tests/phpunit/tests/formatting/stripslashesDeep.php @@ -26,7 +26,7 @@ public function test_preserves_original_datatype() { $this->assertSame( $arr, stripslashes_deep( $arr ) ); // Keyed array. $this->assertSame( array_values( $arr ), stripslashes_deep( array_values( $arr ) ) ); // Non-keyed. - $obj = new stdClass; + $obj = new stdClass(); foreach ( $arr as $k => $v ) { $obj->$k = $v; } @@ -41,9 +41,9 @@ public function test_strips_slashes() { $this->assertSame( array( 'a' => $new ), stripslashes_deep( array( 'a' => $old ) ) ); // Keyed array. $this->assertSame( array( $new ), stripslashes_deep( array( $old ) ) ); // Non-keyed. - $obj_old = new stdClass; + $obj_old = new stdClass(); $obj_old->a = $old; - $obj_new = new stdClass; + $obj_new = new stdClass(); $obj_new->a = $new; $this->assertEquals( $obj_new, stripslashes_deep( $obj_old ) ); } diff --git a/tests/phpunit/tests/formatting/wpSlash.php b/tests/phpunit/tests/formatting/wpSlash.php index 39a7c32a010e2..a1ac591c7ae02 100644 --- a/tests/phpunit/tests/formatting/wpSlash.php +++ b/tests/phpunit/tests/formatting/wpSlash.php @@ -84,7 +84,7 @@ public function test_preserves_original_datatype() { $this->assertSame( $arr, wp_slash( $arr ) ); // Keyed array. $this->assertSame( array_values( $arr ), wp_slash( array_values( $arr ) ) ); // Non-keyed. - $obj = new stdClass; + $obj = new stdClass(); foreach ( $arr as $k => $v ) { $obj->$k = $v; } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 1fdba6ca847ab..71cd6b67d1042 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -5,7 +5,7 @@ */ class Tests_Functions extends WP_UnitTestCase { public function test_wp_parse_args_object() { - $x = new MockClass; + $x = new MockClass(); $x->_baba = 5; $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase $x->a = array( 5, 111, 'x' ); @@ -17,7 +17,7 @@ public function test_wp_parse_args_object() { ), wp_parse_args( $x ) ); - $y = new MockClass; + $y = new MockClass(); $this->assertSame( array(), wp_parse_args( $y ) ); } @@ -41,7 +41,7 @@ public function test_wp_parse_args_array() { } public function test_wp_parse_args_defaults() { - $x = new MockClass; + $x = new MockClass(); $x->_baba = 5; $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase $x->a = array( 5, 111, 'x' ); @@ -1113,7 +1113,7 @@ public function test_wp_json_encode_array() { * @ticket 28786 */ public function test_wp_json_encode_object() { - $object = new stdClass; + $object = new stdClass(); $object->a = 'b'; $this->assertSame( wp_json_encode( $object ), '{"a":"b"}' ); } diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php index 2c05bb8f354c8..f302cefa29441 100644 --- a/tests/phpunit/tests/import/parser.php +++ b/tests/phpunit/tests/import/parser.php @@ -33,7 +33,7 @@ public function test_malformed_wxr() { // Regex based parser cannot detect malformed XML. foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML' ) as $p ) { - $parser = new $p; + $parser = new $p(); $result = $parser->parse( $file ); $this->assertWPError( $result ); $this->assertSame( 'There was an error when reading this WXR file', $result->get_error_message() ); @@ -51,7 +51,7 @@ public function test_invalid_wxr() { foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { foreach ( array( $f1, $f2 ) as $file ) { - $parser = new $p; + $parser = new $p(); $result = $parser->parse( $file ); $this->assertWPError( $result ); $this->assertSame( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() ); @@ -69,7 +69,7 @@ public function test_wxr_version_1_1() { foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { $message = $p . ' failed'; - $parser = new $p; + $parser = new $p(); $result = $parser->parse( $file ); $this->assertIsArray( $result, $message ); @@ -167,7 +167,7 @@ public function test_wxr_version_1_0() { foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { $message = $p . ' failed'; - $parser = new $p; + $parser = new $p(); $result = $parser->parse( $file ); $this->assertIsArray( $result, $message ); @@ -265,7 +265,7 @@ public function test_escaped_cdata_closing_sequence() { foreach ( array( 'WXR_Parser_SimpleXML', 'WXR_Parser_XML', 'WXR_Parser_Regex' ) as $p ) { $message = 'Parser ' . $p; - $parser = new $p; + $parser = new $p(); $result = $parser->parse( $file ); $post = $result['posts'][0]; @@ -298,7 +298,7 @@ public function test_escaped_cdata_closing_sequence() { public function test_unescaped_cdata_closing_sequence() { $file = DIR_TESTDATA . '/export/crazy-cdata.xml'; - $parser = new WXR_Parser_Regex; + $parser = new WXR_Parser_Regex(); $result = $parser->parse( $file ); $post = $result['posts'][0]; diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index a2459a8db6f06..5165e32b85057 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -361,7 +361,7 @@ public function data_autoembed() { * @dataProvider data_autoembed */ public function test_autoembed( $content, $result = null ) { - $wp_embed = new Test_Autoembed; + $wp_embed = new Test_Autoembed(); $this->assertSame( $wp_embed->autoembed( $content ), $result ? $result : $content ); } diff --git a/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php b/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php index 7d5c21fde83fe..b7e6b17c23950 100644 --- a/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php +++ b/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php @@ -13,7 +13,7 @@ public function test_unnested_data_should_expand() { } $data = array(); - $data[0] = new StdClass; + $data[0] = new StdClass(); $data[0]->name = 'yesorno'; $data[0]->value = 'yes'; $_POST['nav-menu-data'] = addslashes( json_encode( $data ) ); @@ -36,7 +36,7 @@ public function test_multidimensional_nested_array_should_expand() { } $data = array(); - $data[0] = new StdClass; + $data[0] = new StdClass(); $data[0]->name = 'would[1][do][the][trick]'; $data[0]->value = 'yes'; $_POST['nav-menu-data'] = addslashes( json_encode( $data ) ); @@ -66,13 +66,13 @@ public function test_multidimensional_nested_array_should_expand_and_merge() { } $data = array(); - $data[0] = new StdClass; + $data[0] = new StdClass(); $data[0]->name = 'would[1][do][the][trick]'; $data[0]->value = 'yes'; - $data[1] = new StdClass; + $data[1] = new StdClass(); $data[1]->name = 'would[2][do][the][trick]'; $data[1]->value = 'yes'; - $data[2] = new StdClass; + $data[2] = new StdClass(); $data[2]->name = 'would[2][do][the][job]'; $data[2]->value = 'yes'; $_POST['nav-menu-data'] = addslashes( json_encode( $data ) ); diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index d49f10682184a..83dcefd1ba4c9 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -401,7 +401,7 @@ public function test_get_metadata_with_empty_key_array_value() { * @ticket 15030 */ public function test_get_metadata_with_empty_key_object_value() { - $data = new stdClass; + $data = new stdClass(); $data->foo = 'bar'; $value = serialize( $data ); add_metadata( 'user', $this->author->ID, 'foo', $data ); diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index a5b8d6a483f82..25d95e7a8cf0d 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -49,7 +49,7 @@ public function set_up() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 ); diff --git a/tests/phpunit/tests/pomo/mo.php b/tests/phpunit/tests/pomo/mo.php index 2269e3d8261b2..e4ce6c4b16d29 100644 --- a/tests/phpunit/tests/pomo/mo.php +++ b/tests/phpunit/tests/pomo/mo.php @@ -145,7 +145,7 @@ public function test_export_mo_file() { public function test_export_should_not_include_empty_translations() { $entries = array(); - $mo = new MO; + $mo = new MO(); $mo->add_entry( array( 'singular' => 'baba', diff --git a/tests/phpunit/tests/pomo/noopTranslations.php b/tests/phpunit/tests/pomo/noopTranslations.php index 3fcfed6b571e1..44f46c1880f43 100644 --- a/tests/phpunit/tests/pomo/noopTranslations.php +++ b/tests/phpunit/tests/pomo/noopTranslations.php @@ -28,7 +28,7 @@ class Tests_POMO_NOOPTranslations extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->noop = new NOOP_Translations; + $this->noop = new NOOP_Translations(); $this->entry = new Translation_Entry( array( 'singular' => 'baba' ) ); $this->plural_entry = new Translation_Entry( array( diff --git a/tests/phpunit/tests/pomo/translations.php b/tests/phpunit/tests/pomo/translations.php index 1e5cc2d03746c..0d2a3383b0f77 100644 --- a/tests/phpunit/tests/pomo/translations.php +++ b/tests/phpunit/tests/pomo/translations.php @@ -121,7 +121,7 @@ public function test_digit_and_merge() { $domain = new Translations(); $domain->add_entry( $entry_digit_1 ); $domain->add_entry( $entry_digit_2 ); - $dummy_translation = new Translations; + $dummy_translation = new Translations(); $this->assertSame( '1', $domain->translate( '1' ) ); $domain->merge_with( $dummy_translation ); $this->assertSame( '1', $domain->translate( '1' ) ); diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 551cbd8c56e8f..484b890af4f31 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -158,7 +158,7 @@ public function test_wp_count_posts() { _unregister_post_type( $post_type ); $count = wp_count_posts( $post_type, 'readable' ); - $this->assertEquals( new stdClass, $count ); + $this->assertEquals( new stdClass(), $count ); } public function test_wp_count_posts_filtered() { @@ -601,7 +601,7 @@ public function data_stick_post_with_unexpected_sticky_posts_option() { '1 int' => array( 1 ), 'null' => array( null ), 'true' => array( true ), - 'an object' => array( new stdClass ), + 'an object' => array( new stdClass() ), ); } diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 456eda0ba1731..0efca37f6bb93 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -169,7 +169,7 @@ public function test_get_post_meta_by_id() { $mid = add_post_meta( self::$post_id, 'get_post_meta_by_key', 'get_post_meta_by_key_value', true ); $this->assertIsInt( $mid ); - $mobj = new stdClass; + $mobj = new stdClass(); $mobj->meta_id = $mid; $mobj->post_id = self::$post_id; $mobj->meta_key = 'get_post_meta_by_key'; diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 5ea10cbb2c6cf..df1543fa0c9ca 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -256,7 +256,7 @@ public function test_get_post_type_object_with_non_scalar_values() { $this->assertNotNull( get_post_type_object( 'foo' ) ); $this->assertNull( get_post_type_object( array() ) ); $this->assertNull( get_post_type_object( array( 'foo' ) ) ); - $this->assertNull( get_post_type_object( new stdClass ) ); + $this->assertNull( get_post_type_object( new stdClass() ) ); _unregister_post_type( 'foo' ); diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index 5ef98e1f726ba..9c4ca439a51e2 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -33,7 +33,7 @@ public function test_nested_loop_reset_postdata() { * @ticket 16471 */ public function test_default_query_var() { - $query = new WP_Query; + $query = new WP_Query(); $this->assertSame( '', $query->get( 'nonexistent' ) ); $this->assertFalse( $query->get( 'nonexistent', false ) ); $this->assertTrue( $query->get( 'nonexistent', true ) ); diff --git a/tests/phpunit/tests/query/generatePostdata.php b/tests/phpunit/tests/query/generatePostdata.php index c223e4b59859d..5d39dfb5d4ba5 100644 --- a/tests/phpunit/tests/query/generatePostdata.php +++ b/tests/phpunit/tests/query/generatePostdata.php @@ -19,7 +19,7 @@ public function test_setup_by_id() { * @ticket 42814 */ public function test_setup_by_fake_post() { - $fake = new stdClass; + $fake = new stdClass(); $fake->ID = 98765; $data = generate_postdata( $fake->ID ); diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index cabfba7c5b590..985ae06f7a9ca 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -33,7 +33,7 @@ public function test_setup_by_id() { * @ticket 30970 */ public function test_setup_by_fake_post() { - $fake = new stdClass; + $fake = new stdClass(); $fake->ID = 98765; setup_postdata( $fake->ID ); diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php index 02312ba6ce3ea..b7342a0a438dd 100644 --- a/tests/phpunit/tests/rest-api/rest-block-type-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-type-controller.php @@ -624,15 +624,15 @@ public function test_get_item_no_permission() { * @ticket 47620 */ public function test_prepare_item() { - $registry = new WP_Block_Type_Registry; + $registry = new WP_Block_Type_Registry(); $settings = array( 'icon' => 'text', 'render_callback' => '__return_null', ); $registry->register( 'fake/line', $settings ); $block_type = $registry->get_registered( 'fake/line' ); - $endpoint = new WP_REST_Block_Types_Controller; - $request = new WP_REST_Request; + $endpoint = new WP_REST_Block_Types_Controller(); + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $response = $endpoint->prepare_item_for_response( $block_type, $request ); $this->check_block_type_object( $block_type, $response->get_data(), $response->get_links() ); @@ -642,15 +642,15 @@ public function test_prepare_item() { * @ticket 47620 */ public function test_prepare_item_limit_fields() { - $registry = new WP_Block_Type_Registry; + $registry = new WP_Block_Type_Registry(); $settings = array( 'icon' => 'text', 'render_callback' => '__return_null', ); $registry->register( 'fake/line', $settings ); $block_type = $registry->get_registered( 'fake/line' ); - $request = new WP_REST_Request; - $endpoint = new WP_REST_Block_Types_Controller; + $request = new WP_REST_Request(); + $endpoint = new WP_REST_Block_Types_Controller(); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'name' ); $response = $endpoint->prepare_item_for_response( $block_type, $request ); diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index 805472487f021..070dac504745d 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -1093,7 +1093,7 @@ public function test_prepare_item() { } public function test_prepare_item_limit_fields() { - $request = new WP_REST_Request; + $request = new WP_REST_Request(); $endpoint = new WP_REST_Terms_Controller( 'category' ); $request->set_param( '_fields', 'id,name' ); $term = get_term( 1, 'category' ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index ef9aec3809059..be8036e90b258 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -152,7 +152,7 @@ public static function wpTearDownAfterClass() { public function set_up() { parent::set_up(); - $this->endpoint = new WP_REST_Comments_Controller; + $this->endpoint = new WP_REST_Comments_Controller(); if ( is_multisite() ) { update_site_option( 'site_admins', array( 'superadmin' ) ); } @@ -953,7 +953,7 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { wp_set_current_user( self::$admin_id ); - $endpoint = new WP_REST_Comments_Controller; + $endpoint = new WP_REST_Comments_Controller(); $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,status' ); diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index cc804a80fc276..7101a38c7cf9f 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -247,7 +247,7 @@ public function set_up() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); } @@ -380,7 +380,7 @@ public function test_get_value_types() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); add_post_meta( self::$post_id, 'test_string', 42 ); diff --git a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php index 901e8bb35783e..2f1e92cbae6da 100644 --- a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php @@ -125,8 +125,8 @@ public function test_delete_item() { public function test_prepare_item() { $obj = get_post_status_object( 'publish' ); - $endpoint = new WP_REST_Post_Statuses_Controller; - $request = new WP_REST_Request; + $endpoint = new WP_REST_Post_Statuses_Controller(); + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $data = $endpoint->prepare_item_for_response( $obj, $request ); $this->check_post_status_obj( $obj, $data->get_data(), $data->get_links() ); @@ -134,8 +134,8 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { $obj = get_post_status_object( 'publish' ); - $request = new WP_REST_Request; - $endpoint = new WP_REST_Post_Statuses_Controller; + $request = new WP_REST_Request(); + $endpoint = new WP_REST_Post_Statuses_Controller(); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $obj, $request ); diff --git a/tests/phpunit/tests/rest-api/rest-post-types-controller.php b/tests/phpunit/tests/rest-api/rest-post-types-controller.php index 58e1698426488..a56aefa4ad507 100644 --- a/tests/phpunit/tests/rest-api/rest-post-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-types-controller.php @@ -133,8 +133,8 @@ public function test_delete_item() { public function test_prepare_item() { $obj = get_post_type_object( 'post' ); - $endpoint = new WP_REST_Post_Types_Controller; - $request = new WP_REST_Request; + $endpoint = new WP_REST_Post_Types_Controller(); + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $response = $endpoint->prepare_item_for_response( $obj, $request ); $this->check_post_type_obj( 'edit', $obj, $response->get_data(), $response->get_links() ); @@ -142,8 +142,8 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { $obj = get_post_type_object( 'post' ); - $request = new WP_REST_Request; - $endpoint = new WP_REST_Post_Types_Controller; + $request = new WP_REST_Request(); + $endpoint = new WP_REST_Post_Types_Controller(); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $obj, $request ); diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index afc1ebc125830..c58af7c346e8e 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -20,7 +20,7 @@ public function set_up() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 ); diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index a4b566f7b2604..945d97a304a22 100644 --- a/tests/phpunit/tests/rest-api/rest-tags-controller.php +++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php @@ -1211,7 +1211,7 @@ public function test_prepare_item() { } public function test_prepare_item_limit_fields() { - $request = new WP_REST_Request; + $request = new WP_REST_Request(); $endpoint = new WP_REST_Terms_Controller( 'post_tag' ); $request->set_param( '_fields', 'id,name' ); $term = get_term_by( 'id', self::factory()->tag->create(), 'post_tag' ); diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php index 78593e6bd86d5..e2901c630729d 100644 --- a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php +++ b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php @@ -174,8 +174,8 @@ public function test_delete_item() { public function test_prepare_item() { $tax = get_taxonomy( 'category' ); - $endpoint = new WP_REST_Taxonomies_Controller; - $request = new WP_REST_Request; + $endpoint = new WP_REST_Taxonomies_Controller(); + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $response = $endpoint->prepare_item_for_response( $tax, $request ); $this->check_taxonomy_object( 'edit', $tax, $response->get_data(), $response->get_links() ); @@ -183,8 +183,8 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { $tax = get_taxonomy( 'category' ); - $request = new WP_REST_Request; - $endpoint = new WP_REST_Taxonomies_Controller; + $request = new WP_REST_Request(); + $endpoint = new WP_REST_Taxonomies_Controller(); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $tax, $request ); diff --git a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php index 5a61623387055..21d4ca86cd69d 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -194,7 +194,7 @@ public function set_up() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); } @@ -327,7 +327,7 @@ public function test_get_value_types() { /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; - $wp_rest_server = new Spy_REST_Server; + $wp_rest_server = new Spy_REST_Server(); do_action( 'rest_api_init', $wp_rest_server ); add_term_meta( self::$category_id, 'test_string', 42 ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 849b0e5464496..05e01a6e921df 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -974,7 +974,7 @@ public function test_get_item() { public function test_prepare_item() { wp_set_current_user( self::$user ); - $request = new WP_REST_Request; + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $user = get_user_by( 'id', get_current_user_id() ); $data = $this->endpoint->prepare_item_for_response( $user, $request ); @@ -984,7 +984,7 @@ public function test_prepare_item() { public function test_prepare_item_limit_fields() { wp_set_current_user( self::$user ); - $request = new WP_REST_Request; + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $user = get_user_by( 'id', get_current_user_id() ); diff --git a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php index 5c6f22bfee426..5074205fb7764 100644 --- a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php @@ -118,7 +118,7 @@ public function test_get_items() { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertGreaterThan( 1, count( $data ) ); - $endpoint = new WP_REST_Widget_Types_Controller; + $endpoint = new WP_REST_Widget_Types_Controller(); foreach ( $data as $item ) { $widget_type = $endpoint->get_widget( $item['name'] ); $this->check_widget_type_object( $widget_type, $item, $item['_links'] ); @@ -180,7 +180,7 @@ public function test_get_item() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/widget-types/' . $widget_name ); $response = rest_get_server()->dispatch( $request ); - $endpoint = new WP_REST_Widget_Types_Controller; + $endpoint = new WP_REST_Widget_Types_Controller(); $widget_type = $endpoint->get_widget( $widget_name ); $this->check_widget_type_object( $widget_type, $response->get_data(), $response->get_links() ); } @@ -198,7 +198,7 @@ static function() {} wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/widget-types/' . $widget_id ); $response = rest_get_server()->dispatch( $request ); - $endpoint = new WP_REST_Widget_Types_Controller; + $endpoint = new WP_REST_Widget_Types_Controller(); $widget_type = $endpoint->get_widget( $widget_id ); $this->check_widget_type_object( $widget_type, $response->get_data(), $response->get_links() ); } @@ -298,9 +298,9 @@ public function test_get_item_no_permission() { * @ticket 41683 */ public function test_prepare_item() { - $endpoint = new WP_REST_Widget_Types_Controller; + $endpoint = new WP_REST_Widget_Types_Controller(); $widget_type = $endpoint->get_widget( 'calendar' ); - $request = new WP_REST_Request; + $request = new WP_REST_Request(); $request->set_param( 'context', 'edit' ); $response = $endpoint->prepare_item_for_response( $widget_type, $request ); $this->check_widget_type_object( $widget_type, $response->get_data(), $response->get_links() ); @@ -366,7 +366,7 @@ public function test_encode_form_data_with_no_input() { array( 'encoded' => base64_encode( serialize( array() ) ), 'hash' => wp_hash( serialize( array() ) ), - 'raw' => new stdClass, + 'raw' => new stdClass(), ), $data['instance'] ); @@ -402,7 +402,7 @@ public function test_encode_form_data_with_number() { array( 'encoded' => base64_encode( serialize( array() ) ), 'hash' => wp_hash( serialize( array() ) ), - 'raw' => new stdClass, + 'raw' => new stdClass(), ), $data['instance'] );