Skip to content

Commit

Permalink
Coding Standards: Always use parentheses when instantiating an object.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SergeyBiryukov committed Nov 29, 2022
1 parent 6821cb0 commit e50c65c
Show file tree
Hide file tree
Showing 86 changed files with 166 additions and 166 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-language-pack-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-automatic-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-site-health-auto-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 ) {
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/image-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 '<p>' . __( 'No items.' ) . '</p>';
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/privacy-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).' );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/translation-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/user-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/category-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/class-wp-oembed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-text-diff-renderer-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ins> or <del>'s.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/comment-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit e50c65c

Please sign in to comment.