Skip to content

Commit 54e1b4b

Browse files
SergeyBiryukovSergeyBiryukov
authored andcommitted
Coding Standards: Use pre-increment/decrement for stand-alone statements.
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] * [WordPress/WordPress-Coding-Standards#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
1 parent 1118e37 commit 54e1b4b

File tree

95 files changed

+212
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+212
-212
lines changed

src/wp-admin/edit-comments.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,31 @@
8484
switch ( $doaction ) {
8585
case 'approve':
8686
wp_set_comment_status( $comment_id, 'approve' );
87-
$approved++;
87+
++$approved;
8888
break;
8989
case 'unapprove':
9090
wp_set_comment_status( $comment_id, 'hold' );
91-
$unapproved++;
91+
++$unapproved;
9292
break;
9393
case 'spam':
9494
wp_spam_comment( $comment_id );
95-
$spammed++;
95+
++$spammed;
9696
break;
9797
case 'unspam':
9898
wp_unspam_comment( $comment_id );
99-
$unspammed++;
99+
++$unspammed;
100100
break;
101101
case 'trash':
102102
wp_trash_comment( $comment_id );
103-
$trashed++;
103+
++$trashed;
104104
break;
105105
case 'untrash':
106106
wp_untrash_comment( $comment_id );
107-
$untrashed++;
107+
++$untrashed;
108108
break;
109109
case 'delete':
110110
wp_delete_comment( $comment_id );
111-
$deleted++;
111+
++$deleted;
112112
break;
113113
}
114114
}

src/wp-admin/edit.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@
124124
}
125125

126126
if ( wp_check_post_lock( $post_id ) ) {
127-
$locked++;
127+
++$locked;
128128
continue;
129129
}
130130

131131
if ( ! wp_trash_post( $post_id ) ) {
132132
wp_die( __( 'Error in moving the item to Trash.' ) );
133133
}
134134

135-
$trashed++;
135+
++$trashed;
136136
}
137137

138138
$sendback = add_query_arg(
@@ -160,7 +160,7 @@
160160
wp_die( __( 'Error in restoring the item from Trash.' ) );
161161
}
162162

163-
$untrashed++;
163+
++$untrashed;
164164
}
165165
$sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
166166

@@ -185,7 +185,7 @@
185185
wp_die( __( 'Error in deleting the item.' ) );
186186
}
187187
}
188-
$deleted++;
188+
++$deleted;
189189
}
190190
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
191191
break;

src/wp-admin/includes/ajax-actions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ function wp_ajax_inline_save() {
21492149
while ( $parent > 0 ) {
21502150
$parent_post = get_post( $parent );
21512151
$parent = $parent_post->post_parent;
2152-
$level++;
2152+
++$level;
21532153
}
21542154
}
21552155

@@ -2211,7 +2211,7 @@ function wp_ajax_inline_save_tax() {
22112211
while ( $parent > 0 ) {
22122212
$parent_tag = get_term( $parent, $taxonomy );
22132213
$parent = $parent_tag->parent;
2214-
$level++;
2214+
++$level;
22152215
}
22162216

22172217
$wp_list_table->single_row( $tag, $level );
@@ -2821,7 +2821,7 @@ function wp_ajax_set_attachment_thumbnail() {
28212821
}
28222822

28232823
if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
2824-
$success++;
2824+
++$success;
28252825
}
28262826
}
28272827

src/wp-admin/includes/class-language-pack-upgrader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function bulk_upgrade( $language_updates = array(), $args = array() ) {
238238
$destination .= '/themes';
239239
}
240240

241-
$this->update_current++;
241+
++$this->update_current;
242242

243243
$options = array(
244244
'package' => $language_update->package,

src/wp-admin/includes/class-plugin-upgrader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public function bulk_upgrade( $plugins, $args = array() ) {
330330
$this->update_count = count( $plugins );
331331
$this->update_current = 0;
332332
foreach ( $plugins as $plugin ) {
333-
$this->update_current++;
333+
++$this->update_current;
334334
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );
335335

336336
if ( ! isset( $current->response[ $plugin ] ) ) {

src/wp-admin/includes/class-theme-upgrader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function bulk_upgrade( $themes, $args = array() ) {
426426
$this->update_count = count( $themes );
427427
$this->update_current = 0;
428428
foreach ( $themes as $theme ) {
429-
$this->update_current++;
429+
++$this->update_current;
430430

431431
$this->skin->theme_info = $this->theme_info( $theme );
432432

src/wp-admin/includes/class-wp-automatic-updater.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ protected function send_debug_email() {
13901390
} else {
13911391
/* translators: %s: WordPress version. */
13921392
$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
1393-
$failures++;
1393+
++$failures;
13941394
}
13951395

13961396
$body[] = '';
@@ -1432,7 +1432,7 @@ protected function send_debug_email() {
14321432
if ( ! $item->result || is_wp_error( $item->result ) ) {
14331433
/* translators: %s: Name of plugin / theme / translation. */
14341434
$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
1435-
$failures++;
1435+
++$failures;
14361436
}
14371437
}
14381438
}

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ public function print_column_headers( $with_id = true ) {
14101410
'</span>' .
14111411
'</label>' .
14121412
'<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
1413-
$cb_counter++;
1413+
++$cb_counter;
14141414
}
14151415

14161416
foreach ( $columns as $column_key => $column_display_name ) {

src/wp-admin/includes/class-wp-plugins-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public function single_row( $item ) {
728728
$suffix = 2;
729729
while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) {
730730
$plugin_id_attr = "$plugin_slug-$suffix";
731-
$suffix++;
731+
++$suffix;
732732
}
733733

734734
$plugin_id_attrs[] = $plugin_id_attr;

src/wp-admin/includes/class-wp-posts-list-table.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 2
898898
$to_display[ $page->ID ] = $level;
899899
}
900900

901-
$count++;
901+
++$count;
902902

903903
if ( isset( $children_pages ) ) {
904904
$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
917917
$to_display[ $op->ID ] = 0;
918918
}
919919

920-
$count++;
920+
++$count;
921921
}
922922
}
923923
}
@@ -992,15 +992,15 @@ private function _page_rows( &$children_pages, &$count, $parent_page, $level, $p
992992

993993
while ( $my_parent = array_pop( $my_parents ) ) {
994994
$to_display[ $my_parent->ID ] = $level - $num_parents;
995-
$num_parents--;
995+
--$num_parents;
996996
}
997997
}
998998

999999
if ( $count >= $start ) {
10001000
$to_display[ $page->ID ] = $level;
10011001
}
10021002

1003-
$count++;
1003+
++$count;
10041004

10051005
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
10061006
}
@@ -1097,7 +1097,7 @@ public function column_title( $post ) {
10971097
break;
10981098
}
10991099

1100-
$this->current_level++;
1100+
++$this->current_level;
11011101
$find_main_page = (int) $parent->post_parent;
11021102

11031103
if ( ! isset( $parent_name ) ) {
@@ -2085,7 +2085,7 @@ public function inline_edit() {
20852085
</td></tr>
20862086

20872087
<?php
2088-
$bulk++;
2088+
++$bulk;
20892089
endwhile;
20902090
?>
20912091
</tbody></table>

0 commit comments

Comments
 (0)