From 54e1b4b95918410bfb999ad6a5364dc9af0a47f8 Mon Sep 17 00:00:00 2001 From: SergeyBiryukov Date: Sat, 9 Sep 2023 09:26:01 +0000 Subject: [PATCH] Coding Standards: Use pre-increment/decrement for stand-alone statements. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: This is enforced by WPCS 3.0.0: 1. There should be no space between an increment/decrement operator and the variable it applies to. 2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around. References: * [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators] * [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators] Props jrf. See #59161, #58831. git-svn-id: https://develop.svn.wordpress.org/trunk@56549 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-comments.php | 14 ++++++------- src/wp-admin/edit.php | 8 ++++---- src/wp-admin/includes/ajax-actions.php | 6 +++--- .../includes/class-language-pack-upgrader.php | 2 +- .../includes/class-plugin-upgrader.php | 2 +- .../includes/class-theme-upgrader.php | 2 +- .../includes/class-wp-automatic-updater.php | 4 ++-- src/wp-admin/includes/class-wp-list-table.php | 2 +- .../includes/class-wp-plugins-list-table.php | 2 +- .../includes/class-wp-posts-list-table.php | 12 +++++------ .../class-wp-privacy-requests-table.php | 10 +++++----- .../includes/class-wp-site-health.php | 20 +++++++++---------- .../includes/class-wp-terms-list-table.php | 2 +- src/wp-admin/includes/file.php | 4 ++-- src/wp-admin/includes/image-edit.php | 2 +- src/wp-admin/includes/media.php | 2 +- src/wp-admin/includes/menu.php | 2 +- src/wp-admin/includes/misc.php | 4 ++-- src/wp-admin/includes/ms.php | 2 +- src/wp-admin/includes/template.php | 4 ++-- src/wp-admin/includes/upgrade.php | 2 +- src/wp-admin/includes/widgets.php | 4 ++-- src/wp-admin/link.php | 2 +- src/wp-admin/menu.php | 2 +- src/wp-admin/network/users.php | 2 +- src/wp-admin/users.php | 2 +- src/wp-admin/widgets-form.php | 4 ++-- .../themes/twentyeleven/functions.php | 6 +++--- src/wp-content/themes/twentyeleven/image.php | 2 +- .../themes/twentyeleven/showcase.php | 4 ++-- .../inc/template-functions.php | 2 +- .../themes/twentyten/loop-attachment.php | 2 +- src/wp-content/themes/twentytwelve/image.php | 2 +- src/wp-content/themes/twentytwenty/index.php | 2 +- .../inc/template-functions.php | 2 +- src/wp-includes/class-walker-comment.php | 2 +- src/wp-includes/class-wp-block.php | 2 +- src/wp-includes/class-wp-comment-query.php | 2 +- .../class-wp-customize-manager.php | 4 ++-- src/wp-includes/class-wp-hook.php | 4 ++-- src/wp-includes/class-wp-list-util.php | 4 ++-- src/wp-includes/class-wp-meta-query.php | 2 +- src/wp-includes/class-wp-query.php | 8 ++++---- src/wp-includes/class-wp-rewrite.php | 2 +- src/wp-includes/class-wp-theme-json.php | 4 ++-- src/wp-includes/class-wp-walker.php | 6 +++--- src/wp-includes/class-wpdb.php | 12 +++++------ src/wp-includes/comment-template.php | 4 ++-- src/wp-includes/compat.php | 2 +- src/wp-includes/formatting.php | 14 ++++++------- src/wp-includes/functions.php | 8 ++++---- .../html-api/class-wp-html-tag-processor.php | 6 +++--- src/wp-includes/media.php | 8 ++++---- src/wp-includes/ms-site.php | 2 +- src/wp-includes/pomo/mo.php | 2 +- src/wp-includes/pomo/plural-forms.php | 14 ++++++------- src/wp-includes/pomo/po.php | 8 ++++---- src/wp-includes/pomo/translations.php | 2 +- src/wp-includes/post.php | 8 ++++---- src/wp-includes/taxonomy.php | 2 +- src/wp-includes/theme-templates.php | 2 +- src/wp-includes/user.php | 6 +++--- .../widgets/class-wp-widget-calendar.php | 2 +- .../widgets/class-wp-widget-media.php | 2 +- .../class-wp-unittest-generator-sequence.php | 4 ++-- .../testcase-rest-post-type-controller.php | 2 +- tests/phpunit/includes/wp-profiler.php | 14 ++++++------- tests/phpunit/tests/blocks/wpBlockList.php | 8 ++++---- tests/phpunit/tests/comment/metaCache.php | 8 ++++---- tests/phpunit/tests/comment/query.php | 12 +++++------ tests/phpunit/tests/date/theDate.php | 2 +- tests/phpunit/tests/feed/atom.php | 2 +- tests/phpunit/tests/import/base.php | 2 +- tests/phpunit/tests/multisite/network.php | 2 +- tests/phpunit/tests/multisite/site.php | 2 +- tests/phpunit/tests/oembed/controller.php | 2 +- tests/phpunit/tests/pluggable/signatures.php | 2 +- tests/phpunit/tests/pomo/pluralForms.php | 2 +- tests/phpunit/tests/post/getPageByPath.php | 4 ++-- tests/phpunit/tests/post/revisions.php | 4 ++-- .../rest-api/rest-attachments-controller.php | 4 ++-- .../rest-api/rest-categories-controller.php | 4 ++-- .../rest-api/rest-comments-controller.php | 4 ++-- .../tests/rest-api/rest-posts-controller.php | 8 ++++---- .../rest-api/rest-sidebars-controller.php | 2 +- .../tests/rest-api/rest-tags-controller.php | 8 ++++---- .../tests/rest-api/rest-users-controller.php | 4 ++-- .../rest-api/rest-widgets-controller.php | 2 +- .../rest-api/wpRestMenuItemsController.php | 2 +- tests/phpunit/tests/term/cache.php | 8 ++++---- tests/phpunit/tests/term/getTerm.php | 2 +- tests/phpunit/tests/term/meta.php | 8 ++++---- .../tests/theme/wpThemeJsonResolver.php | 2 +- tests/phpunit/tests/url.php | 2 +- tests/phpunit/tests/widgets/wpWidgetText.php | 2 +- 95 files changed, 212 insertions(+), 212 deletions(-) diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index d7f14f2cd09aa..ffc1d58d8c548 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -84,31 +84,31 @@ switch ( $doaction ) { case 'approve': wp_set_comment_status( $comment_id, 'approve' ); - $approved++; + ++$approved; break; case 'unapprove': wp_set_comment_status( $comment_id, 'hold' ); - $unapproved++; + ++$unapproved; break; case 'spam': wp_spam_comment( $comment_id ); - $spammed++; + ++$spammed; break; case 'unspam': wp_unspam_comment( $comment_id ); - $unspammed++; + ++$unspammed; break; case 'trash': wp_trash_comment( $comment_id ); - $trashed++; + ++$trashed; break; case 'untrash': wp_untrash_comment( $comment_id ); - $untrashed++; + ++$untrashed; break; case 'delete': wp_delete_comment( $comment_id ); - $deleted++; + ++$deleted; break; } } diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index b5ed3322ae401..90b342330eea7 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -124,7 +124,7 @@ } if ( wp_check_post_lock( $post_id ) ) { - $locked++; + ++$locked; continue; } @@ -132,7 +132,7 @@ wp_die( __( 'Error in moving the item to Trash.' ) ); } - $trashed++; + ++$trashed; } $sendback = add_query_arg( @@ -160,7 +160,7 @@ wp_die( __( 'Error in restoring the item from Trash.' ) ); } - $untrashed++; + ++$untrashed; } $sendback = add_query_arg( 'untrashed', $untrashed, $sendback ); @@ -185,7 +185,7 @@ wp_die( __( 'Error in deleting the item.' ) ); } } - $deleted++; + ++$deleted; } $sendback = add_query_arg( 'deleted', $deleted, $sendback ); break; diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 16b827d7bd5d0..8aada30959372 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -2149,7 +2149,7 @@ function wp_ajax_inline_save() { while ( $parent > 0 ) { $parent_post = get_post( $parent ); $parent = $parent_post->post_parent; - $level++; + ++$level; } } @@ -2211,7 +2211,7 @@ function wp_ajax_inline_save_tax() { while ( $parent > 0 ) { $parent_tag = get_term( $parent, $taxonomy ); $parent = $parent_tag->parent; - $level++; + ++$level; } $wp_list_table->single_row( $tag, $level ); @@ -2821,7 +2821,7 @@ function wp_ajax_set_attachment_thumbnail() { } if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) { - $success++; + ++$success; } } diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index adeac200d4f80..3c3d42a56a9c8 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -238,7 +238,7 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) { $destination .= '/themes'; } - $this->update_current++; + ++$this->update_current; $options = array( 'package' => $language_update->package, diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index 48eaee639087c..02743f64561e9 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -330,7 +330,7 @@ public function bulk_upgrade( $plugins, $args = array() ) { $this->update_count = count( $plugins ); $this->update_current = 0; foreach ( $plugins as $plugin ) { - $this->update_current++; + ++$this->update_current; $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true ); if ( ! isset( $current->response[ $plugin ] ) ) { diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 688f8d612de64..12bd4772919cc 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -426,7 +426,7 @@ public function bulk_upgrade( $themes, $args = array() ) { $this->update_count = count( $themes ); $this->update_current = 0; foreach ( $themes as $theme ) { - $this->update_current++; + ++$this->update_current; $this->skin->theme_info = $this->theme_info( $theme ); diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index e835f0cd35984..bb8cb402aff54 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -1390,7 +1390,7 @@ protected function send_debug_email() { } else { /* translators: %s: WordPress version. */ $body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name ); - $failures++; + ++$failures; } $body[] = ''; @@ -1432,7 +1432,7 @@ protected function send_debug_email() { if ( ! $item->result || is_wp_error( $item->result ) ) { /* translators: %s: Name of plugin / theme / translation. */ $body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name ); - $failures++; + ++$failures; } } } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 3fa6f54dd4a85..8258ebf2a60b2 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -1410,7 +1410,7 @@ public function print_column_headers( $with_id = true ) { '' . '' . ''; - $cb_counter++; + ++$cb_counter; } foreach ( $columns as $column_key => $column_display_name ) { diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index 56e76251dacc3..b633fcd116504 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -728,7 +728,7 @@ public function single_row( $item ) { $suffix = 2; while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) { $plugin_id_attr = "$plugin_slug-$suffix"; - $suffix++; + ++$suffix; } $plugin_id_attrs[] = $plugin_id_attr; diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 6e9bcdc527add..abb305f8e49b0 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -898,7 +898,7 @@ private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 2 $to_display[ $page->ID ] = $level; } - $count++; + ++$count; if ( isset( $children_pages ) ) { $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); @@ -917,7 +917,7 @@ private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 2 $to_display[ $op->ID ] = 0; } - $count++; + ++$count; } } } @@ -992,7 +992,7 @@ private function _page_rows( &$children_pages, &$count, $parent_page, $level, $p while ( $my_parent = array_pop( $my_parents ) ) { $to_display[ $my_parent->ID ] = $level - $num_parents; - $num_parents--; + --$num_parents; } } @@ -1000,7 +1000,7 @@ private function _page_rows( &$children_pages, &$count, $parent_page, $level, $p $to_display[ $page->ID ] = $level; } - $count++; + ++$count; $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); } @@ -1097,7 +1097,7 @@ public function column_title( $post ) { break; } - $this->current_level++; + ++$this->current_level; $find_main_page = (int) $parent->post_parent; if ( ! isset( $parent_name ) ) { @@ -2085,7 +2085,7 @@ public function inline_edit() { diff --git a/src/wp-admin/includes/class-wp-privacy-requests-table.php b/src/wp-admin/includes/class-wp-privacy-requests-table.php index cbc8c01892617..e7ffeebd20e93 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -239,9 +239,9 @@ public function process_bulk_action() { $resend = _wp_privacy_resend_request( $request_id ); if ( $resend && ! is_wp_error( $resend ) ) { - $count++; + ++$count; } else { - $failures++; + ++$failures; } } @@ -286,7 +286,7 @@ public function process_bulk_action() { $result = _wp_privacy_completed_request( $request_id ); if ( $result && ! is_wp_error( $result ) ) { - $count++; + ++$count; } } @@ -309,9 +309,9 @@ public function process_bulk_action() { case 'delete': foreach ( $request_ids as $request_id ) { if ( wp_delete_post( $request_id, true ) ) { - $count++; + ++$count; } else { - $failures++; + ++$failures; } } diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 5ab784af40ed9..6d87edee1b865 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -381,14 +381,14 @@ public function get_test_plugin_version() { // Loop over the available plugins and check their versions and active state. foreach ( $plugins as $plugin_path => $plugin ) { - $plugins_total++; + ++$plugins_total; if ( is_plugin_active( $plugin_path ) ) { - $plugins_active++; + ++$plugins_active; } if ( array_key_exists( $plugin_path, $plugin_updates ) ) { - $plugins_need_update++; + ++$plugins_need_update; } } @@ -543,21 +543,21 @@ public function get_test_theme_version() { } foreach ( $all_themes as $theme_slug => $theme ) { - $themes_total++; + ++$themes_total; if ( array_key_exists( $theme_slug, $theme_updates ) ) { - $themes_need_updates++; + ++$themes_need_updates; } } // If this is a child theme, increase the allowed theme count by one, to account for the parent. if ( is_child_theme() ) { - $allowed_theme_count++; + ++$allowed_theme_count; } // If there's a default theme installed and not in use, we count that as allowed as well. if ( $has_default_theme && ! $using_default_theme ) { - $allowed_theme_count++; + ++$allowed_theme_count; } if ( $themes_total > $allowed_theme_count ) { @@ -3293,11 +3293,11 @@ public function wp_cron_scheduled_check() { foreach ( $results as $result ) { if ( 'critical' === $result['status'] ) { - $site_status['critical']++; + ++$site_status['critical']; } elseif ( 'recommended' === $result['status'] ) { - $site_status['recommended']++; + ++$site_status['recommended']; } else { - $site_status['good']++; + ++$site_status['good']; } } diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 9f2febedc229f..8778e542009af 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -310,7 +310,7 @@ private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$coun while ( $my_parent = array_pop( $my_parents ) ) { echo "\t"; $this->single_row( $my_parent, $level - $num_parents ); - $num_parents--; + --$num_parents; } } diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index 94777598e86db..aa8e25c8ed5fa 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1493,7 +1493,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f // Ensure only valid-length signatures are considered. if ( SODIUM_CRYPTO_SIGN_BYTES !== strlen( $signature_raw ) ) { - $skipped_signature++; + ++$skipped_signature; continue; } @@ -1502,7 +1502,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f // Only pass valid public keys through. if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) { - $skipped_key++; + ++$skipped_key; continue; } diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 58861b1a6f66b..4e97e90acaa53 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -979,7 +979,7 @@ function wp_save_image( $post_id ) { $new_path = "{$dirname}/$new_filename"; if ( file_exists( $new_path ) ) { - $suffix++; + ++$suffix; } else { break; } diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index cee19890a762b..e7b4c10369387 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -638,7 +638,7 @@ function wp_iframe( $content_func, ...$args ) { */ function media_buttons( $editor_id = 'content' ) { static $instance = 0; - $instance++; + ++$instance; $post = get_post(); diff --git a/src/wp-admin/includes/menu.php b/src/wp-admin/includes/menu.php index ae8e06be6e747..da1b2ebf5349f 100644 --- a/src/wp-admin/includes/menu.php +++ b/src/wp-admin/includes/menu.php @@ -228,7 +228,7 @@ function add_menu_classes( $menu ) { $i = 0; foreach ( $menu as $order => $top ) { - $i++; + ++$i; if ( 0 === $order ) { // Dashboard is always shown/single. $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] ); diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 24cd26d661842..3c55f3f59af32 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -403,7 +403,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) { $size = count( $tree ); foreach ( $tree as $label => $theme_file ) : - $index++; + ++$index; if ( ! is_array( $theme_file ) ) { wp_print_theme_file_tree( $theme_file, $level, $index, $size ); @@ -505,7 +505,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $ $size = count( $tree ); foreach ( $tree as $label => $plugin_file ) : - $index++; + ++$index; if ( ! is_array( $plugin_file ) ) { wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size ); diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 1e38133a3f3d8..b52a50a2f9fe7 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -734,7 +734,7 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) { while ( $c < 10 && get_id_from_blogname( $post_name ) ) { $post_name .= mt_rand( 1, 10 ); - $c++; + ++$c; } if ( $post_name !== $data['post_name'] ) { diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 6feac91493002..0a3699672d9ba 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1355,7 +1355,7 @@ function do_meta_boxes( $screen, $context, $data_object ) { } } - $i++; + ++$i; // get_hidden_meta_boxes() doesn't apply in the block editor. $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; echo '
' . "\n"; @@ -1550,7 +1550,7 @@ function do_accordion_sections( $screen, $context, $data_object ) { continue; } - $i++; + ++$i; $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : ''; $open_class = ''; diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 0f081222393e6..bf0b12405da5c 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -1292,7 +1292,7 @@ function upgrade_230() { $num = 2; do { $alt_slug = $slug . "-$num"; - $num++; + ++$num; $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); } while ( $slug_check ); diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index 93979b6a25de5..682f596d941f7 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -134,7 +134,7 @@ function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { function wp_list_widget_controls_dynamic_sidebar( $params ) { global $wp_registered_widgets; static $i = 0; - $i++; + ++$i; $widget_id = $params[0]['widget_id']; $id = isset( $params[0]['_temp_id'] ) ? $params[0]['_temp_id'] : $widget_id; @@ -168,7 +168,7 @@ function next_widget_id_number( $id_base ) { $number = max( $number, $matches[1] ); } } - $number++; + ++$number; return $number; } diff --git a/src/wp-admin/link.php b/src/wp-admin/link.php index 084b1d7566ec1..f07cc5897d3a3 100644 --- a/src/wp-admin/link.php +++ b/src/wp-admin/link.php @@ -45,7 +45,7 @@ $link_id = (int) $link_id; if ( wp_delete_link( $link_id ) ) { - $deleted++; + ++$deleted; } } diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index aa89f6c571328..6a90772155a54 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -161,7 +161,7 @@ */ $core_menu_positions = array( 59, 60, 65, 70, 75, 80, 85, 99 ); while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position, $core_menu_positions, true ) ) { - $ptype_menu_position++; + ++$ptype_menu_position; } $menu[ $ptype_menu_position ] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class, $ptype_menu_id, $menu_icon ); diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index 60ab967b94b27..d0b40e710d286 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -184,7 +184,7 @@ continue; } wpmu_delete_user( $id ); - $i++; + ++$i; } } diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index ec8886b61b1b4..97b96a7b1a0b7 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -381,7 +381,7 @@ ); echo "\n"; - $go_delete++; + ++$go_delete; } } ?> diff --git a/src/wp-admin/widgets-form.php b/src/wp-admin/widgets-form.php index b77f23dbc3aea..aa01798856506 100644 --- a/src/wp-admin/widgets-form.php +++ b/src/wp-admin/widgets-form.php @@ -310,7 +310,7 @@ } else { $j = count( $sidebars_widgets[ $sbname ] ); if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) { - $j++; + ++$j; } } $selected = ''; @@ -540,7 +540,7 @@
diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index f17bf729f38e1..4c478fd8e318f 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -667,15 +667,15 @@ function twentyeleven_footer_sidebar_class() { $count = 0; if ( is_active_sidebar( 'sidebar-3' ) ) { - $count++; + ++$count; } if ( is_active_sidebar( 'sidebar-4' ) ) { - $count++; + ++$count; } if ( is_active_sidebar( 'sidebar-5' ) ) { - $count++; + ++$count; } $class = ''; diff --git a/src/wp-content/themes/twentyeleven/image.php b/src/wp-content/themes/twentyeleven/image.php index a727ea147acfc..973a249b5b077 100644 --- a/src/wp-content/themes/twentyeleven/image.php +++ b/src/wp-content/themes/twentyeleven/image.php @@ -77,7 +77,7 @@ // If there is more than 1 attachment in a gallery... if ( count( $attachments ) > 1 ) { - $k++; + ++$k; if ( isset( $attachments[ $k ] ) ) { // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index c867b830d9571..0821040f76d99 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -88,7 +88,7 @@ $featured->the_post(); // Increase the counter. - $counter_slider++; + ++$counter_slider; /* * We're going to add a class to our featured post for featured images. @@ -153,7 +153,7 @@ // Let's roll again. while ( $featured->have_posts() ) : $featured->the_post(); - $counter_slider++; + ++$counter_slider; if ( 1 === $counter_slider ) { $class = ' class="active"'; } else { diff --git a/src/wp-content/themes/twentyseventeen/inc/template-functions.php b/src/wp-content/themes/twentyseventeen/inc/template-functions.php index 2c2e9504cced5..6b61eae85b239 100644 --- a/src/wp-content/themes/twentyseventeen/inc/template-functions.php +++ b/src/wp-content/themes/twentyseventeen/inc/template-functions.php @@ -89,7 +89,7 @@ function twentyseventeen_panel_count() { // Create a setting and control for each of the sections available in the theme. for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) { if ( get_theme_mod( 'panel_' . $i ) ) { - $panel_count++; + ++$panel_count; } } diff --git a/src/wp-content/themes/twentyten/loop-attachment.php b/src/wp-content/themes/twentyten/loop-attachment.php index 007b5aa036f9d..5c348d6cc78f3 100644 --- a/src/wp-content/themes/twentyten/loop-attachment.php +++ b/src/wp-content/themes/twentyten/loop-attachment.php @@ -107,7 +107,7 @@ // If there is more than 1 image attachment in a gallery... if ( count( $attachments ) > 1 ) { - $k++; + ++$k; if ( isset( $attachments[ $k ] ) ) { // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/src/wp-content/themes/twentytwelve/image.php b/src/wp-content/themes/twentytwelve/image.php index ffdde2c00d23a..c17067cb23de3 100644 --- a/src/wp-content/themes/twentytwelve/image.php +++ b/src/wp-content/themes/twentytwelve/image.php @@ -77,7 +77,7 @@ // If there is more than 1 attachment in a gallery... if ( count( $attachments ) > 1 ) : - $k++; + ++$k; if ( isset( $attachments[ $k ] ) ) : // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/src/wp-content/themes/twentytwenty/index.php b/src/wp-content/themes/twentytwenty/index.php index 0c73e812e3adf..9c7442c6e9fd9 100644 --- a/src/wp-content/themes/twentytwenty/index.php +++ b/src/wp-content/themes/twentytwenty/index.php @@ -84,7 +84,7 @@ $i = 0; while ( have_posts() ) { - $i++; + ++$i; if ( $i > 1 ) { echo ''; } diff --git a/src/wp-content/themes/twentytwentyone/inc/template-functions.php b/src/wp-content/themes/twentytwentyone/inc/template-functions.php index a862dfac14a38..5c1ca0f1e116d 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -384,7 +384,7 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content if ( $is_matching_block ) { // Increment count. - $instances_count++; + ++$instances_count; // Add the block HTML. $blocks_content .= render_block( $block ); diff --git a/src/wp-includes/class-walker-comment.php b/src/wp-includes/class-walker-comment.php index 2aabcbd1583a0..825a28334b14f 100644 --- a/src/wp-includes/class-walker-comment.php +++ b/src/wp-includes/class-walker-comment.php @@ -174,7 +174,7 @@ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $ // Restores the more descriptive, specific name for use within this method. $comment = $data_object; - $depth++; + ++$depth; $GLOBALS['comment_depth'] = $depth; $GLOBALS['comment'] = $comment; diff --git a/src/wp-includes/class-wp-block.php b/src/wp-includes/class-wp-block.php index cdbc678f13d56..65d3af6a12f1a 100644 --- a/src/wp-includes/class-wp-block.php +++ b/src/wp-includes/class-wp-block.php @@ -244,7 +244,7 @@ public function render( $options = array() ) { $block_content .= $inner_block->render(); } - $index++; + ++$index; } } } diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index 40f283896653e..9ebddd1c74e15 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -1079,7 +1079,7 @@ protected function fill_descendants( $comments ) { wp_cache_set_multiple( $data, 'comment-queries' ); } - $level++; + ++$level; $levels[ $level ] = $child_ids; } while ( $child_ids ); diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 77176609bc04f..0bceee3454224 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -1077,7 +1077,7 @@ protected function dismiss_user_auto_draft_changesets() { continue; } if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) { - $dismissed++; + ++$dismissed; } } return $dismissed; @@ -1479,7 +1479,7 @@ public function import_theme_starter_content( $starter_content = array() ) { if ( ! $nav_menu_term_id ) { while ( isset( $changeset_data[ sprintf( 'nav_menu[%d]', $placeholder_id ) ] ) ) { - $placeholder_id--; + --$placeholder_id; } $nav_menu_term_id = $placeholder_id; $nav_menu_setting_id = sprintf( 'nav_menu[%d]', $placeholder_id ); diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php index 8a6cdfd09f758..9c1cac6d1c917 100644 --- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php @@ -317,7 +317,7 @@ public function apply_filters( $value, $args ) { unset( $this->iterations[ $nesting_level ] ); unset( $this->current_priority[ $nesting_level ] ); - $this->nesting_level--; + --$this->nesting_level; return $value; } @@ -359,7 +359,7 @@ public function do_all_hook( &$args ) { } while ( false !== next( $this->iterations[ $nesting_level ] ) ); unset( $this->iterations[ $nesting_level ] ); - $this->nesting_level--; + --$this->nesting_level; } /** diff --git a/src/wp-includes/class-wp-list-util.php b/src/wp-includes/class-wp-list-util.php index c394f2c613b0c..656035529186e 100644 --- a/src/wp-includes/class-wp-list-util.php +++ b/src/wp-includes/class-wp-list-util.php @@ -117,12 +117,12 @@ public function filter( $args = array(), $operator = 'AND' ) { if ( is_array( $obj ) ) { // Treat object as an array. if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) { - $matched++; + ++$matched; } } elseif ( is_object( $obj ) ) { // Treat object as an object. if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) { - $matched++; + ++$matched; } } } diff --git a/src/wp-includes/class-wp-meta-query.php b/src/wp-includes/class-wp-meta-query.php index 0c6867d84ee2a..69dde01ff077e 100644 --- a/src/wp-includes/class-wp-meta-query.php +++ b/src/wp-includes/class-wp-meta-query.php @@ -633,7 +633,7 @@ public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) $clause_key_base = $clause_key; while ( isset( $this->clauses[ $clause_key ] ) ) { $clause_key = $clause_key_base . '-' . $iterator; - $iterator++; + ++$iterator; } // Store the clause in our flat array. diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 16e1cfc248975..458b7898c2e8b 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -3470,7 +3470,7 @@ public function get_posts() { // Move to front, after other stickies. array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); // Increment the sticky offset. The next sticky will be placed at this offset. - $sticky_offset++; + ++$sticky_offset; // Remove post from sticky posts array. $offset = array_search( $sticky_post->ID, $sticky_posts, true ); unset( $sticky_posts[ $offset ] ); @@ -3500,7 +3500,7 @@ public function get_posts() { foreach ( $stickies as $sticky_post ) { array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); - $sticky_offset++; + ++$sticky_offset; } } } @@ -3620,7 +3620,7 @@ private function set_found_posts( $q, $limits ) { */ public function next_post() { - $this->current_post++; + ++$this->current_post; /** @var WP_Post */ $this->post = $this->posts[ $this->current_post ]; @@ -3730,7 +3730,7 @@ public function rewind_posts() { * @return WP_Comment Comment object. */ public function next_comment() { - $this->current_comment++; + ++$this->current_comment; /** @var WP_Comment */ $this->comment = $this->comments[ $this->current_comment ]; diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index 150eabcbd8de1..8bcf8fc962246 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -531,7 +531,7 @@ public function get_date_permastruct() { $front = $front . 'date/'; break; } - $tok_index++; + ++$tok_index; } $this->date_structure = $front . $date_endian; diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index b929c956086f8..227398facd2c5 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -3399,7 +3399,7 @@ public function set_spacing_sizes() { } if ( $below_midpoint_count < $steps_mid_point - 2 ) { - $x_small_count++; + ++$x_small_count; } $slug -= 10; @@ -3436,7 +3436,7 @@ public function set_spacing_sizes() { } if ( $above_midpoint_count > 1 ) { - $x_large_count++; + ++$x_large_count; } $slug += 10; diff --git a/src/wp-includes/class-wp-walker.php b/src/wp-includes/class-wp-walker.php index 28cecfe79ec46..d8c00a372322a 100644 --- a/src/wp-includes/class-wp-walker.php +++ b/src/wp-includes/class-wp-walker.php @@ -325,7 +325,7 @@ public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$arg $empty_array = array(); foreach ( $elements as $e ) { - $count++; + ++$count; if ( $count < $start ) { continue; } @@ -372,7 +372,7 @@ public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$arg } foreach ( $top_level_elements as $e ) { - $count++; + ++$count; // For the last page, need to unset earlier children in order to keep track of orphans. if ( $end >= $total_top && $count < $start ) { @@ -416,7 +416,7 @@ public function get_number_of_root_elements( $elements ) { foreach ( $elements as $e ) { if ( empty( $e->$parent_field ) ) { - $num++; + ++$num; } } return $num; diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 1510d82a9f190..39c467f03182d 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -1539,7 +1539,7 @@ public function prepare( $query, ...$args ) { $k = 1; $l = strlen( $s ); while ( $k <= $l && '%' === $s[ $l - $k ] ) { - $k++; + ++$k; } $placeholder = '%' . ( $k % 2 ? '%' : '' ) . $format . $type; @@ -1600,7 +1600,7 @@ public function prepare( $query, ...$args ) { $new_query .= $split_query[ $key - 2 ] . $split_query[ $key - 1 ] . $placeholder; $key += 3; - $arg_id++; + ++$arg_id; } // Replace $query; and add remaining $query characters, or index 0 if there were no placeholders. @@ -1632,7 +1632,7 @@ public function prepare( $query, ...$args ) { $used_placeholders[ $arg_pos ][] = $placeholder; $key += 3; - $arg_id++; + ++$arg_id; } $conflicts = array(); @@ -2304,7 +2304,7 @@ public function query( $query ) { if ( $this->result instanceof mysqli_result ) { while ( $row = mysqli_fetch_object( $this->result ) ) { $this->last_result[ $num_rows ] = $row; - $num_rows++; + ++$num_rows; } } @@ -2334,7 +2334,7 @@ private function _do_query( $query ) { $this->result = mysqli_query( $this->dbh, $query ); } - $this->num_queries++; + ++$this->num_queries; if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { $this->log_query( @@ -3878,7 +3878,7 @@ public function get_col_info( $info_type = 'name', $col_offset = -1 ) { $new_array = array(); foreach ( (array) $this->col_info as $col ) { $new_array[ $i ] = $col->{$info_type}; - $i++; + ++$i; } return $new_array; } else { diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 59b2361d846d8..03f450dc9bef7 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -549,7 +549,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null ) $classes[] = 'even'; } - $comment_alt++; + ++$comment_alt; // Alt for top-level comments. if ( 1 == $comment_depth ) { @@ -559,7 +559,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null ) } else { $classes[] = 'thread-even'; } - $comment_thread_alt++; + ++$comment_thread_alt; } $classes[] = "depth-$comment_depth"; diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index 2b8de57bd7b9b..5bfdbc23d6d60 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -203,7 +203,7 @@ function _mb_strlen( $str, $encoding = null ) { do { // We had some string left over from the last round, but we counted it in that last round. - $count--; + --$count; /* * Split by UTF-8 character, limit to 1000 characters (last array element will contain diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index be37097220129..fddd2b1aa1db4 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -476,7 +476,7 @@ function wpautop( $text, $br = true ) { $pre_tags[ $name ] = substr( $text_part, $start ) . ''; $text .= substr( $text_part, 0, $start ) . $name; - $i++; + ++$i; } $text .= $last_part; @@ -2657,14 +2657,14 @@ function force_balance_tags( $text ) { } elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag. $tag = ''; // Close tag. array_pop( $tagstack ); - $stacksize--; + --$stacksize; } else { // Closing tag not at top, search for it. for ( $j = $stacksize - 1; $j >= 0; $j-- ) { if ( $tagstack[ $j ] === $tag ) { // Add tag to tagqueue. for ( $k = $stacksize - 1; $k >= $j; $k-- ) { $tagqueue .= ''; - $stacksize--; + --$stacksize; } break; } @@ -2692,7 +2692,7 @@ function force_balance_tags( $text ) { */ if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) { $tagqueue = ''; - $stacksize--; + --$stacksize; } $stacksize = array_push( $tagstack, $tag ); } @@ -3083,7 +3083,7 @@ function make_clickable( $text ) { || preg_match( '|^]|i', $piece ) || preg_match( '|^]|i', $piece ) ) { - $nested_code_pre++; + ++$nested_code_pre; } elseif ( $nested_code_pre && ( '' === strtolower( $piece ) || '' === strtolower( $piece ) @@ -3091,7 +3091,7 @@ function make_clickable( $text ) { || '' === strtolower( $piece ) ) ) { - $nested_code_pre--; + --$nested_code_pre; } if ( $nested_code_pre @@ -5354,7 +5354,7 @@ function wp_sprintf_l( $pattern, $args ) { $i = count( $args ); while ( $i ) { $arg = array_shift( $args ); - $i--; + --$i; if ( 0 === $i ) { $result .= $l['between_last_two'] . $arg; } else { diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 4a2a2b1779f2d..6963de3a3831d 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -2696,7 +2696,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) ); $number = $new_number; - $i++; + ++$i; } } } @@ -2769,7 +2769,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) ); $number = $new_number; - $i++; + ++$i; } } } @@ -7163,7 +7163,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr $trace = debug_backtrace( false ); $caller = array(); $check_class = ! is_null( $ignore_class ); - $skip_frames++; // Skip this function. + ++$skip_frames; // Skip this function. if ( ! isset( $truncate_paths ) ) { $truncate_paths = array( @@ -7174,7 +7174,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr foreach ( $trace as $call ) { if ( $skip_frames > 0 ) { - $skip_frames--; + --$skip_frames; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class === $call['class'] ) { continue; // Filter out calls. diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 2e84b3d7193a0..541b5baf0bfbe 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -951,7 +951,7 @@ private function parse_next_tag() { if ( '/' === $this->html[ $at + 1 ] ) { $this->is_closing_tag = true; - $at++; + ++$at; } else { $this->is_closing_tag = false; } @@ -1020,7 +1020,7 @@ private function parse_next_tag() { * * See https://html.spec.whatwg.org/#parse-error-incorrectly-closed-comment */ - $closer_at--; // Pre-increment inside condition below reduces risk of accidental infinite looping. + --$closer_at; // Pre-increment inside condition below reduces risk of accidental infinite looping. while ( ++$closer_at < strlen( $html ) ) { $closer_at = strpos( $html, '--', $closer_at ); if ( false === $closer_at ) { @@ -1101,7 +1101,7 @@ private function parse_next_tag() { * See https://html.spec.whatwg.org/#parse-error-missing-end-tag-name */ if ( '>' === $html[ $at + 1 ] ) { - $at++; + ++$at; continue; } diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index d365e0b1e1915..dd98b5e622b7d 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2552,7 +2552,7 @@ function gallery_shortcode( $attr ) { $post = get_post(); static $instance = 0; - $instance++; + ++$instance; if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. @@ -2899,7 +2899,7 @@ function wp_playlist_shortcode( $attr ) { $post = get_post(); static $instance = 0; - $instance++; + ++$instance; if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. @@ -3213,7 +3213,7 @@ function wp_audio_shortcode( $attr, $content = '' ) { $post_id = get_post() ? get_the_ID() : 0; static $instance = 0; - $instance++; + ++$instance; /** * Filters the default audio shortcode output. @@ -3432,7 +3432,7 @@ function wp_video_shortcode( $attr, $content = '' ) { $post_id = get_post() ? get_the_ID() : 0; static $instance = 0; - $instance++; + ++$instance; /** * Filters the default video shortcode output. diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index eaee99f5685c2..65e7d8d78d57d 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -877,7 +877,7 @@ function wp_uninitialize_site( $site_id ) { } @closedir( $dh ); } - $index++; + ++$index; } $stack = array_reverse( $stack ); // Last added directories are deepest. diff --git a/src/wp-includes/pomo/mo.php b/src/wp-includes/pomo/mo.php index dec51cee31310..1bbc40ab65aa2 100644 --- a/src/wp-includes/pomo/mo.php +++ b/src/wp-includes/pomo/mo.php @@ -129,7 +129,7 @@ public function export_to_file_handle( $fh ) { // Headers' msgid is an empty string. fwrite( $fh, pack( 'VV', 0, $current_addr ) ); - $current_addr++; + ++$current_addr; $originals_table = "\0"; $reader = new POMO_Reader(); diff --git a/src/wp-includes/pomo/plural-forms.php b/src/wp-includes/pomo/plural-forms.php index b072bfadac002..ae9c306d989a8 100644 --- a/src/wp-includes/pomo/plural-forms.php +++ b/src/wp-includes/pomo/plural-forms.php @@ -110,19 +110,19 @@ protected function parse( $str ) { // Ignore whitespace. case ' ': case "\t": - $pos++; + ++$pos; break; // Variable (n). case 'n': $output[] = array( 'var' ); - $pos++; + ++$pos; break; // Parentheses. case '(': $stack[] = $next; - $pos++; + ++$pos; break; case ')': @@ -144,7 +144,7 @@ protected function parse( $str ) { throw new Exception( 'Mismatched parentheses' ); } - $pos++; + ++$pos; break; // Operators. @@ -189,7 +189,7 @@ protected function parse( $str ) { $o2 = $stack[ $s_pos ]; if ( '?' !== $o2 ) { $output[] = array( 'op', array_pop( $stack ) ); - $s_pos--; + --$s_pos; continue; } @@ -202,7 +202,7 @@ protected function parse( $str ) { if ( ! $found ) { throw new Exception( 'Missing starting "?" ternary operator' ); } - $pos++; + ++$pos; break; // Default - number or invalid. @@ -264,7 +264,7 @@ public function execute( $n ) { $total = count( $this->tokens ); while ( $i < $total ) { $next = $this->tokens[ $i ]; - $i++; + ++$i; if ( 'var' === $next[0] ) { $stack[] = $n; continue; diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index 89d827c2550b9..7b9ec0b88bb2c 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -342,7 +342,7 @@ public function read_entry( $f, $lineno = 0 ) { $context = ''; $msgstr_index = 0; while ( true ) { - $lineno++; + ++$lineno; $line = PO::read_line( $f ); if ( ! $line ) { if ( feof( $f ) ) { @@ -365,7 +365,7 @@ public function read_entry( $f, $lineno = 0 ) { // The comment is the start of a new entry. if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); - $lineno--; + --$lineno; break; } // Comments have to be at the beginning. @@ -377,7 +377,7 @@ public function read_entry( $f, $lineno = 0 ) { } elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) { if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); - $lineno--; + --$lineno; break; } if ( $context && 'comment' !== $context ) { @@ -388,7 +388,7 @@ public function read_entry( $f, $lineno = 0 ) { } elseif ( preg_match( '/^msgid\s+(".*")/', $line, $m ) ) { if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); - $lineno--; + --$lineno; break; } if ( $context && 'msgctxt' !== $context && 'comment' !== $context ) { diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php index d3a1d3cbd09a9..a5534a8ea9d02 100644 --- a/src/wp-includes/pomo/translations.php +++ b/src/wp-includes/pomo/translations.php @@ -261,7 +261,7 @@ public function parenthesize_plural_exression( $expression ) { switch ( $char ) { case '?': $res .= ' ? ('; - $depth++; + ++$depth; break; case ':': $res .= ') : ('; diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 5d7aee24ee663..2a8d6b41f6844 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -5073,7 +5073,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) ); - $suffix++; + ++$suffix; } while ( $post_name_check ); $slug = $alt_post_name; } @@ -5110,7 +5110,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) ); - $suffix++; + ++$suffix; } while ( $post_name_check ); $slug = $alt_post_name; } @@ -5166,7 +5166,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p do { $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) ); - $suffix++; + ++$suffix; } while ( $post_name_check ); $slug = $alt_post_name; } @@ -5758,7 +5758,7 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { * ensuring each matches the post ancestry. */ while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) { - $count++; + ++$count; $parent = $pages[ $p->post_parent ]; if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) { break; diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 52a5705331798..3eb36552e618f 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -3090,7 +3090,7 @@ function wp_unique_term_slug( $slug, $term ) { $num = 2; do { $alt_slug = $slug . "-$num"; - $num++; + ++$num; $slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) ); } while ( $slug_check ); $slug = $alt_slug; diff --git a/src/wp-includes/theme-templates.php b/src/wp-includes/theme-templates.php index 114d7205d470c..2f233ca1d1946 100644 --- a/src/wp-includes/theme-templates.php +++ b/src/wp-includes/theme-templates.php @@ -90,7 +90,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id $alt_post_name = _truncate_post_slug( $override_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; $query_args['post_name__in'] = array( $alt_post_name ); $query = new WP_Query( $query_args ); - $suffix++; + ++$suffix; } while ( count( $query->posts ) > 0 ); $override_slug = $alt_post_name; } diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 5f8fe3807154e..aaba3a7e7e095 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -1316,11 +1316,11 @@ function count_users( $strategy = 'time', $site_id = null ) { continue; } if ( empty( $b_roles ) ) { - $avail_roles['none']++; + ++$avail_roles['none']; } foreach ( $b_roles as $b_role => $val ) { if ( isset( $avail_roles[ $b_role ] ) ) { - $avail_roles[ $b_role ]++; + ++$avail_roles[ $b_role ]; } else { $avail_roles[ $b_role ] = 1; } @@ -2177,7 +2177,7 @@ function wp_insert_user( $userdata ) { $base_length = 49 - mb_strlen( $suffix ); $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; $user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) ); - $suffix++; + ++$suffix; } $user_nicename = $alt_user_nicename; } diff --git a/src/wp-includes/widgets/class-wp-widget-calendar.php b/src/wp-includes/widgets/class-wp-widget-calendar.php index 6ab373fc42fe4..9103934173f8e 100644 --- a/src/wp-includes/widgets/class-wp-widget-calendar.php +++ b/src/wp-includes/widgets/class-wp-widget-calendar.php @@ -66,7 +66,7 @@ public function widget( $args, $instance ) { echo ''; echo $args['after_widget']; - self::$instance++; + ++self::$instance; } /** diff --git a/src/wp-includes/widgets/class-wp-widget-media.php b/src/wp-includes/widgets/class-wp-widget-media.php index ebca22ec66955..2352ae837b05a 100644 --- a/src/wp-includes/widgets/class-wp-widget-media.php +++ b/src/wp-includes/widgets/class-wp-widget-media.php @@ -373,7 +373,7 @@ public function display_media_state( $states, $post = null ) { $use_count = 0; foreach ( $this->get_settings() as $instance ) { if ( isset( $instance['attachment_id'] ) && $instance['attachment_id'] === $post->ID ) { - $use_count++; + ++$use_count; } } diff --git a/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php b/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php index 9391dd8bf7d9c..6412c15db7d8d 100644 --- a/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php +++ b/tests/phpunit/includes/factory/class-wp-unittest-generator-sequence.php @@ -9,7 +9,7 @@ public function __construct( $template_string = '%s', $start = null ) { if ( $start ) { $this->next = $start; } else { - self::$incr++; + ++self::$incr; $this->next = self::$incr; } $this->template_string = $template_string; @@ -17,7 +17,7 @@ public function __construct( $template_string = '%s', $start = null ) { public function next() { $generated = sprintf( $this->template_string, $this->next ); - $this->next++; + ++$this->next; return $generated; } diff --git a/tests/phpunit/includes/testcase-rest-post-type-controller.php b/tests/phpunit/includes/testcase-rest-post-type-controller.php index 0fc03ef5ec621..cd8ccaefc7b14 100644 --- a/tests/phpunit/includes/testcase-rest-post-type-controller.php +++ b/tests/phpunit/includes/testcase-rest-post-type-controller.php @@ -193,7 +193,7 @@ protected function check_post_data( $post, $data, $context, $links ) { foreach ( $taxonomies as $key => $taxonomy ) { $this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] ); $this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] ); - $num++; + ++$num; } } } diff --git a/tests/phpunit/includes/wp-profiler.php b/tests/phpunit/includes/wp-profiler.php index 293f85645d779..5c4ea902d095c 100644 --- a/tests/phpunit/includes/wp-profiler.php +++ b/tests/phpunit/includes/wp-profiler.php @@ -72,7 +72,7 @@ public function stop() { if ( isset( $this->profile[ $name ] ) ) { $this->profile[ $name ]['time'] += $time; - $this->profile[ $name ]['calls']++; + ++$this->profile[ $name ]['calls']; $this->profile[ $name ]['cache_cold_hits'] += ( $wp_object_cache->cold_cache_hits - $item['cache_cold_hits'] ); $this->profile[ $name ]['cache_warm_hits'] += ( $wp_object_cache->warm_cache_hits - $item['cache_warm_hits'] ); $this->profile[ $name ]['cache_misses'] += ( $wp_object_cache->cache_misses - $item['cache_misses'] ); @@ -113,9 +113,9 @@ public function log_filter( $tag ) { if ( $this->stack ) { global $wp_actions; if ( end( $wp_actions ) === $tag ) { - $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++; + ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]; } else { - $this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++; + ++$this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]; } } return $arg; @@ -123,7 +123,7 @@ public function log_filter( $tag ) { public function log_action( $tag ) { if ( $this->stack ) { - $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++; + ++$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]; } } @@ -142,7 +142,7 @@ public function _query_summary( $queries, &$out ) { $sql = preg_replace( '/(WHERE \w+ =) \d+/', '$1 x', $sql ); $sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql ); - $out[ $sql ]++; + ++$out[ $sql ]; } asort( $out ); return; @@ -153,9 +153,9 @@ public function _query_count( $queries ) { $out = array(); foreach ( $queries as $q ) { if ( empty( $q[2] ) ) { - $out['unknown']++; + ++$out['unknown']; } else { - $out[ $q[2] ]++; + ++$out[ $q[2] ]; } } return $out; diff --git a/tests/phpunit/tests/blocks/wpBlockList.php b/tests/phpunit/tests/blocks/wpBlockList.php index 2194bc5a98733..48b040e918f82 100644 --- a/tests/phpunit/tests/blocks/wpBlockList.php +++ b/tests/phpunit/tests/blocks/wpBlockList.php @@ -71,10 +71,10 @@ public function test_iterable() { foreach ( $blocks as $block ) { $this->assertSame( 'core/example', $block->name ); - $assertions++; + ++$assertions; foreach ( $block->inner_blocks as $inner_block ) { $this->assertSame( 'core/example', $inner_block->name ); - $assertions++; + ++$assertions; } } @@ -83,9 +83,9 @@ public function test_iterable() { $key = $blocks->key(); $block = $blocks->current(); $this->assertSame( 0, $key ); - $assertions++; + ++$assertions; $this->assertSame( 'core/example', $block->name ); - $assertions++; + ++$assertions; $blocks->next(); } diff --git a/tests/phpunit/tests/comment/metaCache.php b/tests/phpunit/tests/comment/metaCache.php index 5a6d716e914e8..828363e580544 100644 --- a/tests/phpunit/tests/comment/metaCache.php +++ b/tests/phpunit/tests/comment/metaCache.php @@ -243,7 +243,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries( // First comment will cause the cache to be primed. $num_queries = get_num_queries(); $this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); // Second comment from the results should not cause more queries. @@ -252,7 +252,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries( // A comment from outside the results will not be primed. $this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); } @@ -293,7 +293,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_f // First comment will cause the cache to be primed. $num_queries = get_num_queries(); $this->assertSame( 'bar', get_comment_meta( $comments[0], 'foo', 'bar' ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); // Second comment from the results should not cause more queries. @@ -302,7 +302,7 @@ public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_f // A comment from outside the results will not be primed. $this->assertSame( 'bar', get_comment_meta( $comments[4], 'foo', 'bar' ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); } diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 65f9af6253e13..50cd9107960ca 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -4769,7 +4769,7 @@ public function test_updated_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array( $c ), $q->comments ); } @@ -4805,7 +4805,7 @@ public function test_deleted_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array(), $q->comments ); } @@ -4841,7 +4841,7 @@ public function test_trashed_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array(), $q->comments ); } @@ -4879,7 +4879,7 @@ public function test_untrashed_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array( $c ), $q->comments ); } @@ -4915,7 +4915,7 @@ public function test_spammed_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array(), $q->comments ); } @@ -4953,7 +4953,7 @@ public function test_unspammed_comment_should_invalidate_query_cache() { ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSameSets( array( $c ), $q->comments ); } diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php index 2337ab61ec059..fffcb47ad5665 100644 --- a/tests/phpunit/tests/date/theDate.php +++ b/tests/phpunit/tests/date/theDate.php @@ -80,7 +80,7 @@ public function test_should_call_hooks() { } public function count_hook( $input ) { - $this->hooks_called[ current_filter() ]++; + ++$this->hooks_called[ current_filter() ]; return $input; } diff --git a/tests/phpunit/tests/feed/atom.php b/tests/phpunit/tests/feed/atom.php index 403f1152a46b2..dae234f51caf5 100644 --- a/tests/phpunit/tests/feed/atom.php +++ b/tests/phpunit/tests/feed/atom.php @@ -287,7 +287,7 @@ public function test_atom_enclosure_with_extended_url_length_type_parsing() { $this->assertSame( $enclosures[ $i ]['expected']['href'], $link['attributes']['href'] ); $this->assertEquals( $enclosures[ $i ]['expected']['length'], $link['attributes']['length'] ); $this->assertSame( $enclosures[ $i ]['expected']['type'], $link['attributes']['type'] ); - $i++; + ++$i; } } } diff --git a/tests/phpunit/tests/import/base.php b/tests/phpunit/tests/import/base.php index db83296c0afcb..d0fefb1a925ec 100644 --- a/tests/phpunit/tests/import/base.php +++ b/tests/phpunit/tests/import/base.php @@ -42,7 +42,7 @@ protected function _import_wp( $filename, $users = array(), $fetch_files = true $new[ $i ] = $map; } - $i++; + ++$i; } $_POST = array( diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index db1f35b6d0466..c7fb78e54778f 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -267,7 +267,7 @@ public function test_is_plugin_active_for_network_false() { } public function helper_deactivate_hook() { - $this->plugin_hook_count++; + ++$this->plugin_hook_count; } public function test_wp_schedule_update_network_counts() { diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 4b201cd912108..aa04499105464 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -422,7 +422,7 @@ public function test_wpmu_update_blogs_date() { public function test_get_blog_details_when_site_does_not_exist() { // Create an unused site so that we can then assume an invalid site ID. $blog_id = self::factory()->blog->create(); - $blog_id++; + ++$blog_id; // Prime the cache for an invalid site. get_blog_details( $blog_id ); diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 238b1faf1fa49..821eeac7e3ab5 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -171,7 +171,7 @@ public function filter_oembed_result( $data, $url, $args ) { } $this->assertIsString( $url ); $this->assertIsArray( $args ); - $this->oembed_result_filter_count++; + ++$this->oembed_result_filter_count; return $data; } diff --git a/tests/phpunit/tests/pluggable/signatures.php b/tests/phpunit/tests/pluggable/signatures.php index 84a828d348307..81fd079621916 100644 --- a/tests/phpunit/tests/pluggable/signatures.php +++ b/tests/phpunit/tests/pluggable/signatures.php @@ -44,7 +44,7 @@ public function test_pluggable_function_signatures_match( $function_name ) { $this->assertSame( $name, $param_ref->getName(), $msg ); - $i++; + ++$i; } } diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php index 0343302c689ef..439064f7c49de 100644 --- a/tests/phpunit/tests/pomo/pluralForms.php +++ b/tests/phpunit/tests/pomo/pluralForms.php @@ -21,7 +21,7 @@ protected static function parenthesize_plural_expression( $expression ) { switch ( $char ) { case '?': $res .= ' ? ('; - $depth++; + ++$depth; break; case ':': $res .= ') : ('; diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index 5d26b88d2de19..8db0274249bed 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -343,7 +343,7 @@ public function test_cache_should_not_match_post_in_different_post_type_with_sam $found = get_page_by_path( 'foo', OBJECT, 'wptests_pt' ); $this->assertSame( $p2, $found->ID ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); } @@ -373,7 +373,7 @@ public function test_cache_should_be_invalidated_when_post_name_is_edited() { $found = get_page_by_path( 'bar' ); $this->assertSame( $page, $found->ID ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); } diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index cc17ccd60d5df..8bdcb399b4a46 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -736,7 +736,7 @@ public function test_wp_get_post_revisions_url( $revisions ) { ) ); - $latest_revision_id++; + ++$latest_revision_id; } } @@ -784,7 +784,7 @@ public function test_wp_get_post_revisions_url_with_post_object( $revisions ) { ) ); - $latest_revision_id++; + ++$latest_revision_id; } } diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index aca3c794f97fb..0e721258ed40a 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -1983,11 +1983,11 @@ public function test_create_item_with_meta_values() { } public function filter_rest_insert_attachment( $attachment ) { - self::$rest_insert_attachment_count++; + ++self::$rest_insert_attachment_count; } public function filter_rest_after_insert_attachment( $attachment ) { - self::$rest_after_insert_attachment_count++; + ++self::$rest_after_insert_attachment_count; } /** diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index a6ad0cf7005b0..a9019f227d723 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -631,8 +631,8 @@ public function test_get_terms_pagination_headers() { // 3rd page. self::factory()->category->create(); - $total_categories++; - $total_pages++; + ++$total_categories; + ++$total_pages; $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 9b4444f559554..ab8f672c5de8a 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -828,8 +828,8 @@ public function test_get_comments_pagination_headers() { 'comment_post_ID' => self::$post_id, ) ); - $total_comments++; - $total_pages++; + ++$total_comments; + ++$total_pages; $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 2722cfa7349bd..92d1262195456 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -1662,8 +1662,8 @@ public function test_get_items_pagination_headers() { // 3rd page. self::factory()->post->create(); - $total_posts++; - $total_pages++; + ++$total_posts; + ++$total_pages; $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); @@ -2279,7 +2279,7 @@ public function test_prepare_item_limit_fields() { public function test_prepare_item_filters_content_when_needed() { $filter_count = 0; $filter_content = static function() use ( &$filter_count ) { - $filter_count++; + ++$filter_count; return '

Filtered content.

'; }; add_filter( 'the_content', $filter_content ); @@ -2315,7 +2315,7 @@ public function test_prepare_item_filters_content_when_needed() { public function test_prepare_item_skips_content_filter_if_not_needed() { $filter_count = 0; $filter_content = static function() use ( &$filter_count ) { - $filter_count++; + ++$filter_count; return '

Filtered content.

'; }; add_filter( 'the_content', $filter_content ); diff --git a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php index 8dab4f6ba97f7..0bddf12df92b9 100644 --- a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php +++ b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php @@ -1012,7 +1012,7 @@ protected function remove_links( $data ) { if ( isset( $item['_links'] ) ) { unset( $data[ $count ]['_links'] ); } - $count++; + ++$count; } return $data; diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index d50bcedaaa3e3..6fb75eb93ec0e 100644 --- a/tests/phpunit/tests/rest-api/rest-tags-controller.php +++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php @@ -415,7 +415,7 @@ public function test_get_terms_post_args_paging() { $i = 0; foreach ( $tags as $tag ) { $this->assertSame( $tag['name'], "Tag {$i}" ); - $i++; + ++$i; } $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); @@ -430,7 +430,7 @@ public function test_get_terms_post_args_paging() { foreach ( $tags as $tag ) { $this->assertSame( $tag['name'], "Tag {$i}" ); - $i++; + ++$i; } } @@ -599,8 +599,8 @@ public function test_get_terms_pagination_headers() { // 3rd page. self::factory()->tag->create(); - $total_tags++; - $total_pages++; + ++$total_tags; + ++$total_pages; $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 72c1f7d6e250e..f4dbc2d57f379 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -339,8 +339,8 @@ public function test_get_items_pagination_headers() { // 3rd page. self::factory()->user->create(); - $total_users++; - $total_pages++; + ++$total_users; + ++$total_pages; $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php index 22516737c338d..69672a722627c 100644 --- a/tests/phpunit/tests/rest-api/rest-widgets-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widgets-controller.php @@ -1551,7 +1551,7 @@ protected function remove_links( $data ) { if ( is_array( $item ) && isset( $item['_links'] ) ) { unset( $data[ $count ]['_links'] ); } - $count++; + ++$count; } return $data; diff --git a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php index 4687700cc798f..72dfab5f466e1 100644 --- a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php +++ b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php @@ -918,7 +918,7 @@ protected function check_menu_item_data( $post, $data, $context, $links ) { foreach ( $taxonomies as $taxonomy ) { $this->assertSame( $taxonomy->name, $links['https://api.w.org/term'][ $num ]['attributes']['taxonomy'] ); $this->assertSame( add_query_arg( 'post', $data['id'], rest_url( 'wp/v2/' . $taxonomy->rest_base ) ), $links['https://api.w.org/term'][ $num ]['href'] ); - $num++; + ++$num; } if ( 'post_type' === $data['type'] ) { diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 8efd55da00d0c..ac418fbcfd5c0 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -73,12 +73,12 @@ public function test_hierachy_invalidation() { case 2: $parent = wp_insert_term( 'Child' . $i, $tax, array( 'parent' => $parent_id ) ); $parent_id = $parent['term_id']; - $children++; + ++$children; break; case 3: wp_insert_term( 'Grandchild' . $i, $tax, array( 'parent' => $parent_id ) ); $parent_id = 0; - $children++; + ++$children; break; } @@ -93,7 +93,7 @@ public function test_hierachy_invalidation() { if ( 0 === ( $i % 3 ) ) { $step = 1; } else { - $step++; + ++$step; } } @@ -418,7 +418,7 @@ public function test_get_term_by_does_not_prime_term_meta_cache() { $this->assertSame( $num_queries, get_num_queries() ); $term_meta = get_term_meta( $term_id, 'foo', true ); - $num_queries++; + ++$num_queries; $this->assertSame( $term_meta, 'bar' ); $this->assertSame( $num_queries, get_num_queries() ); } diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index 36567a7830884..ed6acab691fc5 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -233,7 +233,7 @@ public function test_shared_term_in_cache_should_be_ignored_when_specifying_a_di // Database should be hit again. $found = get_term( $terms[1]['term_id'], 'wptests_tax_2' ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertInstanceOf( 'WP_Term', $found ); diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index d46f35ae1dbd7..248d1909179d3 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -139,7 +139,7 @@ public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_l // First request will hit the database. $num_queries = get_num_queries(); $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); // Second and third requests should be in cache. @@ -148,7 +148,7 @@ public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_l $this->assertSame( $num_queries, get_num_queries() ); // Querying a term not primed should result in a hit. - $num_queries++; + ++$num_queries; $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) ); $this->assertSame( $num_queries, get_num_queries() ); } @@ -208,11 +208,11 @@ public function test_lazy_load_term_meta_false() { // Requests will hit the database. $num_queries = get_num_queries(); $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) ); - $num_queries++; + ++$num_queries; $this->assertSame( $num_queries, get_num_queries() ); } } diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index d75ff476b3e30..98f67fea5da4f 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -393,7 +393,7 @@ public function test_get_core_data( $should_fire_filter, $core_is_cached, $block $expected_filter_count = did_filter( 'wp_theme_json_data_default' ); $actual = WP_Theme_JSON_Resolver::get_core_data(); if ( $should_fire_filter ) { - $expected_filter_count++; + ++$expected_filter_count; } $this->assertSame( $expected_filter_count, did_filter( 'wp_theme_json_data_default' ), 'The filter "wp_theme_json_data_default" should fire the given number of times' ); diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php index 1561d3a03cccc..4768e25b7770a 100644 --- a/tests/phpunit/tests/url.php +++ b/tests/phpunit/tests/url.php @@ -339,7 +339,7 @@ public function test_set_url_scheme() { $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'login' ) ); $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'rpc' ) ); - $i++; + ++$i; } force_ssl_admin( $forced_admin ); diff --git a/tests/phpunit/tests/widgets/wpWidgetText.php b/tests/phpunit/tests/widgets/wpWidgetText.php index cccdcbe957c74..a1570da63a550 100644 --- a/tests/phpunit/tests/widgets/wpWidgetText.php +++ b/tests/phpunit/tests/widgets/wpWidgetText.php @@ -303,7 +303,7 @@ public function test_widget() { */ public function do_example_shortcode() { $this->post_during_shortcode = get_post(); - $this->shortcode_render_count++; + ++$this->shortcode_render_count; return $this->example_shortcode_content; }